赞
踩
本文用的python 3.7.16
借鉴了GitHub:https://github.com/Hammer-888/IDCard-OCR-Paddle
import os import sys import cv2 from paddleocr import PaddleOCR proj_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(proj_path) PaddleOCR = PaddleOCR(use_angle_cls=True, lang="ch") def ocrRead(image_path): # 读取身份证图片,并使用ocr.ocr()方法进行文字检测和识别,返回一个包含文字信息的列表 img = cv2.imread(image_path) result = PaddleOCR.ocr(img) return result
import os import sys import re import string proj_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(proj_path) class IdCardStraight: def __init__(self, result): self.result = [ i.replace(" ", "").translate(str.maketrans("", "", string.punctuation)) for i in result ] self.out = { } self.res = self.out self.res["name"] = "" self.res["idcard"] = "" self.res["birthday"] = "" self.res["address"] = "" self.res["sex"] = "" self
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。