Skip to content

Commit 444f328

Browse files
committed
Improve det_model pybind
1 parent 25eae73 commit 444f328

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fastdeploy/vision/ocr/ppocr/ocrmodel_pybind.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ void BindPPOCRModel(pybind11::module& m) {
119119
auto mat = PyArrayToCvMat(data);
120120
std::vector<std::array<int, 8>> boxes_result;
121121
self.Predict(mat, &boxes_result);
122-
return boxes_result;
122+
vision::OCRResult ocr_result;
123+
ocr_result.boxes = boxes_result;
124+
return ocr_result;
123125
})
124126
.def("batch_predict", [](vision::ocr::DBDetector& self,
125127
std::vector<pybind11::array>& data) {
@@ -129,7 +131,12 @@ void BindPPOCRModel(pybind11::module& m) {
129131
images.push_back(PyArrayToCvMat(data[i]));
130132
}
131133
self.BatchPredict(images, &det_results);
132-
return det_results;
134+
std::vector<vision::OCRResult> ocr_results;
135+
ocr_results.resize(det_results.size());
136+
for (int i = 0; i < det_results.size(); i++) {
137+
ocr_results[i].boxes = det_results[i];
138+
}
139+
return ocr_results;
133140
});
134141

135142
// Classifier

0 commit comments

Comments
 (0)