调用移动云OCR识别身份证

这篇具有很好参考价值的文章主要介绍了调用移动云OCR识别身份证。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一.开通移动云OCR服务

在下面这个网址开通免费服务,,每个账号可免费使用500次,先要实名认证。 

通用文字识别 (10086.cn)https://ecloud.10086.cn/home/product-introduction/Generalverify

有两种方式:

调用移动云OCR识别身份证

这里选择第二种 。

二.下载python_sdk测试代码

Python_SDK下载 (10086.cn)https://ecloud.10086.cn/op-help-center/doc/article/40776然后在pycharm中打开上面下载好的文件。

三.测试OCR功能

1.打开文件

打开OCRTest.py文件: 

调用移动云OCR识别身份证

调用移动云OCR识别身份证 里面的每个函数都是开通的OCR服务类型,你开通哪项服务,就配置哪个函数,对照表:

产品名称

服务名称

接口名称

请求路径

通用文字识别

通用类识别

网络图片文字识别

/api/ocr/v1/webimage

通用印刷体识别

/api/ocr/v1/general

通用手写体识别

/api/ocr/v1/handwriting

视频文字识别(视频上传)

/api/ocr/v1/videoupload

视频文字识别(视频文字识别结果查询)

/api/ocr/v1/videoresult

防疫核酸报告识别

/api/ocr/v1/nat

文档类识别

文档识别

/api/ocr/v1/generic

表格识别

/api/ocr/v1/form

卡证识别

卡证识别

身份证识别

/api/ocr/v1/idcard

营业执照识别(标准版)

/api/ocr/v1/businesslicense

营业执照识别(特殊版)

/api/ocr/v1/enterpriselicense

银行卡识别

/api/ocr/v1/bankcard

名片识别

/api/ocr/v1/businesscard

票据识别

票据识别

火车票识别

/api/ocr/v1/trainticket

增值税发票识别

/api/ocr/v1/invoice

出租车发票识别

/api/ocr/v1/taxiinvoice

定额发票识别

/api/ocr/v1/fixedinvoice

机票行程单识别

/api/ocr/v1/flights

过路费发票识别

/api/ocr/v1/toll

混贴票据识别

/api/ocr/v1/mixedbills

行业文字识别

资产类识别

印章检测

/api/ocr/v1/seal

印章识别

/api/ocr/v1/sealrecognition

汽车类识别

车牌识别

/api/ocr/v1/licenseplate

行驶证识别

/api/ocr/v1/driving

驾驶证识别

/api/ocr/v1/drive

VIN码识别

/api/ocr/v1/vincode

仪器仪表类识别

电表识别

/api/ocr/v1/ammeter

教育类识别

公式识别

/api/ocr/v1/formula

自定义模板识别

自定义模板识别

自定义模板识别

/api/ocr/v1/selfdefinition

智能结构化识别

智能结构化识别

/api/ocr/v1/smartstructure

 2.配置函数

 比如我开通的服务是网络图片文字识别,配置的函数是:

def request_webimage_file():
    print("请求File参数")
    requesturl = '/api/ocr/v1/webimage'    #填写对照表中的api地址
    #填写要识别图片的路径,代码包里提供了两张图片
    imagepath = 'C:\\Users\\zhuli\\Desktop\\smartlib_python_sdk\\test_code\\sfz.jpg'  
    try:
        ocr_client = CMSSEcloudOcrClient(accesskey, secretkey, url)
        response = ocr_client.request_ocr_service_file(requestpath=requesturl, imagepath= imagepath)
        print(response.text)
        
    except ValueError as e:
        print(e)
  • 第1行,引入我们的CMSSEcloudOcrClient类
  • 第3和第4行为用户的AK、SK信息
  • 第7行为requesturl参数为接口请求地址
  • 第8行为请求图片的路径
  • 第11行发起https请求,示例中request_ocr_service_file接收的图片的路径,同时还支持request_ocr_service_url(接收URL参数)和request_ocr_service_base64(接收图片base64编码)
  • 第12行打印响应内容

 3.配置移动云API调用所需的“AccessKey”、“SecretKey”

 进入该网址:https://ecloud.10086.cn/api/page/op-usercenter-static/#/aksk?productType=accesskeyhttps://ecloud.10086.cn/api/page/op-usercenter-static/#/aksk?productType=accesskey

