kangda_robotic_dog/003测试paddleocr.py
2025-08-14 15:15:17 +08:00

25 lines
1.2 KiB
Python

from paddleocr import PaddleOCR
ocr = PaddleOCR(
# 文本检测模型地址
text_detection_model_dir = "/home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_server_det",
# 文本识别模型地址
text_recognition_model_dir = "/home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_server_rec",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False) # 文本检测+文本识别
# ocr = PaddleOCR(use_doc_orientation_classify=True, use_doc_unwarping=True) # 文本图像预处理+文本检测+方向分类+文本识别
# ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False) # 文本检测+文本行方向分类+文本识别
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_mobile_det",
# text_recognition_model_name="PP-OCRv5_mobile_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False) # 更换 PP-OCRv5_mobile 模型
result = ocr.predict("data_image/001读表图片/2c7cc83019e7388a7041101da92c9829_frame_000000.jpg")
for res in result:
res.print()
# 输出文件夹
res.save_to_img("output")
res.save_to_json("output")