mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-18 22:44:39 +08:00
Add PaddleOCRv3 & PaddleOCRv2 Support (#139)
* Add PaddleOCR Support * Add PaddleOCR Support * Add PaddleOCRv3 Support * Add PaddleOCRv3 Support * Update README.md * Update README.md * Update README.md * Update README.md * Add PaddleOCRv3 Support * Add PaddleOCRv3 Supports * Add PaddleOCRv3 Suport * Fix Rec diff * Remove useless functions * Remove useless comments * Add PaddleOCRv2 Support
This commit is contained in:
@@ -302,5 +302,68 @@ std::string MattingResult::Str() {
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string OCRResult::Str() {
|
||||
std::string no_result;
|
||||
if (boxes.size() > 0) {
|
||||
std::string out;
|
||||
for (int n = 0; n < boxes.size(); n++) {
|
||||
out = out + "det boxes: [";
|
||||
for (int i = 0; i < 4; i++) {
|
||||
out = out + "[" + std::to_string(boxes[n][i * 2]) + "," +
|
||||
std::to_string(boxes[n][i * 2 + 1]) + "]";
|
||||
|
||||
if (i != 3) {
|
||||
out = out + ",";
|
||||
}
|
||||
}
|
||||
out = out + "]";
|
||||
|
||||
if (rec_scores.size() > 0) {
|
||||
out = out + "rec text: " + text[n] + " rec scores:" +
|
||||
std::to_string(rec_scores[n]) + " ";
|
||||
}
|
||||
if (cls_label.size() > 0) {
|
||||
out = out + "cls label: " + std::to_string(cls_label[n]) +
|
||||
" cls score: " + std::to_string(cls_scores[n]);
|
||||
}
|
||||
out = out + "\n";
|
||||
}
|
||||
return out;
|
||||
|
||||
} else if (boxes.size() == 0 && rec_scores.size() > 0 &&
|
||||
cls_scores.size() > 0) {
|
||||
std::string out;
|
||||
for (int i = 0; i < rec_scores.size(); i++) {
|
||||
out = out + "rec text: " + text[i] + " rec scores:" +
|
||||
std::to_string(rec_scores[i]) + " ";
|
||||
out = out + "cls label: " + std::to_string(cls_label[i]) +
|
||||
" cls score: " + std::to_string(cls_scores[i]);
|
||||
out = out + "\n";
|
||||
}
|
||||
return out;
|
||||
} else if (boxes.size() == 0 && rec_scores.size() == 0 &&
|
||||
cls_scores.size() > 0) {
|
||||
std::string out;
|
||||
for (int i = 0; i < cls_scores.size(); i++) {
|
||||
out = out + "cls label: " + std::to_string(cls_label[i]) +
|
||||
" cls score: " + std::to_string(cls_scores[i]);
|
||||
out = out + "\n";
|
||||
}
|
||||
return out;
|
||||
} else if (boxes.size() == 0 && rec_scores.size() > 0 &&
|
||||
cls_scores.size() == 0) {
|
||||
std::string out;
|
||||
for (int i = 0; i < rec_scores.size(); i++) {
|
||||
out = out + "rec text: " + text[i] + " rec scores:" +
|
||||
std::to_string(rec_scores[i]) + " ";
|
||||
out = out + "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
no_result = no_result + "No Results!";
|
||||
return no_result;
|
||||
}
|
||||
|
||||
} // namespace vision
|
||||
} // namespace fastdeploy
|
||||
|
@@ -22,6 +22,7 @@ enum FASTDEPLOY_DECL ResultType {
|
||||
CLASSIFY,
|
||||
DETECTION,
|
||||
SEGMENTATION,
|
||||
OCR,
|
||||
FACE_DETECTION,
|
||||
FACE_RECOGNITION,
|
||||
MATTING
|
||||
@@ -59,6 +60,20 @@ struct FASTDEPLOY_DECL DetectionResult : public BaseResult {
|
||||
std::string Str();
|
||||
};
|
||||
|
||||
struct FASTDEPLOY_DECL OCRResult : public BaseResult {
|
||||
std::vector<std::array<int, 8>> boxes;
|
||||
|
||||
std::vector<std::string> text;
|
||||
std::vector<float> rec_scores;
|
||||
|
||||
std::vector<float> cls_scores;
|
||||
std::vector<int32_t> cls_label;
|
||||
|
||||
ResultType type = ResultType::OCR;
|
||||
|
||||
std::string Str();
|
||||
};
|
||||
|
||||
struct FASTDEPLOY_DECL FaceDetectionResult : public BaseResult {
|
||||
// box: xmin, ymin, xmax, ymax
|
||||
std::vector<std::array<float, 4>> boxes;
|
||||
|
Reference in New Issue
Block a user