📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Fix issue #75
SWHLc965a72c5114
diff --git a/README.md b/README.mdindex 7564b44..de64aef 100755--- a/README.md+++ b/README.md@@ -170,6 +170,7 @@ flowchart LR- 非常感谢[lzh111222334](https://github.com/lzh111222334)修复python版本下rec前处理部分bug。- 非常感谢[AutumnSun1996](https://github.com/AutumnSun1996)在[#42](https://github.com/RapidAI/RapidOCR/issues/42)中的建议。- 非常感谢[DeadWood8](https://github.com/DeadWood8)提供了[Nuitka打包rapidocr_web的操作文档和可执行exe](https://github.com/RapidAI/RapidOCR/wiki/Nuitka%E6%89%93%E5%8C%85rapidocr_web%E6%93%8D%E4%BD%9C%E6%96%87%E6%A1%A3)。+- 非常感谢[Loovelj](https://github.com/Loovelj)指出对文本检测框排序时顺序问题,详情参见[issue 75](https://github.com/RapidAI/RapidOCR/issues/75)。## 赞助|赞助者|应用的产品|diff --git a/docs/README_en.md b/docs/README_en.mdindex eee78b9..7b12dce 100644--- a/docs/README_en.md+++ b/docs/README_en.md@@ -163,6 +163,7 @@ flowchart LR- Many thanks to [lzh111222334](https://github.com/lzh111222334) for fixing some bugs of rec preprocessing under python version.- Many thanks to [AutumnSun1996](https://github.com/AutumnSun1996) for the suggestion in the [#42](https://github.com/RapidAI/RapidOCR/issues/42).- Many thanks to [DeadWood8](https://github.com/DeadWood8) for providing the [document]((https://github.com/RapidAI/RapidOCR/wiki/Nuitka%E6%89%93%E5%8C%85rapidocr_web%E6%93%8D%E4%BD%9C%E6%96%87%E6%A1%A3)) which packages rapidocr_web to exe by Nuitka.+- Many thanks to [Loovelj](https://github.com/Loovelj) for fixing the bug of sorting the text boxes. For details see [issue 75](https://github.com/RapidAI/RapidOCR/issues/75).## Sponsordiff --git a/python/rapidocr_onnxruntime/rapid_ocr_api.py b/python/rapidocr_onnxruntime/rapid_ocr_api.pyindex a33dc61..30283df 100644--- a/python/rapidocr_onnxruntime/rapid_ocr_api.py+++ b/python/rapidocr_onnxruntime/rapid_ocr_api.py@@ -163,11 +163,14 @@ class RapidOCR():_boxes = list(sorted_boxes)for i in range(num_boxes - 1):- if abs(_boxes[i + 1][0][1] - _boxes[i][0][1]) < 10 and \- (_boxes[i + 1][0][0] < _boxes[i][0][0]):- tmp = _boxes[i]- _boxes[i] = _boxes[i + 1]- _boxes[i + 1] = tmp+ for j in range(i, -1, -1):+ if abs(_boxes[j + 1][0][1] - _boxes[j][0][1]) < 10 \+ and _boxes[j + 1][0][0] < _boxes[j][0][0]:+ tmp = _boxes[j]+ _boxes[j] = _boxes[j + 1]+ _boxes[j + 1] = tmp+ else:+ breakreturn _boxesdef filter_boxes_rec_by_score(self, dt_boxes, rec_res):diff --git a/python/rapidocr_openvino/rapid_ocr_api.py b/python/rapidocr_openvino/rapid_ocr_api.pyindex a33dc61..30283df 100644--- a/python/rapidocr_openvino/rapid_ocr_api.py+++ b/python/rapidocr_openvino/rapid_ocr_api.py@@ -163,11 +163,14 @@ class RapidOCR():_boxes = list(sorted_boxes)for i in range(num_boxes - 1):- if abs(_boxes[i + 1][0][1] - _boxes[i][0][1]) < 10 and \- (_boxes[i + 1][0][0] < _boxes[i][0][0]):- tmp = _boxes[i]- _boxes[i] = _boxes[i + 1]- _boxes[i + 1] = tmp+ for j in range(i, -1, -1):+ if abs(_boxes[j + 1][0][1] - _boxes[j][0][1]) < 10 \+ and _boxes[j + 1][0][0] < _boxes[j][0][0]:+ tmp = _boxes[j]+ _boxes[j] = _boxes[j + 1]+ _boxes[j + 1] = tmp+ else:+ breakreturn _boxesdef filter_boxes_rec_by_score(self, dt_boxes, rec_res):