Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/vision/ocr/PP-OCRv2/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ PPOCRv2 的初始化,由检测,识别模型串联构成(无分类器)

> ```
> bool Predict(cv::Mat* img, fastdeploy::vision::OCRResult* result);
> bool Predict(const cv::Mat& img, fastdeploy::vision::OCRResult* result);
> ```
>
> 模型预测接口,输入一张图片,返回OCR预测结果
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ocr/ppocr/classifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool Classifier::Initialize() {
return true;
}

bool Classifier::Predict(cv::Mat& img, int32_t* cls_label, float* cls_score) {
bool Classifier::Predict(const cv::Mat& img, int32_t* cls_label, float* cls_score) {
std::vector<int32_t> cls_labels(1);
std::vector<float> cls_scores(1);
bool success = BatchPredict({img}, &cls_labels, &cls_scores);
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ocr/ppocr/classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FASTDEPLOY_DECL Classifier : public FastDeployModel {
const ModelFormat& model_format = ModelFormat::PADDLE);
/// Get model's name
std::string ModelName() const { return "ppocr/ocr_cls"; }
virtual bool Predict(cv::Mat& img, int32_t* cls_label, float* cls_score);
virtual bool Predict(const cv::Mat& img, int32_t* cls_label, float* cls_score);
/** \brief BatchPredict the input image and get OCR classification model cls_result.
*
* \param[in] images The list of input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format.
Expand Down
8 changes: 6 additions & 2 deletions fastdeploy/vision/ocr/ppocr/ppocr_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ bool PPOCRv2::Initialized() const {
}
return true;
}

bool PPOCRv2::Predict(cv::Mat* img,
fastdeploy::vision::OCRResult* result) {
return Predict(*img, result);
}

bool PPOCRv2::Predict(const cv::Mat& img,
fastdeploy::vision::OCRResult* result) {
std::vector<fastdeploy::vision::OCRResult> batch_result(1);
bool success = BatchPredict({*img},&batch_result);
bool success = BatchPredict({img},&batch_result);
if(!success){
return success;
}
Expand Down
1 change: 1 addition & 0 deletions fastdeploy/vision/ocr/ppocr/ppocr_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class FASTDEPLOY_DECL PPOCRv2 : public FastDeployModel {
* \return true if the prediction successed, otherwise false.
*/
virtual bool Predict(cv::Mat* img, fastdeploy::vision::OCRResult* result);
virtual bool Predict(const cv::Mat& img, fastdeploy::vision::OCRResult* result);
/** \brief BatchPredict the input image and get OCR result.
*
* \param[in] images The list of input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format.
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ocr/ppocr/recognizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool Recognizer::Initialize() {
return true;
}

bool Recognizer::Predict(cv::Mat& img, std::string* text, float* rec_score) {
bool Recognizer::Predict(const cv::Mat& img, std::string* text, float* rec_score) {
std::vector<std::string> texts(1);
std::vector<float> rec_scores(1);
bool success = BatchPredict({img}, &texts, &rec_scores);
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ocr/ppocr/recognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FASTDEPLOY_DECL Recognizer : public FastDeployModel {
const ModelFormat& model_format = ModelFormat::PADDLE);
/// Get model's name
std::string ModelName() const { return "ppocr/ocr_rec"; }
virtual bool Predict(cv::Mat& img, std::string* text, float* rec_score);
virtual bool Predict(const cv::Mat& img, std::string* text, float* rec_score);
/** \brief BatchPredict the input image and get OCR recognition model result.
*
* \param[in] images The list of input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format.
Expand Down