from aip import AipOcr
APP_ID = '20225407'
API_KEY = 'zWGe7eiBpxqK3DXCRGW7hg1h'
SECRET_KEY = 'Ch3VXkshTVOLICUYIY2vkvOAOnacPQRa'
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
def get_file_content(filepath):
with open(filepath, 'rb') as fp:
return fp.read()
image = get_file_content('C:\\Users\\JiaShuo\\Desktop\\001\\200.jpg')
idCardSide = "front"
print(type(image))
""" 调用身份证识别 """
result = client.idcard(image, idCardSide)
print("姓名:", result["words_result"]["姓名"]["words"])
print("性别:", result["words_result"]["性别"]["words"])
print("民族:", result["words_result"]["民族"]["words"])
print("生日:", result["words_result"]["出生"]["words"])
print("身份证号:", result["words_result"]["公民身份号码"]["words"])
print("住址:", result["words_result"]["住址"]["words"])