FastDeploy  latest
Fast & Easy to Deploy!
Macros
base_define.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define YOLO_DECLARE_CREATE_WRAPPER_FUNCTION(model_type)
 
#define YOLO_DECLARE_DESTROY_WRAPPER_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_PREDICT_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_PREDICT_FUNCTION_WITH_THRESHOLD(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_INITIALIZED_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_BATCH_PREDICT_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_CREATE_WRAPPER_FUNCTION(model_type, var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_DESTROY_WRAPPER_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION_WITH_THREASHOLD(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_INITIALIZED_FUNCTION(model_type, wrapper_var_name)
 
#define YOLO_DECLARE_AND_IMPLEMENT_BATCH_PREDICT_FUNCTION(model_type, wrapper_var_name)
 

Macro Definition Documentation

◆ YOLO_DECLARE_AND_IMPLEMENT_BATCH_PREDICT_FUNCTION

#define YOLO_DECLARE_AND_IMPLEMENT_BATCH_PREDICT_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FD_C_Bool FD_C_##model_type##WrapperBatchPredict( \
FD_C_##model_type##Wrapper* wrapper_var_name, FD_C_OneDimMat imgs, \
std::vector<cv::Mat> imgs_vec; \
std::vector<fastdeploy::vision::DetectionResult> results_out; \
std::vector<FD_C_DetectionResultWrapper*> results_wrapper_out; \
for (int i = 0; i < imgs.size; i++) { \
imgs_vec.push_back(*(reinterpret_cast<cv::Mat*>(imgs.data[i]))); \
FD_C_DetectionResultWrapper* fd_detection_result_wrapper = FD_C_CreateDetectionResultWrapper(); \
results_wrapper_out.push_back(fd_detection_result_wrapper); \
} \
auto& model = \
CHECK_AND_CONVERT_FD_TYPE(model_type##Wrapper, wrapper_var_name); \
bool successful = model->BatchPredict(imgs_vec, &results_out); \
if (successful) { \
results->size = results_out.size(); \
results->data = new FD_C_DetectionResult[results->size]; \
for (int i = 0; i < results_out.size(); i++) { \
(*CHECK_AND_CONVERT_FD_TYPE(DetectionResultWrapper, \
results_wrapper_out[i])) = std::move(results_out[i]); \
FD_C_DetectionResultWrapperToCResult(results_wrapper_out[i], &results->data[i]); \
} \
} \
for (int i = 0; i < results_out.size(); i++) { \
FD_C_DestroyDetectionResultWrapper(results_wrapper_out[i]); \
}\
return successful; \
}
size_t size
Definition: result.h:61
int8_t FD_C_Bool
Definition: fd_common.h:58
bool successful
Definition: model.cc:69
FD_C_OneDimMat FD_C_OneDimOCRResult * results
Definition: model.cc:367
Definition: result.h:51
auto & model
Definition: model.cc:64
FD_C_DetectionResult * data
Definition: result.h:62
std::vector< fastdeploy::vision::OCRResult > results_out
Definition: model.cc:370
Definition: result.h:60
FD_C_OneDimMat imgs
Definition: model.cc:82
#define CHECK_AND_CONVERT_FD_TYPE(TYPENAME, variable_name)
Definition: types_internal.h:36
Definition: fd_type.h:90
std::vector< FD_C_OCRResultWrapper * > results_wrapper_out
Definition: model.cc:369
size_t size
Definition: fd_type.h:91
FD_C_DetectionResultWrapper * FD_C_CreateDetectionResultWrapper()
Create a new FD_C_DetectionResultWrapper object.
Definition: result.cc:106
FD_C_Mat * data
Definition: fd_type.h:92

◆ YOLO_DECLARE_AND_IMPLEMENT_CREATE_WRAPPER_FUNCTION

