FastDeploy  latest
Fast & Easy to Deploy!
base.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/utils/utils.h"
18 #include "fastdeploy/vision/common/processors/mat.h"
19 #include "fastdeploy/vision/common/processors/mat_batch.h"
20 #include "opencv2/highgui/highgui.hpp"
21 #include "opencv2/imgproc/imgproc.hpp"
22 #include <unordered_map>
23 
24 namespace fastdeploy {
25 namespace vision {
26 
31 FASTDEPLOY_DECL void EnableFlyCV();
32 
34 FASTDEPLOY_DECL void DisableFlyCV();
35 
38 FASTDEPLOY_DECL void SetProcLibCpuNumThreads(int threads);
39 
42 class FASTDEPLOY_DECL Processor {
43  public:
44  // default_lib has the highest priority
45  // all the function in `processor` will force to use
46  // default_lib if this flag is set.
47  // DEFAULT means this flag is not set
48  // static ProcLib default_lib;
49 
50  virtual std::string Name() = 0;
51 
52  virtual bool ImplByOpenCV(FDMat* mat);
53  virtual bool ImplByOpenCV(FDMatBatch* mat_batch);
54 
55  virtual bool ImplByFlyCV(FDMat* mat);
56  virtual bool ImplByFlyCV(FDMatBatch* mat_batch);
57 
58  virtual bool ImplByCuda(FDMat* mat);
59  virtual bool ImplByCuda(FDMatBatch* mat_batch);
60 
61  virtual bool ImplByCvCuda(FDMat* mat);
62  virtual bool ImplByCvCuda(FDMatBatch* mat_batch);
63 
69  virtual bool operator()(FDMat* mat);
70 
79  virtual bool operator()(FDMat* mat, ProcLib lib);
80 
86  virtual bool operator()(FDMatBatch* mat_batch);
87 };
88 
89 } // namespace vision
90 } // namespace fastdeploy
void SetProcLibCpuNumThreads(int threads)
Set the cpu num threads of ProcLib.
Definition: base.cc:169
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
FDMatBatch contains batch data for preprocess.
Definition: mat_batch.h:28
void EnableFlyCV()
Enable using FlyCV to process image while deploy vision models. Currently, FlyCV in only available on...
Definition: base.cc:151
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16
void DisableFlyCV()
Disable using FlyCV to process image while deploy vision models.
Definition: base.cc:163