from paddleocr import PaddleOCR, draw_ocr import re ocr = PaddleOCR(use_angle_cls=False, lang="ch", show_log=False) img_path = 'b.jpg' result = ocr.ocr(img_path, cls=False) name='' num='' _num='' for idx in range(len(result)): res = result[idx] for i,line in enumerate(res): print(i,line[1][0]) if i < 1: name = line[1][0][2:] if i ==1 and len(name) < 1: name=line[1][0] _num = re.findall("""^[0-9Xx]w{17}$""",line[1][0]) if len(_num)>0: num=_num if num !='': print(name,num[0]) else: print('number in error') ''' from PIL import Image result = result[0] 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='SimHei.ttf') im_show = Image.fromarray(im_show) im_show.save('result.jpg') '''
paddleocr识别身份证
阅读:1624 输入:2023-10-09 16:39:03
- 上一篇:html5手写签名并保存数据库或下载
- 下一篇:php如何构建一个自己的区块链