• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     kRandomLighting,
44     kInvert,
45     kRandomAffine,
46     kRandomPosterize,
47     kAutoContrast,
48     kAdjustGamma,
49     kEqualize
50   };
51 
52   CVOpCommon();
53 
54   ~CVOpCommon();
55 
56   void SetUp();
57 
58   std::string GetFilename();
59 
60   void GetInputImage(std::string filename);
61 
62   void Save(const std::shared_ptr<Tensor> &tensor, std::string filename);
63 
64   std::string GetJPGStr(const cv::Mat &image);
65 
66   bool CompareCVMat(const cv::Mat &actual, const cv::Mat &expect, OperatorType type);
67 
68   void CheckImageShapeAndData(const std::shared_ptr<Tensor> &output_tensor, OperatorType type);
69 
70   std::string filename_;
71   cv::Mat raw_cv_image_;
72 
73   std::shared_ptr<Tensor> raw_input_tensor_;
74   std::shared_ptr<Tensor> input_tensor_;
75 };
76 }  // namespace CVOP
77 }  // namespace UT
78 #endif  // TESTS_DATASET_UT_CORE_COMMON_DE_UT_CVOP_COMMON_H_
79