FastDeploy  latest
Fast & Easy to Deploy!
convert_and_permute.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 {
23 class FASTDEPLOY_DECL ConvertAndPermute : public Processor {
24  public:
25  ConvertAndPermute(const std::vector<float>& alpha = std::vector<float>(),
26  const std::vector<float>& beta = std::vector<float>(),
27  bool swap_rb = false);
28  bool ImplByOpenCV(FDMat* mat);
29 #ifdef ENABLE_FLYCV
30  bool ImplByFlyCV(FDMat* mat);
31 #endif
32  std::string Name() { return "ConvertAndPermute"; }
33 
42  static bool Run(FDMat* mat, const std::vector<float>& alpha,
43  const std::vector<float>& beta, bool swap_rb = false,
44  ProcLib lib = ProcLib::DEFAULT);
45 
46  std::vector<float> GetAlpha() const { return alpha_; }
47 
52  void SetAlpha(const std::vector<float>& alpha) {
53  alpha_.clear();
54  std::vector<float>().swap(alpha_);
55  alpha_.assign(alpha.begin(), alpha.end());
56  }
57 
58  std::vector<float> GetBeta() const { return beta_; }
59 
64  void SetBeta(const std::vector<float>& beta) {
65  beta_.clear();
66  std::vector<float>().swap(beta_);
67  beta_.assign(beta.begin(), beta.end());
68  }
69 
70  bool GetSwapRB() {
71  return swap_rb_;
72  }
73 
78  void SetSwapRB(bool swap_rb) {
79  swap_rb_ = swap_rb;
80  }
81 
82  private:
83  std::vector<float> alpha_;
84  std::vector<float> beta_;
85  bool swap_rb_;
86 };
87 } // namespace vision
88 } // namespace fastdeploy
void SetSwapRB(bool swap_rb)
Process the input images.
Definition: convert_and_permute.h:78
Processor for convert images with given paramters and permute images from HWC to CHW.
Definition: convert_and_permute.h:23
void SetBeta(const std::vector< float > &beta)
Process the input images.
Definition: convert_and_permute.h:64
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
void SetAlpha(const std::vector< float > &alpha)
Process the input images.
Definition: convert_and_permute.h:52
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16