FastDeploy  latest
Fast & Easy to Deploy!
resize.h
1 // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "fastdeploy/vision/common/processors/base.h"
18 #ifdef ENABLE_CVCUDA
19 #include <cvcuda/OpResize.hpp>
20 
21 #include "fastdeploy/vision/common/processors/cvcuda_utils.h"
22 #endif
23 
24 namespace fastdeploy {
25 namespace vision {
26 
29 class FASTDEPLOY_DECL Resize : public Processor {
30  public:
31  Resize(int width, int height, float scale_w = -1.0, float scale_h = -1.0,
32  int interp = 1, bool use_scale = false) {
33  width_ = width;
34  height_ = height;
35  scale_w_ = scale_w;
36  scale_h_ = scale_h;
37  interp_ = interp;
38  use_scale_ = use_scale;
39  }
40 
41  bool ImplByOpenCV(FDMat* mat);
42 #ifdef ENABLE_FLYCV
43  bool ImplByFlyCV(FDMat* mat);
44 #endif
45 #ifdef ENABLE_CVCUDA
46  bool ImplByCvCuda(FDMat* mat);
47 #endif
48  std::string Name() { return "Resize"; }
49 
62  static bool Run(FDMat* mat, int width, int height, float scale_w = -1.0,
63  float scale_h = -1.0, int interp = 1, bool use_scale = false,
64  ProcLib lib = ProcLib::DEFAULT);
65 
71  bool SetWidthAndHeight(int width, int height) {
72  width_ = width;
73  height_ = height;
74  return true;
75  }
76 
77  std::tuple<int, int> GetWidthAndHeight() {
78  return std::make_tuple(width_, height_);
79  }
80 
81  private:
82  int width_;
83  int height_;
84  float scale_w_ = -1.0;
85  float scale_h_ = -1.0;
86  int interp_ = 1;
87  bool use_scale_ = false;
88 #ifdef ENABLE_CVCUDA
89  cvcuda::Resize cvcuda_resize_op_;
90 #endif
91 };
92 } // namespace vision
93 } // namespace fastdeploy
Processor for Resize images.
Definition: resize.h:29
FDMat is a structure for replace cv::Mat.
Definition: mat.h:34
Processor base class for processors in fastdeploy/vision/common/processors.
Definition: base.h:42
bool SetWidthAndHeight(int width, int height)
Process the input images.
Definition: resize.h:71
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16