From 9ac88d08a4aead008778488d5bfb31228d5f3a43 Mon Sep 17 00:00:00 2001 From: dhz Date: Wed, 26 Apr 2023 09:54:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=86=85=E5=AD=98?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=9E=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- csrc/mmdeploy/apis/c/mmdeploy/classifier.cpp | 12 ++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/classifier.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/detector.cpp | 12 ++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/detector.h | 13 +++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/pose_detector.cpp | 11 +++++++++++ csrc/mmdeploy/apis/c/mmdeploy/pose_detector.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/restorer.cpp | 11 +++++++++++ csrc/mmdeploy/apis/c/mmdeploy/restorer.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.cpp | 12 ++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.h | 13 +++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/segmentor.cpp | 11 +++++++++++ csrc/mmdeploy/apis/c/mmdeploy/segmentor.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/text_detector.cpp | 11 +++++++++++ csrc/mmdeploy/apis/c/mmdeploy/text_detector.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.cpp | 11 +++++++++++ csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.cpp | 14 ++++++++++++++ csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.h | 14 ++++++++++++++ 19 files changed, 230 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02f7a7579b..33247522d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ option(MMDEPLOY_BUILD_SDK_CSHARP_API "build SDK C# API support" OFF) option(MMDEPLOY_BUILD_SDK_JAVA_API "build SDK JAVA API" OFF) option(MMDEPLOY_BUILD_EXAMPLES "build examples" OFF) option(MMDEPLOY_SPDLOG_EXTERNAL "use external spdlog" OFF) -option(MMDEPLOY_ZIP_MODEL "support SDK model in zip format" OFF) +option(MMDEPLOY_ZIP_MODEL "support SDK model in zip format" ON) option(MMDEPLOY_COVERAGE "build SDK for coverage" OFF) option(MMDEPLOY_ELENA_FUSION "use elena to fuse preprocess" OFF) diff --git a/csrc/mmdeploy/apis/c/mmdeploy/classifier.cpp b/csrc/mmdeploy/apis/c/mmdeploy/classifier.cpp index 3eec4ef90b..379a0cdf20 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/classifier.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/classifier.cpp @@ -40,6 +40,18 @@ int mmdeploy_classifier_create_by_path(const char* model_path, const char* devic return ec; } +int mmdeploy_classifier_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_classifier_t* classifier) { + mmdeploy_model_t model{}; + + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_classifier_create(model, device_name, device_id, classifier); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_classifier_create_v2(mmdeploy_model_t model, mmdeploy_context_t context, mmdeploy_classifier_t* classifier) { return mmdeploy_pipeline_create_from_model(model, context, (mmdeploy_pipeline_t*)classifier); diff --git a/csrc/mmdeploy/apis/c/mmdeploy/classifier.h b/csrc/mmdeploy/apis/c/mmdeploy/classifier.h index 54e9d0215b..9c8510f472 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/classifier.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/classifier.h @@ -49,6 +49,20 @@ MMDEPLOY_API int mmdeploy_classifier_create_by_path(const char* model_path, cons int device_id, mmdeploy_classifier_t* classifier); +/** + * @brief Create classifier's handle + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] classifier instance of a classifier, which must be destroyed + * by \ref mmdeploy_classifier_destroy + * @return status of creating classifier's handle + */ +MMDEPLOY_API int mmdeploy_classifier_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, + mmdeploy_classifier_t* classifier); + /** * @brief Use classifier created by \ref mmdeploy_classifier_create_by_path to get label * information of each image in a batch diff --git a/csrc/mmdeploy/apis/c/mmdeploy/detector.cpp b/csrc/mmdeploy/apis/c/mmdeploy/detector.cpp index aadf92fb62..d53a9162d6 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/detector.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/detector.cpp @@ -53,6 +53,18 @@ int mmdeploy_detector_create_by_path(const char* model_path, const char* device_ return ec; } +int mmdeploy_detector_create_by_buffer(const void* buffer, int size, const char* device_name, int device_id, + mmdeploy_detector_t* detector) { + mmdeploy_model_t model{}; + + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_detector_create(model, device_name, device_id, detector); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_detector_create_input(const mmdeploy_mat_t* mats, int mat_count, mmdeploy_value_t* input) { return mmdeploy_common_create_input(mats, mat_count, input); diff --git a/csrc/mmdeploy/apis/c/mmdeploy/detector.h b/csrc/mmdeploy/apis/c/mmdeploy/detector.h index 5c5ba2f356..26b90753da 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/detector.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/detector.h @@ -54,6 +54,19 @@ MMDEPLOY_API int mmdeploy_detector_create(mmdeploy_model_t model, const char* de MMDEPLOY_API int mmdeploy_detector_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_detector_t* detector); +/** + * @brief Create detector's handle + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] detector instance of a detector + * @return status of creating detector's handle + */ +MMDEPLOY_API int mmdeploy_detector_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_detector_t* detector); + + /** * @brief Apply detector to batch images and get their inference results * @param[in] detector detector's handle created by \ref mmdeploy_detector_create_by_path diff --git a/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.cpp b/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.cpp index 46f9921e62..b1f14d7cbf 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.cpp @@ -39,6 +39,17 @@ int mmdeploy_pose_detector_create_by_path(const char* model_path, const char* de return ec; } +int mmdeploy_pose_detector_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_pose_detector_t* detector) { + mmdeploy_model_t model{}; + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_pose_detector_create(model, device_name, device_id, detector); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_pose_detector_apply(mmdeploy_pose_detector_t detector, const mmdeploy_mat_t* mats, int mat_count, mmdeploy_pose_detection_t** results) { return mmdeploy_pose_detector_apply_bbox(detector, mats, mat_count, nullptr, nullptr, results); diff --git a/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.h b/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.h index ff0987cee4..8e43d29ac8 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/pose_detector.h @@ -50,6 +50,20 @@ MMDEPLOY_API int mmdeploy_pose_detector_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_pose_detector_t* detector); +/** + * @brief Create a pose detector instance + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] detector handle of the created pose detector, which must be destroyed + * by \ref mmdeploy_pose_detector_destroy + * @return status code of the operation + */ +MMDEPLOY_API int mmdeploy_pose_detector_create_by_buffer(const void* buffer, int size, + const char* device_name, int device_id, + mmdeploy_pose_detector_t* detector); + /** * @brief Apply pose detector to a batch of images with full image roi * @param[in] detector pose detector's handle created by \ref diff --git a/csrc/mmdeploy/apis/c/mmdeploy/restorer.cpp b/csrc/mmdeploy/apis/c/mmdeploy/restorer.cpp index 9ca2ca65f7..9077a16f39 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/restorer.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/restorer.cpp @@ -39,6 +39,17 @@ int mmdeploy_restorer_create_by_path(const char* model_path, const char* device_ return ec; } +int mmdeploy_restorer_create_by_buffer(const void* buffer , int size , const char* device_name, int device_id, + mmdeploy_restorer_t* restorer) { + mmdeploy_model_t model{}; + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_restorer_create(model, device_name, device_id, restorer); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_restorer_apply(mmdeploy_restorer_t restorer, const mmdeploy_mat_t* images, int count, mmdeploy_mat_t** results) { wrapped input; diff --git a/csrc/mmdeploy/apis/c/mmdeploy/restorer.h b/csrc/mmdeploy/apis/c/mmdeploy/restorer.h index 9ab529850f..2a5a6ac6e9 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/restorer.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/restorer.h @@ -43,6 +43,20 @@ MMDEPLOY_API int mmdeploy_restorer_create(mmdeploy_model_t model, const char* de MMDEPLOY_API int mmdeploy_restorer_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_restorer_t* restorer); +/** + * @brief Create a restorer instance + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] restorer handle of the created restorer, which must be destroyed + * by \ref mmdeploy_restorer_destroy + * @return status code of the operation + */ +MMDEPLOY_API int mmdeploy_restorer_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_restorer_t* restorer); + + /** * @brief Apply restorer to a batch of images * @param[in] restorer restorer's handle created by \ref mmdeploy_restorer_create_by_path diff --git a/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.cpp b/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.cpp index d2172c54b8..1e5e5e6f13 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.cpp @@ -39,6 +39,18 @@ int mmdeploy_rotated_detector_create_by_path(const char* model_path, const char* return ec; } +int mmdeploy_rotated_detector_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_rotated_detector_t* detector) { + mmdeploy_model_t model{}; + + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_rotated_detector_create(model, device_name, device_id, detector); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_rotated_detector_apply(mmdeploy_rotated_detector_t detector, const mmdeploy_mat_t* mats, int mat_count, mmdeploy_rotated_detection_t** results, int** result_count) { diff --git a/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.h b/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.h index 35125a74ff..c271b6ba22 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/rotated_detector.h @@ -49,6 +49,19 @@ MMDEPLOY_API int mmdeploy_rotated_detector_create_by_path(const char* model_path const char* device_name, int device_id, mmdeploy_rotated_detector_t* detector); +/** + * @brief Create rotated detector's handle + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] detector instance of a rotated detector + * @return status of creating rotated detector's handle + */ +MMDEPLOY_API int mmdeploy_rotated_detector_create_by_buffer(const void* buffer, int size, + const char* device_name, int device_id, + mmdeploy_rotated_detector_t* detector); + /** * @brief Apply rotated detector to batch images and get their inference results * @param[in] detector rotated detector's handle created by \ref diff --git a/csrc/mmdeploy/apis/c/mmdeploy/segmentor.cpp b/csrc/mmdeploy/apis/c/mmdeploy/segmentor.cpp index c982df39e5..180b4cceb8 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/segmentor.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/segmentor.cpp @@ -41,6 +41,17 @@ int mmdeploy_segmentor_create_by_path(const char* model_path, const char* device return ec; } +int mmdeploy_segmentor_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_segmentor_t* segmentor) { + mmdeploy_model_t model{}; + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_segmentor_create(model, device_name, device_id, segmentor); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_segmentor_apply(mmdeploy_segmentor_t segmentor, const mmdeploy_mat_t* mats, int mat_count, mmdeploy_segmentation_t** results) { wrapped input; diff --git a/csrc/mmdeploy/apis/c/mmdeploy/segmentor.h b/csrc/mmdeploy/apis/c/mmdeploy/segmentor.h index 65bcfd03f3..50c43fd2e2 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/segmentor.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/segmentor.h @@ -54,6 +54,20 @@ MMDEPLOY_API int mmdeploy_segmentor_create(mmdeploy_model_t model, const char* d MMDEPLOY_API int mmdeploy_segmentor_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_segmentor_t* segmentor); +/** + * @brief Create segmentor's handle + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] segmentor instance of a segmentor, which must be destroyed + * by \ref mmdeploy_segmentor_destroy + * @return status of creating segmentor's handle + */ +MMDEPLOY_API int mmdeploy_segmentor_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_segmentor_t* segmentor); + + /** * @brief Apply segmentor to batch images and get their inference results * @param[in] segmentor segmentor's handle created by \ref mmdeploy_segmentor_create_by_path or \ref diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.cpp b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.cpp index 576af07762..916fce6ffc 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.cpp @@ -44,6 +44,17 @@ int mmdeploy_text_detector_create_by_path(const char* model_path, const char* de return ec; } +int mmdeploy_text_detector_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_text_detector_t* detector) { + mmdeploy_model_t model{}; + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_text_detector_create(model, device_name, device_id, detector); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_text_detector_create_input(const mmdeploy_mat_t* mats, int mat_count, mmdeploy_value_t* input) { return mmdeploy_common_create_input(mats, mat_count, input); diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h index a3c38dc6f6..2405a2e011 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h @@ -49,6 +49,20 @@ MMDEPLOY_API int mmdeploy_text_detector_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_text_detector_t* detector); +/** + * @brief Create text-detector's handle + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device + * @param[out] detector instance of a text-detector, which must be destroyed + * by \ref mmdeploy_text_detector_destroy + * @return status of creating text-detector's handle + */ +MMDEPLOY_API int mmdeploy_text_detector_create_by_path(const void* buffer, int size, + const char* device_name, int device_id, + mmdeploy_text_detector_t* detector); + /** * @brief Apply text-detector to batch images and get their inference results * @param[in] detector text-detector's handle created by \ref mmdeploy_text_detector_create_by_path diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.cpp b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.cpp index 3c8cfbb5c6..240c409aa0 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.cpp @@ -78,6 +78,17 @@ int mmdeploy_text_recognizer_create_by_path(const char* model_path, const char* return ec; } +int mmdeploy_text_recognizer_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, mmdeploy_text_recognizer_t* recognizer) { + mmdeploy_model_t model{}; + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_text_recognizer_create(model, device_name, device_id, recognizer); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_text_recognizer_apply(mmdeploy_text_recognizer_t recognizer, const mmdeploy_mat_t* images, int count, mmdeploy_text_recognition_t** results) { diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h index 6c18928242..6fc59eec3a 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h @@ -51,6 +51,20 @@ MMDEPLOY_API int mmdeploy_text_recognizer_create_by_path(const char* model_path, const char* device_name, int device_id, mmdeploy_text_recognizer_t* recognizer); +/** + * @brief Create a text recognizer instance + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] recognizer handle of the created text recognizer, which must be destroyed + * by \ref mmdeploy_text_recognizer_destroy + * @return status code of the operation + */ +MMDEPLOY_API int mmdeploy_text_recognizer_create_by_path(const void* buffer, int size, + const char* device_name, int device_id, + mmdeploy_text_recognizer_t* recognizer); + /** * @brief Apply text recognizer to a batch of text images * @param[in] recognizer text recognizer's handle created by \ref diff --git a/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.cpp b/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.cpp index de71e57842..b00533b658 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.cpp +++ b/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.cpp @@ -44,6 +44,20 @@ int mmdeploy_video_recognizer_create_by_path(const char* model_path, const char* mmdeploy_model_destroy(model); return ec; } + +int mmdeploy_video_recognizer_create_by_buffer(const void* buffer, int size, const char* device_name, + int device_id, + mmdeploy_video_recognizer_t* recognizer) { + mmdeploy_model_t model{}; + + if (auto ec = mmdeploy_model_create(buffer, size, &model)) { + return ec; + } + auto ec = mmdeploy_video_recognizer_create(model, device_name, device_id, recognizer); + mmdeploy_model_destroy(model); + return ec; +} + int mmdeploy_video_recognizer_apply(mmdeploy_video_recognizer_t recognizer, const mmdeploy_mat_t* images, const mmdeploy_video_sample_info_t* video_info, int video_count, diff --git a/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.h b/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.h index e98b2bd07e..14b7ce519a 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/video_recognizer.h @@ -55,6 +55,20 @@ MMDEPLOY_API int mmdeploy_video_recognizer_create_by_path(const char* model_path const char* device_name, int device_id, mmdeploy_video_recognizer_t* recognizer); +/** + * @brief Create a video recognizer instance + * @param[in] buffer a linear buffer contains the model information + * @param[in] size size of \p buffer in bytes + * @param[in] device_name name of device, such as "cpu", "cuda", etc. + * @param[in] device_id id of device. + * @param[out] recognizer handle of the created video recognizer, which must be destroyed + * by \ref mmdeploy_video_recognizer_destroy + * @return status code of the operation + */ +MMDEPLOY_API int mmdeploy_video_recognizer_create_by_buffer(const void* buffer, int size, + const char* device_name, int device_id, + mmdeploy_video_recognizer_t* recognizer); + /** * @brief Apply video recognizer to a batch of videos * @param[in] recognizer video recognizer's handle created by \ref From 0c93abe06b4ee79dbb077cfe77af6e350234267d Mon Sep 17 00:00:00 2001 From: dhz Date: Wed, 26 Apr 2023 14:01:51 +0800 Subject: [PATCH 2/2] The.h file method is incorrectly named --- csrc/mmdeploy/apis/c/mmdeploy/text_detector.h | 2 +- csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h index 2405a2e011..d640d57e15 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_detector.h @@ -59,7 +59,7 @@ MMDEPLOY_API int mmdeploy_text_detector_create_by_path(const char* model_path, * by \ref mmdeploy_text_detector_destroy * @return status of creating text-detector's handle */ -MMDEPLOY_API int mmdeploy_text_detector_create_by_path(const void* buffer, int size, +MMDEPLOY_API int mmdeploy_text_detector_create_by_buffer(const void* buffer, int size, const char* device_name, int device_id, mmdeploy_text_detector_t* detector); diff --git a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h index 6fc59eec3a..40272ffb6a 100644 --- a/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h +++ b/csrc/mmdeploy/apis/c/mmdeploy/text_recognizer.h @@ -61,7 +61,7 @@ MMDEPLOY_API int mmdeploy_text_recognizer_create_by_path(const char* model_path, * by \ref mmdeploy_text_recognizer_destroy * @return status code of the operation */ -MMDEPLOY_API int mmdeploy_text_recognizer_create_by_path(const void* buffer, int size, +MMDEPLOY_API int mmdeploy_text_recognizer_create_by_buffer(const void* buffer, int size, const char* device_name, int device_id, mmdeploy_text_recognizer_t* recognizer);