FastDeploy  latest
Fast & Easy to Deploy!
cast.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/OpConvertTo.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 Cast : public Processor {
30  public:
31  explicit Cast(const std::string& dtype = "float") : dtype_(dtype) {}
32  bool ImplByOpenCV(Mat* mat);
33 #ifdef ENABLE_FLYCV
34  bool ImplByFlyCV(Mat* mat);
35 #endif
36 #ifdef ENABLE_CVCUDA
37  bool ImplByCvCuda(FDMat* mat);
38 #endif
39  std::string Name() { return "Cast"; }
47  static bool Run(Mat* mat, const std::string& dtype,
48  ProcLib lib = ProcLib::DEFAULT);
49 
50  std::string GetDtype() const { return dtype_; }
51 
52  private:
53  std::string dtype_;
54 #ifdef ENABLE_CVCUDA
55  cvcuda::ConvertTo cvcuda_convert_op_;
56 #endif
57 };
58 } // namespace vision
59 } // namespace fastdeploy
Processor for cast images with given type deafault is float.
Definition: cast.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
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16