1 /**
2 * Copyright 2020 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 #include "common/bboxop_common.h"
17 #include "minddata/dataset/kernels/image/bounding_box_augment_op.h"
18 #include "minddata/dataset/kernels/image/random_rotation_op.h"
19 #include "utils/log_adapter.h"
20
21 using namespace mindspore::dataset;
22 using mindspore::LogStream;
23 using mindspore::ExceptionType::NoExceptionType;
24 using mindspore::MsLogLevel::INFO;
25
26 const bool kSaveExpected = false;
27 const char kOpName[] = "bounding_box_augment_op";
28
29 class MindDataTestBoundingBoxAugmentOp : public UT::CVOP::BBOXOP::BBoxOpCommon {
30 protected:
MindDataTestBoundingBoxAugmentOp()31 MindDataTestBoundingBoxAugmentOp() : UT::CVOP::BBOXOP::BBoxOpCommon() {}
32 };
33
TEST_F(MindDataTestBoundingBoxAugmentOp,TestOp)34 TEST_F(MindDataTestBoundingBoxAugmentOp, TestOp) {
35 MS_LOG(INFO) << "Doing testBoundingBoxAugment.";
36 TensorTable results;
37 std::unique_ptr<BoundingBoxAugmentOp> op =
38 std::make_unique<BoundingBoxAugmentOp>(std::make_shared<RandomRotationOp>(90, 90), 1);
39 for (const auto &row : images_and_annotations_) {
40 TensorRow output_row;
41 Status s = op->Compute(row, &output_row);
42 EXPECT_TRUE(s.IsOk());
43 results.push_back(output_row);
44 }
45 if (kSaveExpected) {
46 SaveImagesWithAnnotations(FileType::kExpected, std::string(kOpName), results);
47 }
48 SaveImagesWithAnnotations(FileType::kActual, std::string(kOpName), results);
49 if (!kSaveExpected) {
50 CompareActualAndExpected(std::string(kOpName));
51 }
52 }
53