FastDeploy  latest
Fast & Easy to Deploy!
pad.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/OpCopyMakeBorder.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 Pad : public Processor {
30  public:
31  Pad(int top, int bottom, int left, int right,
32  const std::vector<float>& value) {
33  top_ = top;
34  bottom_ = bottom;
35  left_ = left;
36  right_ = right;
37  value_ = value;
38  }
39  bool ImplByOpenCV(Mat* mat);
40 #ifdef ENABLE_FLYCV
41  bool ImplByFlyCV(Mat* mat);
42 #endif
43 #ifdef ENABLE_CVCUDA
44  bool ImplByCvCuda(FDMat* mat);
45 #endif
46  std::string Name() { return "Pad"; }
47 
59  static bool Run(Mat* mat, const int& top, const int& bottom, const int& left,
60  const int& right, const std::vector<float>& value,
61  ProcLib lib = ProcLib::DEFAULT);
62 
70  bool SetPaddingSize(int top, int bottom, int left, int right) {
71  top_ = top;
72  bottom_ = bottom;
73  left_ = left;
74  right_ = right;
75  return true;
76  }
77 
78  private:
79  int top_;
80  int bottom_;
81  int left_;
82  int right_;
83  std::vector<float> value_;
84 #ifdef ENABLE_CVCUDA
85  cvcuda::CopyMakeBorder cvcuda_pad_op_;
86 #endif
87 };
88 } // namespace vision
89 } // namespace fastdeploy
Processor for padding images.
Definition: pad.h:29
bool SetPaddingSize(int top, int bottom, int left, int right)
Process the input images.
Definition: pad.h:70
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
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16