目录
pip3 install cnocr -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple
from cnocr import CnOcr
img_fp = './input.jpeg'
ocr = CnOcr() # 所有参数都使用默认值
out = ocr.ocr(img_fp)
print(out)
from cnocr import CnOcr
img_fp = './input.png'
ocr = CnOcr(det_model_name='naive_det')
out = ocr.ocr(img_fp)
print(out)
from cnocr import CnOcr
img_fp = './input.png'
ocr = CnOcr(rec_model_name='ch_PP-OCRv3')
out = ocr.ocr(img_fp)
print(out)
from cnocr import CnOcr
img_fp = './input.jpeg'
ocr = CnOcr(det_model_name='en_PP-OCRv3_det', rec_model_name='en_PP-OCRv3')
out = ocr.ocr(img_fp)
print(out)
from cnocr import CnOcr
img_fp = './input.jpg'
ocr = CnOcr(rec_model_name='chinese_cht_PP-OCRv3') # 识别模型使用繁体识别模型
out = ocr.ocr(img_fp)
print(out)
from cnocr import CnOcr
img_fp = './input.jpg'
ocr = CnOcr()
out = ocr.ocr_for_single_line(img_fp)
print(out)