FastDeploy  latest
Fast & Easy to Deploy!
convert.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 Convert : public Processor {
24  public:
25  Convert(const std::vector<float>& alpha, const std::vector<float>& beta);
26 
27  bool ImplByOpenCV(Mat* mat);
28 #ifdef ENABLE_FLYCV
29  bool ImplByFlyCV(Mat* mat);
30 #endif
31  std::string Name() { return "Convert"; }
32 
33  // Compute `result = mat * alpha + beta` directly by channel.
34  // The default behavior is the same as OpenCV's convertTo method.
43  static bool Run(Mat* mat, const std::vector<float>& alpha,
44  const std::vector<float>& beta,
45  ProcLib lib = ProcLib::DEFAULT);
46 
47  private:
48  std::vector<float> alpha_;
49  std::vector<float> beta_;
50 };
51 } // namespace vision
52 } // namespace fastdeploy
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 convert images with given paramters.
Definition: convert.h:23
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16