澳门身份证识别接口

接口描述

用户通过发送HTTP Post请求方式提交数据至公有云服务器,服务器识别并返回json格式的识别结果。

接口说明

请求URL:http://api.exocr.com/ocr/v1/macau_id_card

请求方式:HTTP Post

返回格式:json

参数
Content-Type 使用二进制方式时,为multipart/form-data;使用base64和url方式时,为application/x-www-form-urlencoded

请求参数

参数 必选 类型 说明
app_key string 请在控制台->我的应用中获取
app_secret string 请在控制台->我的应用中获取
image_base64 string 图像base64编码。image_base64、image_url、image_binary三个参数中至少选择一个,读取优先级从前到后依次降低。如:同时选择了以上三个参数,则以image_base64图像为准。
image_url string 图像url地址。image_base64、image_url、image_binary三个参数中至少选择一个,读取优先级从前到后依次降低。如:同时选择了以上三个参数,则以image_base64图像为准。
image_binary data 图像二进制。image_base64、image_url、image_binary三个参数中至少选择一个,读取优先级从前到后依次降低。如:同时选择了以上三个参数,则以image_base64图像为准。

返回结果

字段 说明 类型 备注
error_code 错误码 Int 0:正确,1:无法识别,2:图像格式错误
description 结果描述 String
request_id 唯一请求标识符 String 用于回溯问题
recognize_time 识别所用时间 Int 毫秒为单位
result 识别结果列表 Array
issue_date 发证日期 Array
name 姓名 Array
sex 性别 Array
expire_date 有效期至 Array
birth_date 出生日期 Array
first_issue_date 初次发证日期 Array
height 身高 Array
Id 身份证号 Array
words 识别结果 String utf-8格式
score 照片可信度 Float 取值范围为0~1
position 位置矩形框 Array 以左上角为基准,距离左侧,上侧,右侧矩形框长度,下侧矩形框长度
left 位置值 Int 距离原图左侧距离x,单位为像素
top 位置值 Int 距离原图上方距离y,单位为像素
width 位置值 Int 字段所在图框宽度w,单位为像素
quad 四个顶点坐标 String 所在区域的四个点,依次为左上,右上,右下,左下四个点的坐标值
chinese_key 该字段中文含义 String
available_count 识别剩余可用次数 Int 次数不足时无法继续识别,可在控制台进行充值次数
english_name 英文姓名 Object
code 电码 Object
id_mark 证件标记 Object

调用示例

java(相关依赖库下载)

package com.exocr.httpclient;



import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStream;

import java.util.HashMap;

import java.util.Map;



import com.exocr.common.utils.HttpClientUtils;



public class Test {



   public static void main(String[] args) throws FileNotFoundException {

      /**

       * base64

       */

      //识别url

      String url = " http://api.exocr.com/ocr/v1/macau_id_card";

      //设置请求参数

      Map<String, String> params = new HashMap<String, String>();

      params.put("app_key", "#####");

      params.put("app_secret", "#####");

      //设置识别图像base64编码

      params.put("image_base64", "base64ImageStr");

      //发送请求,得到识别结果

      String result = HttpClientUtils.doPost(url, params);

      System.out.println(result);

      /**

       * url

       */

      //设置请求参数、识别图像url

      params.put("app_key", "#####");

      params.put("app_secret", "#####");

      params.put("image_url", "imageUrl");

      //发送请求,得到识别结果

      result = HttpClientUtils.doPost(url, params);

      System.out.println(result);

      /**

       * 二进制

       */

      //设置请求参数

      params.put("app_key", "#####");

      params.put("app_secret", "#####");

      //拿到本地图像,写入数据流

      File file = new File("/Users/mac/logs/test.png");

      InputStream in = new FileInputStream(file);

      //设置数据流

      Map<String, InputStream> streamMap = new HashMap<String, InputStream>();

      streamMap.put("image_binary", in);

      //发送请求,得到识别结果

      result = HttpClientUtils.doPostStream(url, params, streamMap);

      //关闭io流

      try {

         in.close();

      } catch (IOException e) {

         e.printStackTrace();

      }

      System.out.println(result);

   }

}

返回结果示例


{
  "description":"识别成功",
  "error_code":0,
  "result":{
  "issue_date":{
  "position":{},
  "score":1.0,
  "words":"15-08-2012"
  },
  "name":{…},
  "sex":{…},
  "expire_date":{…},
  "birth_date":{…},
  "first_issue_date":{…},
  "height":{…},
  "id":{…}},
  "request_id":"cc181ce01fdb11eab0f6fa163e375239",
  "recognize_time":1261,
  "dbg_xml":""
}
Copyright © 2020 易道博识 all right reserved,powered by Gitbook该文件修订时间: 2023-12-04 14:10:10

results matching ""

    No results matching ""