FastDeploy  latest
Fast & Easy to Deploy!
model.h
Go to the documentation of this file.
1 // Copyright (c) 2023 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 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 // Recognizer
28 
30 
44  const char* model_file, const char* params_file, const char* label_path,
45  FD_C_RuntimeOptionWrapper* fd_c_runtime_option_wrapper,
46  const FD_C_ModelFormat model_format);
47 
53 OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(Recognizer, fd_c_recognizer_wrapper);
54 
65  __fd_keep FD_C_RecognizerWrapper* fd_c_recognizer_wrapper, FD_C_Mat img,
66  FD_C_Cstr* text, float* rec_score);
67 
75 OCR_DECLARE_INITIALIZED_FUNCTION(Recognizer, fd_c_recognizer_wrapper);
76 
88  __fd_keep FD_C_RecognizerWrapper* fd_c_recognizer_wrapper, FD_C_OneDimMat imgs,
90 
92  __fd_keep FD_C_RecognizerWrapper* fd_c_recognizer_wrapper, FD_C_OneDimMat imgs,
94  size_t start_index, size_t end_index,
95  FD_C_OneDimArrayInt32 indices);
96 
97 
98 // Classifier
99 
101 
114  const char* model_file, const char* params_file,
115  FD_C_RuntimeOptionWrapper* fd_c_runtime_option_wrapper,
116  const FD_C_ModelFormat model_format);
117 
123 OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(Classifier, fd_c_classifier_wrapper);
124 
135  __fd_keep FD_C_ClassifierWrapper* fd_c_classifier_wrapper, FD_C_Mat img,
136  int32_t* cls_label, float* cls_score);
137 
145 OCR_DECLARE_INITIALIZED_FUNCTION(Classifier, fd_c_classifier_wrapper);
146 
157  __fd_keep FD_C_ClassifierWrapper* fd_c_classifier_wrapper, FD_C_OneDimMat imgs,
159 
161  __fd_keep FD_C_ClassifierWrapper* fd_c_classifier_wrapper, FD_C_OneDimMat imgs,
163  size_t start_index, size_t end_index);
164 
165 
166 // DBDetector
167 
169 
182  const char* model_file, const char* params_file,
183  FD_C_RuntimeOptionWrapper* fd_c_runtime_option_wrapper,
184  const FD_C_ModelFormat model_format);
185 
191 OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(DBDetector, fd_c_dbdetector_wrapper);
192 
202  __fd_keep FD_C_DBDetectorWrapper* fd_c_dbdetector_wrapper, FD_C_Mat img,
204 
212 OCR_DECLARE_INITIALIZED_FUNCTION(DBDetector, fd_c_dbdetector_wrapper);
213 
224  __fd_keep FD_C_DBDetectorWrapper* fd_c_dbdetector_wrapper, FD_C_OneDimMat imgs,
226 
227 
228 // PPOCRv2
229 
230 
232 
242  FD_C_DBDetectorWrapper* det_model,
243  FD_C_ClassifierWrapper* cls_model,
244  FD_C_RecognizerWrapper* rec_model);
245 
251 OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(PPOCRv2, fd_c_ppocrv2_wrapper);
252 
262  __fd_keep FD_C_PPOCRv2Wrapper* fd_c_ppocrv2_wrapper, FD_C_Mat img,
263  FD_C_OCRResult* result);
264 
272 OCR_DECLARE_INITIALIZED_FUNCTION(PPOCRv2, fd_c_ppocrv2_wrapper);
273 
283  __fd_keep FD_C_PPOCRv2Wrapper* fd_c_ppocrv2_wrapper, FD_C_OneDimMat imgs,
284  FD_C_OneDimOCRResult* batch_result);
285 
286 
287 
288 // PPOCRv3
289 
291 
301  FD_C_DBDetectorWrapper* det_model,
302  FD_C_ClassifierWrapper* cls_model,
303  FD_C_RecognizerWrapper* rec_model);
304 
310 OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(PPOCRv3, fd_c_ppocrv3_wrapper);
311 
321  __fd_keep FD_C_PPOCRv3Wrapper* fd_c_ppocrv3_wrapper, FD_C_Mat img,
322  FD_C_OCRResult* result);
323 
331 OCR_DECLARE_INITIALIZED_FUNCTION(PPOCRv3, fd_c_ppocrv3_wrapper);
332 
342  __fd_keep FD_C_PPOCRv3Wrapper* fd_c_ppocrv3_wrapper, FD_C_OneDimMat imgs,
343  FD_C_OneDimOCRResult* batch_result);
344 
345 
346 #ifdef __cplusplus
347 } // extern "C"
348 #endif
struct FD_C_DBDetectorWrapper FD_C_DBDetectorWrapper
Definition: model.h:168
FD_C_Mat FD_C_TwoDimArrayInt32 * boxes_result
Definition: model.cc:262
FASTDEPLOY_CAPI_EXPORT __fd_give FD_C_DBDetectorWrapper * FD_C_CreateDBDetectorWrapper(const char *model_file, const char *params_file, FD_C_RuntimeOptionWrapper *fd_c_runtime_option_wrapper, const FD_C_ModelFormat model_format)
Create a new FD_C_DBDetectorWrapper object.
Definition: model.cc:240
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_RecognizerWrapperPredict(__fd_keep FD_C_RecognizerWrapper *fd_c_recognizer_wrapper, FD_C_Mat img, FD_C_Cstr *text, float *rec_score)
Predict the ocr result for an input image.
struct FD_C_ClassifierWrapper FD_C_ClassifierWrapper
Definition: model.h:100
int8_t FD_C_Bool
Definition: fd_common.h:58
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_RecognizerWrapperBatchPredictWithIndex(__fd_keep FD_C_RecognizerWrapper *fd_c_recognizer_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimArrayCstr *texts, FD_C_OneDimArrayFloat *rec_scores, size_t start_index, size_t end_index, FD_C_OneDimArrayInt32 indices)
FD_C_OneDimMat FD_C_OneDimArrayCstr * texts
Definition: model.cc:82
FD_C_Mat FD_C_Cstr * text
Definition: model.cc:61
FD_C_OneDimMat FD_C_OneDimArrayInt32 * cls_labels
Definition: model.cc:183
FD_C_Mat FD_C_Cstr float * rec_score
Definition: model.cc:62
FASTDEPLOY_CAPI_EXPORT __fd_give FD_C_RecognizerWrapper * FD_C_CreateRecognizerWrapper(const char *model_file, const char *params_file, const char *label_path, FD_C_RuntimeOptionWrapper *fd_c_runtime_option_wrapper, const FD_C_ModelFormat model_format)
Create a new FD_C_RecognizerWrapper object.
Definition: model.cc:40
Definition: result.h:66
FASTDEPLOY_CAPI_EXPORT __fd_give FD_C_PPOCRv3Wrapper * FD_C_CreatePPOCRv3Wrapper(FD_C_DBDetectorWrapper *det_model, FD_C_ClassifierWrapper *cls_model, FD_C_RecognizerWrapper *rec_model)
Set up the detection model path, classification model path and recognition model path respectively...
Definition: model.cc:397
struct FD_C_PPOCRv3Wrapper FD_C_PPOCRv3Wrapper
Definition: model.h:290
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_RecognizerWrapperBatchPredict(__fd_keep FD_C_RecognizerWrapper *fd_c_recognizer_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimArrayCstr *texts, FD_C_OneDimArrayFloat *rec_scores)
Predict the ocr results for a batch of input images.
FD_C_OneDimMat FD_C_OneDimArrayCstr FD_C_OneDimArrayFloat * rec_scores
Definition: model.cc:83
FASTDEPLOY_CAPI_EXPORT __fd_give FD_C_ClassifierWrapper * FD_C_CreateClassifierWrapper(const char *model_file, const char *params_file, FD_C_RuntimeOptionWrapper *fd_c_runtime_option_wrapper, const FD_C_ModelFormat model_format)
Create a new FD_C_ClassifierWrapper object.
Definition: model.cc:149
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_ClassifierWrapperPredict(__fd_keep FD_C_ClassifierWrapper *fd_c_classifier_wrapper, FD_C_Mat img, int32_t *cls_label, float *cls_score)
Predict the input image and get OCR classification model cls_result.
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_PPOCRv2WrapperPredict(__fd_keep FD_C_PPOCRv2Wrapper *fd_c_ppocrv2_wrapper, FD_C_Mat img, FD_C_OCRResult *result)
Predict the input image and get OCR result.
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_PPOCRv2WrapperBatchPredict(__fd_keep FD_C_PPOCRv2Wrapper *fd_c_ppocrv2_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimOCRResult *batch_result)
BatchPredict the input image and get OCR result.
Definition: result.h:75
Definition: fd_type.h:48
FD_C_OneDimMat FD_C_OneDimArrayInt32 FD_C_OneDimArrayFloat * cls_scores
Definition: model.cc:184
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_PPOCRv3WrapperPredict(__fd_keep FD_C_PPOCRv3Wrapper *fd_c_ppocrv3_wrapper, FD_C_Mat img, FD_C_OCRResult *result)
Predict the input image and get OCR result.
Definition: types_internal.h:26
FD_C_Mat int32_t * cls_label
Definition: model.cc:170
FD_C_OneDimMat imgs
Definition: model.cc:82
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_ClassifierWrapperBatchPredict(__fd_keep FD_C_ClassifierWrapper *fd_c_classifier_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimArrayInt32 *cls_labels, FD_C_OneDimArrayFloat *cls_scores)
BatchPredict the input image and get OCR classification model cls_result.
FD_C_Mat img
Definition: model.cc:61
FD_C_OneDimMat FD_C_ThreeDimArrayInt32 * det_results
Definition: model.cc:289
struct FD_C_RecognizerWrapper FD_C_RecognizerWrapper
Definition: model.h:29
Definition: fd_type.h:53
struct FD_C_PPOCRv2Wrapper FD_C_PPOCRv2Wrapper
Definition: model.h:231
Definition: fd_type.h:90
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_ClassifierWrapperBatchPredictWithIndex(__fd_keep FD_C_ClassifierWrapper *fd_c_classifier_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimArrayInt32 *cls_labels, FD_C_OneDimArrayFloat *cls_scores, size_t start_index, size_t end_index)
Definition: fd_type.h:78
#define OCR_DECLARE_INITIALIZED_FUNCTION(model_type, wrapper_var_name)
Definition: base_define.h:20
FD_C_Mat int32_t float * cls_score
Definition: model.cc:171
#define __fd_keep
Definition: fd_common.h:55
FASTDEPLOY_CAPI_EXPORT __fd_give FD_C_PPOCRv2Wrapper * FD_C_CreatePPOCRv2Wrapper(FD_C_DBDetectorWrapper *det_model, FD_C_ClassifierWrapper *cls_model, FD_C_RecognizerWrapper *rec_model)
Set up the detection model path, classification model path and recognition model path respectively...
Definition: model.cc:323
#define OCR_DECLARE_DESTROY_WRAPPER_FUNCTION(model_type, wrapper_var_name)
Definition: base_define.h:17
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_DBDetectorWrapperPredict(__fd_keep FD_C_DBDetectorWrapper *fd_c_dbdetector_wrapper, FD_C_Mat img, FD_C_TwoDimArrayInt32 *boxes_result)
Predict the input image and get OCR detection model result.
#define __fd_give
Definition: fd_common.h:37
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_DBDetectorWrapperBatchPredict(__fd_keep FD_C_DBDetectorWrapper *fd_c_dbdetector_wrapper, FD_C_OneDimMat imgs, FD_C_ThreeDimArrayInt32 *det_results)
BatchPredict the input image and get OCR detection model result.
Definition: fd_type.h:73
void * FD_C_Mat
Definition: fd_type.h:88
FASTDEPLOY_CAPI_EXPORT FD_C_Bool FD_C_PPOCRv3WrapperBatchPredict(__fd_keep FD_C_PPOCRv3Wrapper *fd_c_ppocrv3_wrapper, FD_C_OneDimMat imgs, FD_C_OneDimOCRResult *batch_result)
BatchPredict the input image and get OCR result.
Definition: fd_type.h:58
Definition: fd_type.h:33