【六期】港澳通行证识别
worddict 发布于2019-11 浏览:3148 回复:5
0
收藏

功能介绍
支持对大陆居民往来港澳通行证的证件号码、姓名、姓名拼音、出生日期、性别、有效期限、签发地点7个关键字段进行结构化识别

应用场景
出境旅游、留学
结合多种卡证识别技术,实现对护照、港澳通行证、台湾通行证等境外常用卡证信息的自动识别和录入,应用于境外旅游产品预定、个人信息登记等场景,有效提升信息录入效率,降低用户输入成本,提升用户使用体验

接口描述
对港澳通行证所有关键字段进行识别。

帮助地址:https://ai.baidu.com/docs#/OCR-API-HKMPermit/top

请求URL: https://aip.baidubce.com/rest/2.0/ocr/v1/HK_Macau_exitentrypermit

请求参数
image string 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式

返回示例

{
"log_id": 490699656,
"words_result": {
"words": "山东"
},
"Birthday": {
"words": "19900201"
},
"CardNum": {
"words": "c10563465"
},
"NameChn": {
"words": "陈露露"
},
"NameEng": {
"words": "CHENLULU"
},
"Sex": {
"words": "女"
},
"ValidDate": {
"words": "20150116-20250115"
},
},
"words_result_num": 7
}

代码实现(python3):

import urllib
import base64
import json
import time

#client_id 为官网获取的AK, client_secret 为官网获取的SK
client_id = 'XXXXXXXX'
client_secret = 'XXXXXXXXX'

#获取token
def get_token():
    host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + client_id + '&client_secret=' + client_secret
    request = urllib.request.Request(host)
    request.add_header('Content-Type', 'application/json; charset=UTF-8')
    response = urllib.request.urlopen(request)
    token_content = response.read()
    if token_content:
        token_info = json.loads(token_content)
        token_key = token_info['access_token']
    return token_key

#港澳通行证识别
def HK_Macau(filename):
    request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/HK_Macau_exitentrypermit"
    
    # 二进制方式打开图片文件
    f = open(filename, 'rb')
    img = base64.b64encode(f.read())
    
    params = dict()
    params['image'] = img
    params = urllib.parse.urlencode(params).encode("utf-8")
    access_token = get_token()
    
    begin = time.perf_counter()
        
    request_url = request_url + "?access_token=" + access_token
    request = urllib.request.Request(url=request_url, data=params)
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
    response = urllib.request.urlopen(request)
    content = response.read()
    
    end = time.perf_counter()
    print('处理时长:'+'%.2f'%(end-begin)+'秒')
    if content:
        content=content.decode('utf-8')
        data = json.loads(content)
        words_result=data['words_result']
        
        for item in words_result:
            print (item,':',words_result[item]['words'])
        


产品测评:

处理时长:3.26秒
ValidDate : 20140421-20240420
Sex : 女
NameChn : 证件样
Birthday : 19810803
NameEng : ZHENGJIANYANGBEN
CardNum : c00000000
Address : 广东

测试结果及建议

通过评测发现百度港澳通行证识别速度和准确率都很不错。

收藏
点赞
0
个赞
共5条回复 最后由用户已被禁言回复于2022-04
#19用户已被禁言回复于2022-04

http://www.yxdown.com/search?wd=%E6%9E%9C%E6%95%A2%E9%91%AB%E4%BD%B0%E5%88%A9%E5%A8%B1%E4%B9%90%E5%AE%98%E7%BD%91B2024%C2%B7CN%E6%9E%A3%E5%BA%84%E7%94%B5%E4%BF%A1%EF%BC%A5%EF%BD%82%EF%BD%99 https://s.co188.com/front/forum?keyword=%BB%AA%C4%C9%B9%FA%BC%CA%CF%C2%B7%D6%CC%E1%BF%EE%A1%BETL262%A1%A4C%A3%CFM%BB%B6%D3%AD%C4%FA%A1%BF%E5%A7%D1%F4%D5%D0%C6%B8%A3%DF%A3%AF&fid=2343&catalog_name=&order_type=0&publish_time=0&reply_num=0&s_phrase=false https://b2b.baidu.com/s?q=%E5%8B%90%E6%8B%89%E9%BE%99%E6%BA%90%E5%85%AC%E5%8F%B8%E4%B8%8A%E4%B8%8B%E5%88%86%E4%B8%9A%E5%8A%A1%E5%BE%AE%E4%BF%A1%E5%BC%80%E6%88%B7%E7%94%B5%E8%AF%9D%E3%80%90TL262%C2%B7%EF%BC%A3%EF%BC%AF%EF%BC%AD%E6%AC%A2%E8%BF%8E%E6%82%A8%E3%80%91%E9%95%BF%E6%B2%BB%E7%94%B5%E8%A7%86%E5%8F%B0&from=search http://search.dangdang.com/?key=%CC%DA%C1%FA%CF%D6%B3%A1%BF%AA%BB%A7%D5%D2%CB%AD%A1%BE%B9%D9%CD%F8%A1%FAB2024%A1%A4CN%A1%BF%C5%CC%BD%F5%B7%D6%D5%BE%A3%AD%A3%CB%A3%FC&act=input https://163yun.com/search/%E7%99%BE%E8%83%9C%E5%B8%9D%E5%AE%9D%E8%AE%A1%E5%88%92%E5%B8%88%E5%AE%98%E6%96%B9%E7%BD%91%E5%9D%80TL262%C2%B7C%EF%BC%AFM%E5%A4%AA%E5%8E%9F%E7%94%B5%E8%A7%86%E5%8F%B0%EF%BC%B0%EF%BC%A4%EF%BC%BB

0
#5worddict回复于2019-11

期待大家一起来尝试

0
#4worddict回复于2019-11

以后各种证照都可以自动处理了

0
#3worddict回复于2019-11
#2 小雨青青润无声回复
百度证照的识别效果都很好

是啊,效果非常的不错

0
#2小雨青青润无声回复于2019-11

百度证照的识别效果都很好

0
TOP
切换版块