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 19 #include <memory> 20 #include <string> 21 #include "common.h" 22 #include "minddata/dataset/kernels/image/image_utils.h" 23 24 namespace UT { 25 namespace CVOP { 26 using namespace mindspore::dataset; 27 28 class CVOpCommon : public Common { 29 public: 30 enum OperatorType { 31 kResizeArea, 32 kResizeBilinear, 33 kRescale, 34 kFlipVertical, 35 kFlipHorizontal, 36 kDecode, 37 kChannelSwap, 38 kChangeMode, 39 kRandomSolarize, 40 kTemplate, 41 kCrop, 42 kRandomSharpness, 43 kInvert, 44 kRandomAffine, 45 kRandomPosterize, 46 kAutoContrast, 47 kAdjustGamma, 48 kEqualize 49 }; 50 51 CVOpCommon(); 52 53 ~CVOpCommon(); 54 55 void SetUp(); 56 57 std::string GetFilename(); 58 59 void GetInputImage(std::string filename); 60 61 void Save(const std::shared_ptr<Tensor> &tensor, std::string filename); 62 63 std::string GetJPGStr(const cv::Mat &image); 64 65 bool CompareCVMat(const cv::Mat &actual, const cv::Mat &expect, OperatorType type); 66 67 void CheckImageShapeAndData(const std::shared_ptr<Tensor> &output_tensor, OperatorType type); 68 69 std::string filename_; 70 cv::Mat raw_cv_image_; 71 72 std::shared_ptr<Tensor> raw_input_tensor_; 73 std::shared_ptr<Tensor> input_tensor_; 74 }; 75 } // namespace CVOP 76 } // namespace UT 77 #endif // TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_ 78