安装paddleocr:
apt install python3-pip libgl1
pip3 install paddlepaddle paddleocr
paddleocr cli使用:
paddleocr --image_dir test.jpg --lang ch --show_log False --det_db_unclip_ratio 2.5
python使用:
from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang="ch", det_db_score_mode="slow", show_log=False, use_gpu=False, det_db_unclip_ratio=2.5)
img_path = 'test.jpg'
result = ocr.ocr(img_path, cls=True)
txts = [line[1][0] for line in result]
print(*txts)
如遇到错:
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)
安装指定版本opencv-python:
pip uninstall opencv-python
pip install opencv-python==4.5.5.64
https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/inference_args.md