mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00

* add batch_predict and initialized api for c * add batch_predict and result str in C api * modify visualization function * add micro to add models batchify * refactor and add models for ppdet others * add base define * fix * refine predict api
60 lines
2.4 KiB
C++
60 lines
2.4 KiB
C++
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "fastdeploy_capi/vision/visualize.h"
|
|
|
|
#include "fastdeploy/vision/visualize/visualize.h"
|
|
#include "fastdeploy_capi/types_internal.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
FD_C_Mat FD_C_VisDetection(FD_C_Mat im,
|
|
FD_C_DetectionResult* fd_c_detection_result,
|
|
float score_threshold, int line_size,
|
|
float font_size) {
|
|
FD_C_DetectionResultWrapper* fd_c_detection_result_wrapper =
|
|
FD_C_CreateDetectionResultWrapperFromData(fd_c_detection_result);
|
|
auto& detection_result = CHECK_AND_CONVERT_FD_TYPE(
|
|
DetectionResultWrapper, fd_c_detection_result_wrapper);
|
|
cv::Mat result = fastdeploy::vision::VisDetection(
|
|
*(reinterpret_cast<cv::Mat*>(im)), *detection_result, score_threshold,
|
|
line_size, font_size);
|
|
return new cv::Mat(result);
|
|
}
|
|
|
|
FD_C_Mat FD_C_VisDetectionWithLabel(FD_C_Mat im,
|
|
FD_C_DetectionResult* fd_c_detection_result,
|
|
FD_C_OneDimArrayCstr* labels,
|
|
float score_threshold, int line_size,
|
|
float font_size) {
|
|
std::vector<std::string> labels_in;
|
|
for (int i = 0; i < labels->size; i++) {
|
|
labels_in.emplace_back(labels->data[i].data);
|
|
}
|
|
FD_C_DetectionResultWrapper* fd_c_detection_result_wrapper =
|
|
FD_C_CreateDetectionResultWrapperFromData(fd_c_detection_result);
|
|
auto& detection_result = CHECK_AND_CONVERT_FD_TYPE(
|
|
DetectionResultWrapper, fd_c_detection_result_wrapper);
|
|
cv::Mat result = fastdeploy::vision::VisDetection(
|
|
*(reinterpret_cast<cv::Mat*>(im)), *detection_result, labels_in,
|
|
score_threshold, line_size, font_size);
|
|
return new cv::Mat(result);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|