车牌图像在这里:
https://www.51halcon.com/forum.php?mod=viewthread&tid=716&fromuid=3
- from paddleocr import PaddleOCR, draw_ocr
- # Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
- # 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
- ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
- img_path = 'C:/Users/Criss/Desktop/22.jpg'
- result = ocr.ocr(img_path, cls=True)
- for line in result:
- print(line)
- # 显示结果
- from PIL import Image
- image = Image.open(img_path).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='./fonts/simfang.ttf')
- im_show = Image.fromarray(im_show)
- im_show.save('result.jpg')
复制代码
导入代码到pycharm中,然后运行即可。
识别效果:
- [2021/09/19 19:47:30] root DEBUG: dt_boxes num : 4, elapse : 0.16655516624450684
- [2021/09/19 19:47:30] root DEBUG: cls num : 4, elapse : 0.04388308525085449
- [2021/09/19 19:47:31] root DEBUG: rec_res num : 4, elapse : 0.28022098541259766
- [[[34.0, 137.0], [457.0, 134.0], [458.0, 229.0], [35.0, 233.0]], ('赣B·1D569', 0.9075086)]
- [[[396.0, 345.0], [495.0, 345.0], [495.0, 365.0], [396.0, 365.0]], ('51halcon.com', 0.97081804)]
复制代码
不得不说,真6啊!
paddleocr中文使用说明:
https://github.com/PaddlePaddle/ ... oc_ch/quickstart.md |