调用移动云OCR识别身份证 点击左上角的创建可创建密钥,会生成一个excel文件,里面有“AccessKey”、“SecretKey”。

找到OCRTest.py的这两行:

调用移动云OCR识别身份证

 将密钥填入对应的位置。

然后在终端输入:

python setup.py install

4.图片识别

调用移动云OCR识别身份证

 运行OCRTest.py文件,终端输出:

"C:\Users\ysy2001 0615\Desktop\PythonSDK\Python_SDK\venv\Scripts\python.exe" "C:\Users\ysy2001 0615\Desktop\PythonSDK\Python_SDK\test_code\OCRTest.py" 
请求File参数
{"requestId":"reqId-db2d0b5745d0a3dbf1689-9e8075e5-2","state":"OK","body":{"content":{"prism_wnum":11,"prism_wordsInfo":[{"prob":0.6822017431259155,"position":[{"x":64,"y":37},{"x":21,"y":39},{"x":21,"y":27},{"x":63,"y":25}],"word":"姓名","chars":[{"pos":[{"x":24,"y":25},{"x":36,"y":25},{"x":36,"y":39},{"x":24,"y":39}],"confidence":0.0956088437898568,"char":"姓"},{"pos":[{"x":39,"y":25},{"x":51,"y":25},{"x":51,"y":39},{"x":39,"y":39}],"confidence":0.08598547386547697,"char":"名"}]},{"prob":0.7948694229125977,"position":[{"x":99,"y":38},{"x":57,"y":38},{"x":57,"y":23},{"x":100,"y":23}],"word":"韦小宝","chars":[{"pos":[{"x":60,"y":23},{"x":72,"y":23},{"x":72,"y":38},{"x":60,"y":38}],"confidence":0.08316039122068702,"char":"韦"},{"pos":[{"x":70,"y":23},{"x":83,"y":23},{"x":83,"y":38},{"x":70,"y":38}],"confidence":0.09125237194941925,"char":"小"},{"pos":[{"x":81,"y":23},{"x":93,"y":23},{"x":93,"y":38},{"x":81,"y":38}],"confidence":0.09230028952018327,"char":"宝"}]},{"prob":0.6656411290168762,"position":[{"x":75,"y":65},{"x":20,"y":65},{"x":20,"y":47},{"x":75,"y":47}],"word":"性别男","chars":[{"pos":[{"x":21,"y":47},{"x":37,"y":47},{"x":37,"y":65},{"x":21,"y":65}],"confidence":0.0872939909963341,"char":"性"},{"pos":[{"x":31,"y":47},{"x":47,"y":47},{"x":47,"y":65},{"x":31,"y":65}],"confidence":0.07940399219819497,"char":"别"},{"pos":[{"x":49,"y":47},{"x":65,"y":47},{"x":65,"y":65},{"x":49,"y":65}],"confidence":0.08107724526057385,"char":"男"}]},{"prob":0.7900686860084534,"position":[{"x":131,"y":63},{"x":88,"y":61},{"x":89,"y":47},{"x":132,"y":49}],"word":"民族汉","chars":[{"pos":[{"x":89,"y":47},{"x":102,"y":47},{"x":102,"y":63},{"x":89,"y":63}],"confidence":0.09217217634938077,"char":"民"},{"pos":[{"x":102,"y":47},{"x":114,"y":47},{"x":114,"y":63},{"x":102,"y":63}],"confidence":0.09340092631165517,"char":"族"},{"pos":[{"x":114,"y":47},{"x":127,"y":47},{"x":127,"y":63},{"x":114,"y":63}],"confidence":0.09088020316953409,"char":"汉"}]},{"prob":0.8024003505706787,"position":[{"x":61,"y":84},{"x":22,"y":84},{"x":22,"y":71},{"x":61,"y":72}],"word":"出生","chars":[{"pos":[{"x":23,"y":71},{"x":34,"y":71},{"x":34,"y":84},{"x":23,"y":84}],"confidence":0.07454915327918127,"char":"出"},{"pos":[{"x":35,"y":71},{"x":47,"y":71},{"x":47,"y":84},{"x":35,"y":84}],"confidence":0.0838299437269847,"char":"生"}]},{"prob":0.8024003505706787,"position":[{"x":159,"y":85},{"x":56,"y":86},{"x":56,"y":72},{"x":159,"y":71}],"word":"1654年12月20日","chars":[{"pos":[{"x":57,"y":71},{"x":63,"y":71},{"x":63,"y":86},{"x":57,"y":86}],"confidence":0.08048306484940677,"char":"1"},{"pos":[{"x":60,"y":71},{"x":66,"y":71},{"x":66,"y":86},{"x":60,"y":86}],"confidence":0.07077925460296725,"char":"6"},{"pos":[{"x":62,"y":71},{"x":68,"y":71},{"x":68,"y":86},{"x":62,"y":86}],"confidence":0.07927936587835137,"char":"5"},{"pos":[{"x":65,"y":71},{"x":71,"y":71},{"x":71,"y":86},{"x":65,"y":86}],"confidence":0.08434467112840616,"char":"4"},{"pos":[{"x":70,"y":71},{"x":76,"y":71},{"x":76,"y":86},{"x":70,"y":86}],"confidence":0.08105277973402224,"char":"年"},{"pos":[{"x":75,"y":71},{"x":81,"y":71},{"x":81,"y":86},{"x":75,"y":86}],"confidence":0.08495977211713442,"char":"1"},{"pos":[{"x":78,"y":71},{"x":84,"y":71},{"x":84,"y":86},{"x":78,"y":86}],"confidence":0.09189763192040779,"char":"2"},{"pos":[{"x":82,"y":71},{"x":88,"y":71},{"x":88,"y":86},{"x":82,"y":86}],"confidence":0.07305568947744293,"char":"月"},{"pos":[{"x":87,"y":71},{"x":93,"y":71},{"x":93,"y":86},{"x":87,"y":86}],"confidence":0.07719586748106957,"char":"2"},{"pos":[{"x":89,"y":71},{"x":95,"y":71},{"x":95,"y":86},{"x":89,"y":86}],"confidence":0.08392865783456832,"char":"0"},{"pos":[{"x":94,"y":71},{"x":100,"y":71},{"x":100,"y":86},{"x":94,"y":86}],"confidence":0.08628613377026872,"char":"日"}]},{"prob":0.7320006489753723,"position":[{"x":58,"y":108},{"x":22,"y":108},{"x":22,"y":97},{"x":58,"y":97}],"word":"住址","chars":[{"pos":[{"x":24,"y":97},{"x":34,"y":97},{"x":34,"y":108},{"x":24,"y":108}],"confidence":0.09009406955958693,"char":"住"},{"pos":[{"x":37,"y":97},{"x":47,"y":97},{"x":47,"y":108},{"x":37,"y":108}],"confidence":0.08240888515657947,"char":"址"}]},{"prob":0.7900686860084534,"position":[{"x":190,"y":108},{"x":55,"y":107},{"x":55,"y":97},{"x":190,"y":97}],"word":"北京市东城区景山前街4号","chars":[{"pos":[{"x":58,"y":97},{"x":66,"y":97},{"x":66,"y":108},{"x":58,"y":108}],"confidence":0.08713626978853328,"char":"北"},{"pos":[{"x":66,"y":97},{"x":75,"y":97},{"x":75,"y":108},{"x":66,"y":108}],"confidence":0.09658446442664059,"char":"京"},{"pos":[{"x":75,"y":97},{"x":82,"y":97},{"x":82,"y":108},{"x":75,"y":108}],"confidence":0.09711321959702555,"char":"市"},{"pos":[{"x":82,"y":97},{"x":89,"y":97},{"x":89,"y":108},{"x":82,"y":108}],"confidence":0.09856503984905221,"char":"东"},{"pos":[{"x":89,"y":97},{"x":96,"y":97},{"x":96,"y":108},{"x":89,"y":108}],"confidence":0.08821399269578022,"char":"城"},{"pos":[{"x":98,"y":97},{"x":106,"y":97},{"x":106,"y":108},{"x":98,"y":108}],"confidence":0.08318493837647765,"char":"区"},{"pos":[{"x":104,"y":97},{"x":112,"y":97},{"x":112,"y":108},{"x":104,"y":108}],"confidence":0.08305766109568175,"char":"景"},{"pos":[{"x":112,"y":97},{"x":119,"y":97},{"x":119,"y":108},{"x":112,"y":108}],"confidence":0.07607177167586324,"char":"山"},{"pos":[{"x":118,"y":97},{"x":126,"y":97},{"x":126,"y":108},{"x":118,"y":108}],"confidence":0.08421159482850636,"char":"前"},{"pos":[{"x":126,"y":97},{"x":133,"y":97},{"x":133,"y":108},{"x":126,"y":108}],"confidence":0.09308668400515782,"char":"街"},{"pos":[{"x":133,"y":97},{"x":141,"y":97},{"x":141,"y":108},{"x":133,"y":108}],"confidence":0.0723923305743872,"char":"4"},{"pos":[{"x":141,"y":97},{"x":148,"y":97},{"x":148,"y":108},{"x":141,"y":108}],"confidence":0.07152081204563109,"char":"号"}]},{"prob":0.6656411290168762,"position":[{"x":123,"y":128},{"x":56,"y":128},{"x":56,"y":116},{"x":123,"y":116}],"word":"紫禁城敬事房","chars":[{"pos":[{"x":56,"y":116},{"x":60,"y":116},{"x":60,"y":128},{"x":56,"y":128}],"confidence":0.09226816954953951,"char":"紫"},{"pos":[{"x":59,"y":116},{"x":63,"y":116},{"x":63,"y":128},{"x":59,"y":128}],"confidence":0.07426896576246664,"char":"禁"},{"pos":[{"x":63,"y":116},{"x":67,"y":116},{"x":67,"y":128},{"x":63,"y":128}],"confidence":0.09067550017265255,"char":"城"},{"pos":[{"x":66,"y":116},{"x":70,"y":116},{"x":70,"y":128},{"x":66,"y":128}],"confidence":0.0765029225688767,"char":"敬"},{"pos":[{"x":70,"y":116},{"x":74,"y":116},{"x":74,"y":128},{"x":70,"y":128}],"confidence":0.09292123645870534,"char":"事"},{"pos":[{"x":73,"y":116},{"x":77,"y":116},{"x":77,"y":128},{"x":73,"y":128}],"confidence":0.08314556446170798,"char":"房"}]},{"prob":0.7948694229125977,"position":[{"x":94,"y":167},{"x":24,"y":167},{"x":24,"y":157},{"x":94,"y":157}],"word":"公民身份证号码","chars":[{"pos":[{"x":25,"y":157},{"x":29,"y":157},{"x":29,"y":167},{"x":25,"y":167}],"confidence":0.08861113638800246,"char":"公"},{"pos":[{"x":28,"y":157},{"x":32,"y":157},{"x":32,"y":167},{"x":28,"y":167}],"confidence":0.08254439412470047,"char":"民"},{"pos":[{"x":32,"y":157},{"x":36,"y":157},{"x":36,"y":167},{"x":32,"y":167}],"confidence":0.08884088398096258,"char":"身"},{"pos":[{"x":35,"y":157},{"x":40,"y":157},{"x":40,"y":167},{"x":35,"y":167}],"confidence":0.07859658124232792,"char":"份"},{"pos":[{"x":39,"y":157},{"x":43,"y":157},{"x":43,"y":167},{"x":39,"y":167}],"confidence":0.08619067298610167,"char":"证"},{"pos":[{"x":43,"y":157},{"x":47,"y":157},{"x":47,"y":167},{"x":43,"y":167}],"confidence":0.08511877072698217,"char":"号"},{"pos":[{"x":46,"y":157},{"x":50,"y":157},{"x":50,"y":167},{"x":46,"y":167}],"confidence":0.09074754695507889,"char":"码"}]},{"prob":0.7320006489753723,"position":[{"x":254,"y":166},{"x":106,"y":166},{"x":106,"y":158},{"x":254,"y":158}],"word":"11204416541220243X","chars":[{"pos":[{"x":108,"y":158},{"x":116,"y":158},{"x":116,"y":166},{"x":108,"y":166}],"confidence":0.0711357259043661,"char":"1"},{"pos":[{"x":115,"y":158},{"x":124,"y":158},{"x":124,"y":166},{"x":115,"y":166}],"confidence":0.09493274829684896,"char":"1"},{"pos":[{"x":124,"y":158},{"x":133,"y":158},{"x":133,"y":166},{"x":124,"y":166}],"confidence":0.0901567424680299,"char":"2"},{"pos":[{"x":133,"y":158},{"x":142,"y":158},{"x":142,"y":166},{"x":133,"y":166}],"confidence":0.07465050410196451,"char":"0"},{"pos":[{"x":141,"y":158},{"x":149,"y":158},{"x":149,"y":166},{"x":141,"y":166}],"confidence":0.08667510833307837,"char":"4"},{"pos":[{"x":148,"y":158},{"x":157,"y":158},{"x":157,"y":166},{"x":148,"y":166}],"confidence":0.0864850438550479,"char":"4"},{"pos":[{"x":156,"y":158},{"x":165,"y":158},{"x":165,"y":166},{"x":156,"y":166}],"confidence":0.07474846232751661,"char":"1"},{"pos":[{"x":165,"y":158},{"x":173,"y":158},{"x":173,"y":166},{"x":165,"y":166}],"confidence":0.0851283759530122,"char":"6"},{"pos":[{"x":172,"y":158},{"x":181,"y":158},{"x":181,"y":166},{"x":172,"y":166}],"confidence":0.07180779276748162,"char":"5"},{"pos":[{"x":181,"y":158},{"x":190,"y":158},{"x":190,"y":166},{"x":181,"y":166}],"confidence":0.08309512465379258,"char":"4"},{"pos":[{"x":189,"y":158},{"x":198,"y":158},{"x":198,"y":166},{"x":189,"y":166}],"confidence":0.08760201548613727,"char":"1"},{"pos":[{"x":196,"y":158},{"x":205,"y":158},{"x":205,"y":166},{"x":196,"y":166}],"confidence":0.08620213212777092,"char":"2"},{"pos":[{"x":205,"y":158},{"x":214,"y":158},{"x":214,"y":166},{"x":205,"y":166}],"confidence":0.07708197697260562,"char":"2"},{"pos":[{"x":213,"y":158},{"x":222,"y":158},{"x":222,"y":166},{"x":213,"y":166}],"confidence":0.09455778959674814,"char":"0"},{"pos":[{"x":221,"y":158},{"x":229,"y":158},{"x":229,"y":166},{"x":221,"y":166}],"confidence":0.07772310130275195,"char":"2"},{"pos":[{"x":229,"y":158},{"x":238,"y":158},{"x":238,"y":166},{"x":229,"y":166}],"confidence":0.0836733998033232,"char":"4"},{"pos":[{"x":237,"y":158},{"x":246,"y":158},{"x":246,"y":166},{"x":237,"y":166}],"confidence":0.0832613556488638,"char":"3"},{"pos":[{"x":245,"y":158},{"x":254,"y":158},{"x":254,"y":166},{"x":245,"y":166}],"confidence":0.08408428869218577,"char":"X"}]}]}}}

