图片文字识别不出来
收藏
目标图片如图:
使用如下脚本:
def ocr_to_word(source_image, target_image):
ocr = PaddleOCR(use_angle_cls=True, lang="ch", use_gpu=False,
det_model_dir=os.path.join(OCR_MODEL_PATH, "ch_PP-OCRv3_det_infer"),
cls_model_dir=os.path.join(OCR_MODEL_PATH, "ch_ppocr_mobile_v2.0_cls_infer"),
rec_model_dir=os.path.join(OCR_MODEL_PATH, "ch_PP-OCRv3_rec_infer"))
result = ocr.ocr(source_image, cls=True)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
# 显示结果
result = result[0]
image = Image.open(source_image).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path=f'{OCR_MODEL_PATH}/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save(target_image)
控制台输出:
[2023/03/31 16:21:56] ppocr DEBUG: dt_boxes num : 0, elapse : 0.02344989776611328
[2023/03/31 16:21:56] ppocr DEBUG: cls num : 0, elapse : 0
[2023/03/31 16:21:56] ppocr DEBUG: rec_res num : 0, elapse : 0.0
图片结果为:
当前Python版本为3.8.16,paddleocr 版本2.6.1.3
0
收藏
请登录后评论