Day2,身份证识别web应用
操作的时候基本在搬运大佬编好的代码,因为自己很多东西都还不懂,就放个流程。
比较不幸的是我开通服务失败,所以没办法验证……
环境准备:java,maven,idea
功能实现逻辑流程:
·用户在页面上传身份证正反面照片
·前端将照片发送至后端,并保存到本地
·后端调用VIAPI 的 SDK,参数是本地的照片文件,得到算法识别的返回结果。
·后端将识别结果返回给前端·前端连同上传的照片和ocr识别结果展示在界面上供用户查看和检查。
1、进入视觉智能开放平台官网 https://vision.aliyun.com/,以找到身份证识别项,点击 SDK 参考,找到新的支持本地上传图片的Java SDK,进入相应的说明页,后获取需要的 Maven 坐标。
2、通过在 pom.xml文件中添加Maven依赖安装 java SDK,获取视觉智能开放平台提供的SDK源代码下载地址:https://github.com/aliyun/alibabacloud-viapi-demo/tree/master/identity-card-demo
3、前端代码
<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <title>VIAPI</title> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script></head><body> <div class="container"> <div class="row"> <div class="col-md-12 mx-auto"> <h2>VIAPI RecognizeIdentityCard Example</h2> <div class="col-sm-12"> <p th:text="${message}" th:if="${message ne null}" class="alert alert-primary"></p> </div> <form method="post" th:action="@{/upload}" enctype="multipart/form-data"> <div class="col-sm-4"> <div class="input-group"> <input id='location' class="form-control" onclick="$('#i-face').click();"> <label class="input-group-btn"> <input type="button" id="i-check" value="上传人像面" class="btn btn-primary" onclick="$('#i-face').click();"> </label> </div> </div> <input type="file" name="face" id='i-face' accept=".jpg, .png, .jpeg" onchange="$('#location').val($('#i-face').val());" style="display: none"> <div class="col-sm-4"> <div class="input-group"> <input id='location1' class="form-control" onclick="$('#i-back').click();"> <label class="input-group-btn"> <input type="button" id="i-check-1" value="上传国徽面" class="btn btn-primary" onclick="$('#i-back').click();"> </label> </div> </div> <input type="file" name="back" id='i-back' accept=".jpg, .p