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 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. kTemplate,
  37. kCrop
  38. };
  39. CVOpCommon();
  40. ~CVOpCommon();
  41. void SetUp();
  42. std::string GetFilename();
  43. void GetInputImage(std::string filename);
  44. void Save(const std::shared_ptr<Tensor> &tensor, std::string filename);
  45. std::string GetJPGStr(const cv::Mat &image);
  46. bool CompareCVMat(const cv::Mat &actual, const cv::Mat &expect, OperatorType type);
  47. void CheckImageShapeAndData(const std::shared_ptr<Tensor> &output_tensor, OperatorType type);
  48. std::string filename_;
  49. cv::Mat raw_cv_image_;
  50. std::shared_ptr<Tensor> raw_input_tensor_;
  51. std::shared_ptr<Tensor> input_tensor_;
  52. };
  53. } // namespace CVOP
  54. } // namespace UT
  55. #endif // TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_