mirror of
				https://github.com/PaddlePaddle/FastDeploy.git
				synced 2025-10-31 11:56:44 +08:00 
			
		
		
		
	[C API] Add create api for c results (#1547)
add create api for c results
This commit is contained in:
		| @@ -37,6 +37,11 @@ void FD_C_DestroyClassifyResultWrapper( | ||||
|   delete fd_c_classify_result_wrapper; | ||||
| } | ||||
|  | ||||
| FD_C_ClassifyResult* FD_C_CreateClassifyResult() { | ||||
|   FD_C_ClassifyResult* fd_c_classify_result = new FD_C_ClassifyResult(); | ||||
|   return fd_c_classify_result; | ||||
| } | ||||
|  | ||||
| void FD_C_DestroyClassifyResult( | ||||
|     __fd_take FD_C_ClassifyResult* fd_c_classify_result) { | ||||
|   if (fd_c_classify_result == nullptr) return; | ||||
| @@ -44,6 +49,7 @@ void FD_C_DestroyClassifyResult( | ||||
|   delete[] fd_c_classify_result->label_ids.data; | ||||
|   // delete scores | ||||
|   delete[] fd_c_classify_result->scores.data; | ||||
|   delete fd_c_classify_result; | ||||
| } | ||||
|  | ||||
| void FD_C_ClassifyResultWrapperToCResult( | ||||
| @@ -117,6 +123,11 @@ void FD_C_DestroyDetectionResultWrapper( | ||||
|   delete fd_c_detection_result_wrapper; | ||||
| } | ||||
|  | ||||
| FD_C_DetectionResult* FD_C_CreateDetectionResult() { | ||||
|   FD_C_DetectionResult* fd_c_detection_result = new FD_C_DetectionResult(); | ||||
|   return fd_c_detection_result; | ||||
| } | ||||
|  | ||||
| void FD_C_DestroyDetectionResult( | ||||
|     __fd_take FD_C_DetectionResult* fd_c_detection_result) { | ||||
|   if (fd_c_detection_result == nullptr) return; | ||||
| @@ -134,6 +145,7 @@ void FD_C_DestroyDetectionResult( | ||||
|     delete[] fd_c_detection_result->masks.data[i].data.data; | ||||
|     delete[] fd_c_detection_result->masks.data[i].shape.data; | ||||
|   } | ||||
|   delete fd_c_detection_result; | ||||
| } | ||||
|  | ||||
| void FD_C_DetectionResultWrapperToCResult( | ||||
| @@ -275,6 +287,11 @@ void FD_C_DestroyOCRResultWrapper( | ||||
|   delete fd_c_ocr_result_wrapper; | ||||
| } | ||||
|  | ||||
| FD_C_OCRResult* FD_C_CreateOCRResult() { | ||||
|   FD_C_OCRResult* fd_c_ocr_result = new FD_C_OCRResult(); | ||||
|   return fd_c_ocr_result; | ||||
| } | ||||
|  | ||||
| void FD_C_DestroyOCRResult(__fd_take FD_C_OCRResult* fd_c_ocr_result) { | ||||
|   if (fd_c_ocr_result == nullptr) return; | ||||
|   // delete boxes | ||||
| @@ -293,6 +310,7 @@ void FD_C_DestroyOCRResult(__fd_take FD_C_OCRResult* fd_c_ocr_result) { | ||||
|   delete[] fd_c_ocr_result->cls_scores.data; | ||||
|   // delete cls_labels | ||||
|   delete[] fd_c_ocr_result->cls_labels.data; | ||||
|   delete fd_c_ocr_result; | ||||
| } | ||||
|  | ||||
| void FD_C_OCRResultWrapperToCResult( | ||||
| @@ -418,6 +436,12 @@ void FD_C_DestroySegmentationResultWrapper( | ||||
|   delete fd_c_segmentation_result_wrapper; | ||||
| } | ||||
|  | ||||
| FD_C_SegmentationResult* FD_C_CreateSegmentationResult() { | ||||
|   FD_C_SegmentationResult* fd_c_segmentation_result = | ||||
|       new FD_C_SegmentationResult(); | ||||
|   return fd_c_segmentation_result; | ||||
| } | ||||
|  | ||||
| void FD_C_DestroySegmentationResult( | ||||
|     __fd_take FD_C_SegmentationResult* fd_c_segmentation_result) { | ||||
|   if (fd_c_segmentation_result == nullptr) return; | ||||
| @@ -427,6 +451,7 @@ void FD_C_DestroySegmentationResult( | ||||
|   delete[] fd_c_segmentation_result->score_map.data; | ||||
|   // delete shape | ||||
|   delete[] fd_c_segmentation_result->shape.data; | ||||
|   delete fd_c_segmentation_result; | ||||
| } | ||||
|  | ||||
| void FD_C_SegmentationResultWrapperToCResult( | ||||
|   | ||||
| @@ -109,6 +109,13 @@ FD_C_CreateClassifyResultWrapper(); | ||||
| FASTDEPLOY_CAPI_EXPORT extern void FD_C_DestroyClassifyResultWrapper( | ||||
|     __fd_take FD_C_ClassifyResultWrapper* fd_c_classify_result_wrapper); | ||||
|  | ||||
| /** \brief Create a new FD_C_ClassifyResult object | ||||
|  * | ||||
|  * \return Return a pointer to FD_C_ClassifyResult object | ||||
|  */ | ||||
| FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_ClassifyResult* | ||||
| FD_C_CreateClassifyResult(); | ||||
|  | ||||
| /** \brief Destroy a FD_C_ClassifyResult object | ||||
|  * | ||||
|  * \param[in] fd_c_classify_result pointer to FD_C_ClassifyResult object | ||||
| @@ -159,6 +166,7 @@ FD_C_ClassifyResultStr( | ||||
| FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_DetectionResultWrapper* | ||||
| FD_C_CreateDetectionResultWrapper(); | ||||
|  | ||||
|  | ||||
| /** \brief Destroy a FD_C_DetectionResultWrapper object | ||||
|  * | ||||
|  * \param[in] fd_c_detection_result_wrapper pointer to FD_C_DetectionResultWrapper object | ||||
| @@ -167,6 +175,14 @@ FD_C_CreateDetectionResultWrapper(); | ||||
| FASTDEPLOY_CAPI_EXPORT extern void FD_C_DestroyDetectionResultWrapper( | ||||
|     __fd_take FD_C_DetectionResultWrapper* fd_c_detection_result_wrapper); | ||||
|  | ||||
|  | ||||
| /** \brief Create a new FD_C_DetectionResult object | ||||
|  * | ||||
|  * \return Return a pointer to FD_C_DetectionResult object | ||||
|  */ | ||||
| FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_DetectionResult* | ||||
| FD_C_CreateDetectionResult(); | ||||
|  | ||||
| /** \brief Destroy a FD_C_DetectionResult object | ||||
|  * | ||||
|  * \param[in] fd_c_detection_result pointer to FD_C_DetectionResult object | ||||
| @@ -225,6 +241,14 @@ FD_C_CreateOCRResultWrapper(); | ||||
| FASTDEPLOY_CAPI_EXPORT extern void FD_C_DestroyOCRResultWrapper( | ||||
|     __fd_take FD_C_OCRResultWrapper* fd_c_ocr_result_wrapper); | ||||
|  | ||||
|  | ||||
| /** \brief Create a new FD_C_OCRResult object | ||||
|  * | ||||
|  * \return Return a pointer to FD_C_OCRResult object | ||||
|  */ | ||||
| FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_OCRResult* | ||||
| FD_C_CreateOCRResult(); | ||||
|  | ||||
| /** \brief Destroy a FD_C_OCRResult object | ||||
|  * | ||||
|  * \param[in] fd_c_ocr_result pointer to FD_C_OCRResult object | ||||
| @@ -282,6 +306,13 @@ FD_C_CreateSegmentationResultWrapper(); | ||||
| FASTDEPLOY_CAPI_EXPORT extern void FD_C_DestroySegmentationResultWrapper( | ||||
|     __fd_take FD_C_SegmentationResultWrapper* fd_c_segmentation_result_wrapper); | ||||
|  | ||||
| /** \brief Create a new FD_C_SegmentationResult object | ||||
|  * | ||||
|  * \return Return a pointer to FD_C_SegmentationResult object | ||||
|  */ | ||||
| FASTDEPLOY_CAPI_EXPORT extern __fd_give FD_C_SegmentationResult* | ||||
| FD_C_CreateSegmentationResult(); | ||||
|  | ||||
| /** \brief Destroy a FD_C_SegmentationResult object | ||||
|  * | ||||
|  * \param[in] fd_c_segmentation_result pointer to FD_C_SegmentationResult object | ||||
|   | ||||
| @@ -49,8 +49,7 @@ void CpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_ClassifyResult* result = | ||||
|       (FD_C_ClassifyResult*)malloc(sizeof(FD_C_ClassifyResult)); | ||||
|   FD_C_ClassifyResult* result = FD_C_CreateClassifyResult(); | ||||
|  | ||||
|   if (!FD_C_PaddleClasModelWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -97,8 +96,7 @@ void GpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_ClassifyResult* result = | ||||
|       (FD_C_ClassifyResult*)malloc(sizeof(FD_C_ClassifyResult)); | ||||
|   FD_C_ClassifyResult* result = FD_C_CreateClassifyResult(); | ||||
|  | ||||
|   if (!FD_C_PaddleClasModelWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
| @@ -47,8 +47,7 @@ void CpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_DetectionResult* result = | ||||
|       (FD_C_DetectionResult*)malloc(sizeof(FD_C_DetectionResult)); | ||||
|   FD_C_DetectionResult* result = FD_C_CreateDetectionResult(); | ||||
|  | ||||
|   if (!FD_C_PPYOLOEWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -95,8 +94,7 @@ void GpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_DetectionResult* result = | ||||
|       (FD_C_DetectionResult*)malloc(sizeof(FD_C_DetectionResult)); | ||||
|   FD_C_DetectionResult* result = FD_C_CreateDetectionResult(); | ||||
|  | ||||
|   if (!FD_C_PPYOLOEWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
| @@ -39,8 +39,7 @@ void CpuInfer(const char* model_file, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_DetectionResult* result = | ||||
|       (FD_C_DetectionResult*)malloc(sizeof(FD_C_DetectionResult)); | ||||
|   FD_C_DetectionResult* result = FD_C_CreateDetectionResult(); | ||||
|  | ||||
|   if (!FD_C_YOLOv5WrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -79,8 +78,7 @@ void GpuInfer(const char* model_file, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_DetectionResult* result = | ||||
|       (FD_C_DetectionResult*)malloc(sizeof(FD_C_DetectionResult)); | ||||
|   FD_C_DetectionResult* result = FD_C_CreateDetectionResult(); | ||||
|  | ||||
|   if (!FD_C_YOLOv5WrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
| @@ -96,7 +96,7 @@ void CpuInfer(const char* det_model_dir, const char* cls_model_dir, | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_OCRResult* result = (FD_C_OCRResult*)malloc(sizeof(FD_C_OCRResult)); | ||||
|   FD_C_OCRResult* result = FD_C_CreateOCRResult(); | ||||
|  | ||||
|   if (!FD_C_PPOCRv2WrapperPredict(ppocr_v2, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -191,7 +191,7 @@ void GpuInfer(const char* det_model_dir, const char* cls_model_dir, | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_OCRResult* result = (FD_C_OCRResult*)malloc(sizeof(FD_C_OCRResult)); | ||||
|   FD_C_OCRResult* result = FD_C_CreateOCRResult(); | ||||
|  | ||||
|   if (!FD_C_PPOCRv2WrapperPredict(ppocr_v2, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
| @@ -96,7 +96,7 @@ void CpuInfer(const char* det_model_dir, const char* cls_model_dir, | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_OCRResult* result = (FD_C_OCRResult*)malloc(sizeof(FD_C_OCRResult)); | ||||
|   FD_C_OCRResult* result = FD_C_CreateOCRResult(); | ||||
|  | ||||
|   if (!FD_C_PPOCRv3WrapperPredict(ppocr_v3, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -191,7 +191,7 @@ void GpuInfer(const char* det_model_dir, const char* cls_model_dir, | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_OCRResult* result = (FD_C_OCRResult*)malloc(sizeof(FD_C_OCRResult)); | ||||
|   FD_C_OCRResult* result = FD_C_CreateOCRResult(); | ||||
|  | ||||
|   if (!FD_C_PPOCRv3WrapperPredict(ppocr_v3, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
| @@ -47,8 +47,7 @@ void CpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_SegmentationResult* result = | ||||
|       (FD_C_SegmentationResult*)malloc(sizeof(FD_C_SegmentationResult)); | ||||
|   FD_C_SegmentationResult* result = FD_C_CreateSegmentationResult(); | ||||
|  | ||||
|   if (!FD_C_PaddleSegModelWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
| @@ -99,8 +98,7 @@ void GpuInfer(const char* model_dir, const char* image_file) { | ||||
|  | ||||
|   FD_C_Mat im = FD_C_Imread(image_file); | ||||
|  | ||||
|   FD_C_SegmentationResult* result = | ||||
|       (FD_C_SegmentationResult*)malloc(sizeof(FD_C_SegmentationResult)); | ||||
|   FD_C_SegmentationResult* result = FD_C_CreateSegmentationResult(); | ||||
|  | ||||
|   if (!FD_C_PaddleSegModelWrapperPredict(model, im, result)) { | ||||
|     printf("Failed to predict.\n"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 chenjian
					chenjian