#define YOLO_DECLARE_AND_IMPLEMENT_CREATE_WRAPPER_FUNCTION (   model_type,
  var_name 
)
Value:
FD_C_##model_type##Wrapper* FD_C_Create##model_type##Wrapper(\
const char* model_file, const char* params_file, \
FD_C_RuntimeOptionWrapper* fd_c_runtime_option_wrapper, \
const FD_C_ModelFormat model_format) { \
auto& runtime_option = CHECK_AND_CONVERT_FD_TYPE(RuntimeOptionWrapper, \
fd_c_runtime_option_wrapper); \
FD_C_##model_type##Wrapper* fd_c_##model_type##_wrapper = new FD_C_##model_type##Wrapper(); \
fd_c_##model_type##_wrapper->var_name = \
std::unique_ptr<fastdeploy::vision::detection::model_type>( \
new fastdeploy::vision::detection::model_type( \
std::string(model_file), std::string(params_file), \
*runtime_option, \
static_cast<fastdeploy::ModelFormat>(model_format))); \
return fd_c_##model_type##_wrapper; \
}
Definition: types_internal.h:26
#define CHECK_AND_CONVERT_FD_TYPE(TYPENAME, variable_name)
Definition: types_internal.h:36

◆ YOLO_DECLARE_AND_IMPLEMENT_DESTROY_WRAPPER_FUNCTION

#define YOLO_DECLARE_AND_IMPLEMENT_DESTROY_WRAPPER_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
void FD_C_Destroy##model_type##Wrapper( \
__fd_take FD_C_##model_type##Wrapper* wrapper_var_name) { \
delete wrapper_var_name; \
}
#define __fd_take
Definition: fd_common.h:46

◆ YOLO_DECLARE_AND_IMPLEMENT_INITIALIZED_FUNCTION

#define YOLO_DECLARE_AND_IMPLEMENT_INITIALIZED_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FD_C_Bool FD_C_##model_type##WrapperInitialized( \
FD_C_##model_type##Wrapper* wrapper_var_name) { \
auto& model = \
CHECK_AND_CONVERT_FD_TYPE(model_type##Wrapper, wrapper_var_name); \
return model->Initialized(); \
}
int8_t FD_C_Bool
Definition: fd_common.h:58
auto & model
Definition: model.cc:64

◆ YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION

#define YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FD_C_Bool FD_C_##model_type##WrapperPredict( \
FD_C_##model_type##Wrapper* wrapper_var_name, FD_C_Mat img, \
FD_C_DetectionResult* fd_c_detection_result) { \
cv::Mat* im = reinterpret_cast<cv::Mat*>(img); \
auto& model = \
CHECK_AND_CONVERT_FD_TYPE(model_type##Wrapper, wrapper_var_name); \
FD_C_DetectionResultWrapper* fd_c_detection_result_wrapper = \
FD_C_CreateDetectionResultWrapper(); \
auto& detection_result = CHECK_AND_CONVERT_FD_TYPE( \
DetectionResultWrapper, fd_c_detection_result_wrapper); \
bool successful = model->Predict(*im, detection_result.get()); \
if (successful) { \
FD_C_DetectionResultWrapperToCResult(fd_c_detection_result_wrapper, fd_c_detection_result); \
}\
FD_C_DestroyDetectionResultWrapper(fd_c_detection_result_wrapper); \
return successful; \
}
int8_t FD_C_Bool
Definition: fd_common.h:58
bool successful
Definition: model.cc:69
Definition: result.h:51
auto & model
Definition: model.cc:64
FD_C_Mat img
Definition: model.cc:61
#define CHECK_AND_CONVERT_FD_TYPE(TYPENAME, variable_name)
Definition: types_internal.h:36
void * FD_C_Mat
Definition: fd_type.h:88

◆ YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION_WITH_THREASHOLD

#define YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION_WITH_THREASHOLD (   model_type,
  wrapper_var_name 
)
Value:
FD_C_Bool FD_C_##model_type##WrapperPredict( \
FD_C_##model_type##Wrapper* wrapper_var_name, FD_C_Mat img, \
FD_C_DetectionResult* fd_c_detection_result, float conf_threshold, \
float nms_threshold) { \
cv::Mat* im = reinterpret_cast<cv::Mat*>(img); \
auto& model = \
CHECK_AND_CONVERT_FD_TYPE(model_type##Wrapper, wrapper_var_name); \
FD_C_DetectionResultWrapper* fd_c_detection_result_wrapper = \
FD_C_CreateDetectionResultWrapper(); \
auto& detection_result = CHECK_AND_CONVERT_FD_TYPE( \
DetectionResultWrapper, fd_c_detection_result_wrapper); \
bool successful = model->Predict(im, detection_result.get(), conf_threshold, nms_threshold); \
if (successful) { \
FD_C_DetectionResultWrapperToCResult(fd_c_detection_result_wrapper, fd_c_detection_result); \
} \
FD_C_DestroyDetectionResultWrapper(fd_c_detection_result_wrapper); \
return successful; \
}
int8_t FD_C_Bool
Definition: fd_common.h:58
bool successful
Definition: model.cc:69
Definition: result.h:51
auto & model
Definition: model.cc:64
FD_C_Mat img
Definition: model.cc:61
#define CHECK_AND_CONVERT_FD_TYPE(TYPENAME, variable_name)
Definition: types_internal.h:36
void * FD_C_Mat
Definition: fd_type.h:88

◆ YOLO_DECLARE_BATCH_PREDICT_FUNCTION

#define YOLO_DECLARE_BATCH_PREDICT_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperBatchPredict( \
__fd_keep FD_C_##model_type##Wrapper* wrapper_var_name, \
int8_t FD_C_Bool
Definition: fd_common.h:58
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
FD_C_OneDimMat FD_C_OneDimOCRResult * results
Definition: model.cc:367
Definition: result.h:60
FD_C_OneDimMat imgs
Definition: model.cc:82
Definition: fd_type.h:90
#define __fd_keep
Definition: fd_common.h:55

◆ YOLO_DECLARE_CREATE_WRAPPER_FUNCTION

#define YOLO_DECLARE_CREATE_WRAPPER_FUNCTION (   model_type)
Value:
FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_##model_type##Wrapper* \
FD_C_Create##model_type##Wrapper( \
const char* model_file, const char* params_file, \
FD_C_RuntimeOptionWrapper* fd_c_runtime_option_wrapper, \
const FD_C_ModelFormat model_format)
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
Definition: types_internal.h:26
#define __fd_give
Definition: fd_common.h:37

