FastDeploy  latest
Fast & Easy to Deploy!
limit_short.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 
19 namespace fastdeploy {
20 namespace vision {
21 
24 class LimitShort : public Processor {
25  public:
26  explicit LimitShort(int max_short = -1, int min_short = -1, int interp = 1) {
27  max_short_ = max_short;
28  min_short_ = min_short;
29  interp_ = interp;
30  }
31 
32  // Limit the short edge of image.
33  // If the short edge is larger than max_short_, resize the short edge
34  // to max_short_, while scale the long edge proportionally.
35  // If the short edge is smaller than min_short_, resize the short edge
36  // to min_short_, while scale the long edge proportionally.
37  bool ImplByOpenCV(Mat* mat);
38 #ifdef ENABLE_FLYCV
39  bool ImplByFlyCV(Mat* mat);
40 #endif
41  std::string Name() { return "LimitShort"; }
42 
52  static bool Run(Mat* mat, int max_short = -1, int min_short = -1,
53  int interp = 1, ProcLib lib = ProcLib::DEFAULT);
54  int GetMaxShort() const { return max_short_; }
55 
56  private:
57  int max_short_;
58  int min_short_;
59  int interp_;
60 };
61 } // namespace vision
62 } // namespace fastdeploy
static bool Run(Mat *mat, int max_short=-1, int min_short=-1, int interp=1, ProcLib lib=ProcLib::DEFAULT)
Process the input images.
Definition: limit_short.cc:86
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
Processor for Limit images by short edge with given paramters.
Definition: limit_short.h:24
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16