Skip to content

πŸ“„ Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Fix python/rapidOCR parameter error

SWHL686e4ceca148
diff --git a/python/rapidOCR.py b/python/rapidOCR.py
index 3c68571..5c59f80 100644
--- a/python/rapidOCR.py
+++ b/python/rapidOCR.py
@@ -89,6 +89,7 @@ def draw_ocr_box_txt(image, boxes, txts,
color = (random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255))
+ print(box)
draw_left.polygon(box, fill=color)
draw_right.polygon([box[0][0], box[0][1],
box[1][0], box[1][1],
@@ -96,10 +97,10 @@ def draw_ocr_box_txt(image, boxes, txts,
box[3][0], box[3][1]],
outline=color)
- box_height = math.sqrt((box[0][0] - box[3][0])**2 \
+ box_height = math.sqrt((box[0][0] - box[3][0])**2
+ (box[0][1] - box[3][1])**2)
- box_width = math.sqrt((box[0][0] - box[1][0])**2 \
+ box_width = math.sqrt((box[0][0] - box[1][0])**2
+ (box[0][1] - box[1][1])**2)
if box_height > 2 * box_width:
@@ -267,8 +268,8 @@ if __name__ == '__main__':
parser.add_argument('--image_path', type=str,
default='test_images/det_images/')
parser.add_argument('--text_score', type=float, default=0.5)
-
- parser.add_argument('--keys_path', type=str,
+
+ parser.add_argument('--keys_path', type=str,
default="ch_ppocr_mobile_v2_rec/ppocr_keys_v1.txt")
args = parser.parse_args()
text_score = args.text_score
@@ -283,7 +284,10 @@ if __name__ == '__main__':
if args.rec_model_path.find('server') != -1:
from ch_ppocr_server_v2_rec import TextRecognizer
else:
- from ch_ppocr_mobile_v2_rec import TextRecognizer
+ if args.rec_model_path.find('en') != -1:
+ from en_number_ppocr_mobile_v2_rec import TextRecognizer
+ else:
+ from ch_ppocr_mobile_v2_rec import TextRecognizer
text_sys = TextSystem(args.det_model_path,
args.rec_model_path,
diff --git a/python/rapidOCR.sh b/python/rapidOCR.sh
index a27e3d9..3c324f8 100644
--- a/python/rapidOCR.sh
+++ b/python/rapidOCR.sh
@@ -3,10 +3,10 @@
# The img_path can be file path or folder path.
img_path="test_images/det_images/1.jpg"
-key_path="ch_ppocr_mobile_v2_rec/ppocr_keys_v1.txt"
+keys_path="ch_ppocr_mobile_v2_rec/ppocr_keys_v1.txt"
python rapidOCR.py --det_model_path models/ch_ppocr_mobile_v2.0_det_infer.onnx \
--cls_model_path models/ch_ppocr_mobile_v2.0_cls_infer.onnx \
--rec_model_path models/ch_ppocr_mobile_v2.0_rec_infer.onnx \
--image_path ${img_path} \
--text_score 0.5 \
- --key_path ${key_path}
+ --keys_path ${keys_path}