◆ YOLO_DECLARE_DESTROY_WRAPPER_FUNCTION

#define YOLO_DECLARE_DESTROY_WRAPPER_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FD_C_Destroy##model_type##Wrapper(__fd_take FD_C_##model_type##Wrapper* wrapper_var_name)
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
#define __fd_take
Definition: fd_common.h:46

◆ YOLO_DECLARE_INITIALIZED_FUNCTION

#define YOLO_DECLARE_INITIALIZED_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperInitialized( \
__fd_keep FD_C_##model_type##Wrapper* wrapper_var_name)
int8_t FD_C_Bool
Definition: fd_common.h:58
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
#define __fd_keep
Definition: fd_common.h:55

◆ YOLO_DECLARE_PREDICT_FUNCTION

#define YOLO_DECLARE_PREDICT_FUNCTION (   model_type,
  wrapper_var_name 
)
Value:
FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperPredict( \
__fd_take FD_C_##model_type##Wrapper* wrapper_var_name, FD_C_Mat img, \
FD_C_DetectionResult* fd_c_detection_result)
int8_t FD_C_Bool
Definition: fd_common.h:58
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
Definition: result.h:51
FD_C_Mat img
Definition: model.cc:61
#define __fd_take
Definition: fd_common.h:46
void * FD_C_Mat
Definition: fd_type.h:88

◆ YOLO_DECLARE_PREDICT_FUNCTION_WITH_THRESHOLD

#define YOLO_DECLARE_PREDICT_FUNCTION_WITH_THRESHOLD (   model_type,
  wrapper_var_name 
)
Value:
FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperPredict( \
__fd_take FD_C_##model_type##Wrapper* wrapper_var_name, FD_C_Mat img, \
FD_C_DetectionResult* fd_c_detection_result, float conf_threshold, \
float nms_threshold)
int8_t FD_C_Bool
Definition: fd_common.h:58
#define FASTDEPLOY_CAPI_EXPORT
Definition: fd_common.h:27
Definition: result.h:51
FD_C_Mat img
Definition: model.cc:61
#define __fd_take
Definition: fd_common.h:46
void * FD_C_Mat
Definition: fd_type.h:88