diff --git a/c_api/fastdeploy_capi/core/config.h b/c_api/fastdeploy_capi/core/config.h index 73de04c446..73ad1145a0 100755 --- a/c_api/fastdeploy_capi/core/config.h +++ b/c_api/fastdeploy_capi/core/config.h @@ -18,5 +18,5 @@ #endif #ifndef ENABLE_TEXT -/* #undef ENABLE_TEXT */ +#define ENABLE_TEXT #endif diff --git a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/base_define.h b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/base_define.h index 92b44bc749..0dca3cccd2 100644 --- a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/base_define.h +++ b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/base_define.h @@ -34,10 +34,17 @@ FD_C_Destroy##model_type##Wrapper(__fd_take FD_C_##model_type##Wrapper* wrapper_ FD_C_DetectionResult* fd_c_detection_result, float conf_threshold, \ float nms_threshold) +#define YOLO_DECLARE_SETPRESIZE_FUNCTION(model_type, wrapper_var_name) \ + FASTDEPLOY_CAPI_EXPORT extern void FD_C_##model_type##WrapperSetPreSize( \ + __fd_take FD_C_##model_type##Wrapper* wrapper_var_name, \ + int iWidth, int iHeight) + #define YOLO_DECLARE_INITIALIZED_FUNCTION(model_type, wrapper_var_name) FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperInitialized( \ __fd_keep FD_C_##model_type##Wrapper* wrapper_var_name) - +#define YOLO_DECLARE_SET_PRESIZE_FUNCTION(model_type, wrapper_var_name) FASTDEPLOY_CAPI_EXPORT extern void FD_C_##model_type##WrapperSetPreSize( \ + __fd_keep FD_C_##model_type##Wrapper* wrapper_var_name, \ + int iWidth, int iHeight) #define YOLO_DECLARE_BATCH_PREDICT_FUNCTION(model_type, wrapper_var_name) FASTDEPLOY_CAPI_EXPORT extern FD_C_Bool FD_C_##model_type##WrapperBatchPredict( \ __fd_keep FD_C_##model_type##Wrapper* wrapper_var_name, \ FD_C_OneDimMat imgs, \ @@ -137,3 +144,12 @@ FD_C_Destroy##model_type##Wrapper(__fd_take FD_C_##model_type##Wrapper* wrapper_ }\ return successful; \ } + +#define YOLO_DECLARE_AND_IMPLEMENT_SETPRESIZE_FUNCTION(model_type, wrapper_var_name) void FD_C_##model_type##WrapperSetPreSize( \ + FD_C_##model_type##Wrapper* wrapper_var_name, int iWidth, int iHeight) { \ + if (iWidth > 0 && iHeight > 0) { \ + auto& model = \ + CHECK_AND_CONVERT_FD_TYPE(model_type##Wrapper, wrapper_var_name); \ + model->SetPreSize(iWidth, iHeight); \ + } \ + } diff --git a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.cc b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.cc index 92122b3889..e4970b0308 100644 --- a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.cc +++ b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.cc @@ -27,7 +27,7 @@ YOLO_DECLARE_AND_IMPLEMENT_DESTROY_WRAPPER_FUNCTION(YOLOv5, fd_yolov5_wrapper) YOLO_DECLARE_AND_IMPLEMENT_PREDICT_FUNCTION(YOLOv5, fd_yolov5_wrapper) YOLO_DECLARE_AND_IMPLEMENT_INITIALIZED_FUNCTION(YOLOv5, fd_yolov5_wrapper) YOLO_DECLARE_AND_IMPLEMENT_BATCH_PREDICT_FUNCTION(YOLOv5, fd_yolov5_wrapper) - +YOLO_DECLARE_AND_IMPLEMENT_SETPRESIZE_FUNCTION(YOLOv5, fd_yolov5_wrapper) // YOLOv7 YOLO_DECLARE_AND_IMPLEMENT_CREATE_WRAPPER_FUNCTION(YOLOv7, yolov7_model) YOLO_DECLARE_AND_IMPLEMENT_DESTROY_WRAPPER_FUNCTION(YOLOv7, fd_yolov7_wrapper) @@ -65,4 +65,4 @@ YOLO_DECLARE_AND_IMPLEMENT_INITIALIZED_FUNCTION(YOLOX, fd_yolox_wrapper) #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.h b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.h index 942a8cf1e9..16f306bc7b 100644 --- a/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.h +++ b/c_api/fastdeploy_capi/vision/detection/contrib/yolo/model.h @@ -67,6 +67,7 @@ YOLO_DECLARE_PREDICT_FUNCTION(YOLOv5, fd_c_yolov5_wrapper); YOLO_DECLARE_INITIALIZED_FUNCTION(YOLOv5, fd_c_yolov5_wrapper); +YOLO_DECLARE_SETPRESIZE_FUNCTION(YOLOv5, fd_c_yolov5_wrapper); /** \brief Predict the detection results for a batch of input images * * \param[in] fd_c_yolov5_wrapper pointer to FD_C_YOLOv5Wrapper object diff --git a/fastdeploy/vision/detection/contrib/yolov5/yolov5.h b/fastdeploy/vision/detection/contrib/yolov5/yolov5.h index 53bcfce755..74fc8a6421 100755 --- a/fastdeploy/vision/detection/contrib/yolov5/yolov5.h +++ b/fastdeploy/vision/detection/contrib/yolov5/yolov5.h @@ -38,6 +38,10 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel { std::string ModelName() const { return "yolov5"; } + void SetPreSize(int iWidth, int iHeight){ + std::vector vecPreSize = {iWidth, iHeight}; + preprocessor_.SetSize(vecPreSize); + } /** \brief DEPRECATED Predict the detection result for an input image, remove at 1.0 version * * \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format