You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cvop_common.h 2.0 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_
  17. #define TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_
  18. #include <memory>
  19. #include <string>
  20. #include "common.h"
  21. #include "minddata/dataset/kernels/image/image_utils.h"
  22. namespace UT {
  23. namespace CVOP {
  24. using namespace mindspore::dataset;
  25. class CVOpCommon : public Common {
  26. public:
  27. enum OperatorType {
  28. kResizeArea,
  29. kResizeBilinear,
  30. kRescale,
  31. kFlipVertical,
  32. kFlipHorizontal,
  33. kDecode,
  34. kChannelSwap,
  35. kChangeMode,
  36. kRandomSolarize,
  37. kTemplate,
  38. kCrop,
  39. kRandomSharpness,
  40. kInvert,
  41. kRandomAffine,
  42. kRandomPosterize,
  43. kAutoContrast,
  44. kEqualize
  45. };
  46. CVOpCommon();
  47. ~CVOpCommon();
  48. void SetUp();
  49. std::string GetFilename();
  50. void GetInputImage(std::string filename);
  51. void Save(const std::shared_ptr<Tensor> &tensor, std::string filename);
  52. std::string GetJPGStr(const cv::Mat &image);
  53. bool CompareCVMat(const cv::Mat &actual, const cv::Mat &expect, OperatorType type);
  54. void CheckImageShapeAndData(const std::shared_ptr<Tensor> &output_tensor, OperatorType type);
  55. std::string filename_;
  56. cv::Mat raw_cv_image_;
  57. std::shared_ptr<Tensor> raw_input_tensor_;
  58. std::shared_ptr<Tensor> input_tensor_;
  59. };
  60. } // namespace CVOP
  61. } // namespace UT
  62. #endif // TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_