• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2023 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 MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RESIZE_WITH_BBOX_OP_H_
17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RESIZE_WITH_BBOX_OP_H_
18 
19 #include <memory>
20 #include <string>
21 
22 #include "minddata/dataset/core/tensor.h"
23 #include "minddata/dataset/kernels/image/image_utils.h"
24 #include "minddata/dataset/kernels/image/resize_op.h"
25 #include "minddata/dataset/kernels/tensor_op.h"
26 #include "minddata/dataset/util/status.h"
27 
28 namespace mindspore {
29 namespace dataset {
30 class ResizeWithBBoxOp : public ResizeOp {
31  public:
32   //  Constructor for ResizeWithBBoxOp, with default value and passing to base class constructor
33   explicit ResizeWithBBoxOp(int32_t size_1, int32_t size_2 = kDefWidth,
34                             InterpolationMode mInterpolation = kDefInterpolation)
ResizeOp(size_1,size_2,mInterpolation)35       : ResizeOp(size_1, size_2, mInterpolation) {}
36 
37   ~ResizeWithBBoxOp() override = default;
38 
Print(std::ostream & out)39   void Print(std::ostream &out) const override { out << Name() << ": " << size1_ << " " << size2_; }
40 
41   // Use in pipeline mode
42   Status Compute(const TensorRow &input, TensorRow *output) override;
43 
44   // Use in execute mode
45   // ResizeWithBBoxOp is inherited from ResizeOp and this function has been overridden by ResizeOp,
46   // thus we need to change the behavior back to basic class (TensorOp).
Compute(const std::shared_ptr<Tensor> & input,std::shared_ptr<Tensor> * output)47   Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override {
48     return TensorOp::Compute(input, output);
49   }
50 
Name()51   std::string Name() const override { return kResizeWithBBoxOp; }
52 
NumInput()53   uint32_t NumInput() override { return 2; }
54 
NumOutput()55   uint32_t NumOutput() override { return 2; }
56 };
57 }  // namespace dataset
58 }  // namespace mindspore
59 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RESIZE_WITH_BBOX_OP_H_
60