Process finished with exit code 0
 

调用移动云OCR识别身份证

 识别成功,但是数据是混乱的,要清洗数据。

参考文献:

[1]使用SDK调用OCR服务 (10086.cn)

[2]移动云官网_云主机_云空间_CDN_云硬盘_云数据库 (10086.cn) 文章来源地址https://www.toymoban.com/news/detail-428224.html

到了这里,关于调用移动云OCR识别身份证的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 从0-1,使用腾讯OCR进行身份证识别

    目录 1.申请腾讯OCR权限 2.代码思路 3.Postman测试​  获取 secretId 和 secretKey,见上文 从0到1,申请cos服务器并上传图片到cos文件服务器-CSDN博客 https://blog.csdn.net/m0_55627541/article/details/133902798 入参有两个值,第一个为图片的云服务器路径,第二个为版面(正面/反面) controller servic

    2024年02月07日
    浏览(52)
  • Java集成腾讯云OCR身份证识别接口

            项目用到身份证识别获取人员信息的功能,于是想到了腾讯云提供这样的API。在整合代码过程都很顺利,利用腾讯云官方SDK很快集成进来。但是在上测试环境部署时有了新的问题,通过Nginx代理后的环境无法访问到目标腾讯云接口,遂有了如下的改造过程。        

    2024年02月08日
    浏览(47)
  • 实名制重要性、PHP身份实名认证示例、身份证ocr识别核验

    身份证丢失失,可能会被不法分子利用去贷款。虽然是被人冒名办理,客观上不承担责任,但会造成个人信用信息的困扰。因此,对于个人来讲,要妥善保管自己的身份证,避免不必要的麻烦。对于贷款机构来说,单纯的认证了身份证的真伪是不够的,还需要进行“身份认证

    2024年04月23日
    浏览(45)
  • 记录--如何在H5中实现OCR拍照识别身份证功能

    由于当前项目中需要实现身份证拍照识别的功能,如果是小程序可以使用微信提供的 ocr-navigator 插件实现,但是在企业微信的H5中没有提供该插件,所以需要手动实现该功能。 众所周知,前端H5中浏览器打开相机打开的是原生相机,无法在相机的界面上覆盖自定义的元素,比如

    2024年02月06日
    浏览(43)
  • 【合合TextIn】OCR身份证 / 银行卡识别功能适配鸿蒙系统

    目录 一、 鸿蒙系统与信创国产化的背景 二、两款产品的兼容性升级详情 三、身份证产品介绍 四、银行卡识别产品 五、承诺与展望 一、 鸿蒙系统与信创国产化的背景 自鸿蒙系统推出以来,其不仅成为了华为在软件领域的重要里程碑,更是国产操作系统的一面旗帜,也是国

    2024年04月10日
    浏览(55)
  • 调用华为API实现身份证识别

    雷千龙,男,西安工程大学电子信息学院,2022级研究生 研究方向:机器视觉与人工智能 电子邮件:2387360343@qq.com 张思怡,女,西安工程大学电子信息学院,2022级研究生,张宏伟人工智能课题组 研究方向:机器视觉与人工智能 电子邮件:981664791@qq.com 2.1.1OCR简介 OCR (Optica

    2024年02月06日
    浏览(36)
  • 微信小程序OCR插件,实现身份证、行驶证、银行卡、营业执照和驾驶证等识别

    随着科技的不断发展,图片识别技术已经成为了当下移动互联网中的热点话题。而基于微信小程序和 OCR 插件的图文识别方案,更是成为了越来越多小程序开发者关注和研究的问题。本文中,我将为大家介绍微信小程序 OCR 插件,帮助大家实现身份证、行驶证、银行卡、营业执

    2024年02月08日
    浏览(83)
  • 身份证实名接口和身份证OCR接口的组合使用

    随着网络技术的快速发展以及对个人信息保护意识的提升,身份证实名认证已成为诸多在线业务中不可或缺的一环。身份证实名接口与身份证OCR接口的有机结合,为用户提供了一种快速、精准、安全的身份信息核验方式。 首先,用户在应用程序或网站界面上传其身份证正反两

    2024年04月26日
    浏览(57)
  • uniapp - 安卓|苹果App软件实现调用百度人脸识别接口服务及人脸活体认证功能,uniapp苹果ios、安卓Android手机app平台,人脸认证、活体检测、身份证与人脸验证(示例代码,一键复制

    在uniapp手机App开发中(安卓Android|苹果ios系统),利用百度人脸识别api接口对接uniapp APP进行人脸识别、人脸检测、活体验证、人脸对比、人脸搜索、身份证信息是否与人脸匹配,支持离线SDK集成、离线无网络正常使用功能、自定义人脸识别框附近的页面样式和大小等。 提供详

    2024年04月11日
    浏览(68)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包