百度身份证识别,超级准确,全部信息能识别

import java.io.File;
import java.util.HashMap;


import org.json.JSONObject;


import com.baidu.aip.ocr.AipOcr;

public class test {

public static void main(String[] args) throws Exception {
        Tesseract("/1.png");
        getId();
    }
   
public static void getId(){
String fileName = "";
String realPath = "d:\\1.png";//request.getRealPath(fileName);
//识别图片
AipOcr aipOcr = new AipOcr("10334326", "GMyO1iwnnxPHdSkpuEEEvOAs", "N2VqvVd1AkFPEbVPYL0rGlWPnWxQZT97");
JSONObject result = aipOcr.idcard(realPath, true, new HashMap());
System.err.println(result);

}

}


代码简单,引入一个包即可,


返回结果:{"log_id":7858030615587141314,"words_result":{"姓名":{"words":"百度熊","location":{"top":35,"left":82,"width":58,"height":19}},"民族":{"words":"汉","location":{"top":76,"left":172,"width":13,"height":15}},"住址":{"words":"北京市海淀区上地十号七栋2单元110室","location":{"top":150,"left":78,"width":197,"height":37}},"公民身份号码":{"words":"532101198906010015","location":{"top":243,"left":141,"width":251,"height":15}},"出生":{"words":"19890601","location":{"top":0,"left":0,"width":0,"height":0}},"性别":{"words":"男","location":{"top":76,"left":71,"width":21,"height":16}}},"words_result_num":6,"image_status":"normal","direction":0}

你可能感兴趣的:(java基础)