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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. kAdjustGamma,
  45. kEqualize
  46. };
  47. CVOpCommon();
  48. ~CVOpCommon();
  49. void SetUp();
  50. std::string GetFilename();
  51. void GetInputImage(std::string filename);
  52. void Save(const std::shared_ptr<Tensor> &tensor, std::string filename);
  53. std::string GetJPGStr(const cv::Mat &image);
  54. bool CompareCVMat(const cv::Mat &actual, const cv::Mat &expect, OperatorType type);
  55. void CheckImageShapeAndData(const std::shared_ptr<Tensor> &output_tensor, OperatorType type);
  56. std::string filename_;
  57. cv::Mat raw_cv_image_;
  58. std::shared_ptr<Tensor> raw_input_tensor_;
  59. std::shared_ptr<Tensor> input_tensor_;
  60. };
  61. } // namespace CVOP
  62. } // namespace UT
  63. #endif // TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_