搜索本产品文档关键词
接口调用说明
所有文档
menu

文字识别

接口调用说明

OCR-UI模块

OCR-UI模块提供了一套默认的UI。如需使用,请将ocr_ui模块包含到您的工程,具体使用可参考SDK包中附带的示例工程。

OCR-UI模块调用示例

调用拍摄activity,更详细的类别请参考demo工程。

Plain Text
1// 生成intent对象
2Intent intent = new Intent(IDCardActivity.this, CameraActivity.class);
3
4// 设置临时存储
5intent.putExtra(CameraActivity.KEY_OUTPUT_FILE_PATH,                     FileUtil.getSaveFile(getApplication()).getAbsolutePath());
6
7// 调用除银行卡,身份证等识别的activity
8intent.putExtra(CameraActivity.KEY_CONTENT_TYPE, CameraActivity.CONTENT_TYPE_GENERAL);
9startActivityForResult(intent, REQUEST_CODE_CAMERA);
10// 通过参数确定接口类型
11startActivityForResult(intent, REQUEST_CODE_GENERAL_BASIC);
12
13// 调用拍摄银行卡的activity
14intent.putExtra(CameraActivity.KEY_CONTENT_TYPE, CameraActivity.CONTENT_TYPE_BANK_CARD);
15startActivityForResult(intent, REQUEST_CODE_CAMERA);
16
17// 调用拍摄身份证正面(不带本地质量控制)activity
18intent.putExtra(CameraActivity.KEY_CONTENT_TYPE, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT);
19startActivityForResult(intent, REQUEST_CODE_CAMERA);
20
21// 调用身份证本识别(带本地质量控制)activity
22 Intent intent = new Intent(IDCardActivity.this, CameraActivity.class);
23// 使用本地质量控制能力需要授权,需要在OCR调用initAccessToken或者
24// initAccessTokenWithAkSk成功返回后才能获取License授权本地质量控制能力
25intent.putExtra(CameraActivity.KEY_NATIVE_TOKEN,
26                        OCR.getInstance().getLicense());
27// 使用本地质量控制能力需要设置开启
28intent.putExtra(CameraActivity.KEY_NATIVE_ENABLE,
29                        true);
30// 开启身份证正面本地识别                    
31intent.putExtra(CameraActivity.KEY_CONTENT_TYPE, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT);

通过onActivityResult获取拍摄结果,更详细的类别请参考demo工程。

Plain Text
1@Override
2protected void onActivityResult(int requestCode, int resultCode, Intent data) {
3    // 获取调用参数
4    String contentType = data.getStringExtra(CameraActivity.KEY_CONTENT_TYPE);
5    // 通过临时文件获取拍摄的图片
6    String filePath = FileUtil.getSaveFile(getApplicationContext()).getAbsolutePath();
7    // 判断拍摄类型(通用,身份证,银行卡等)
8    if (requestCode == REQUEST_CODE_GENERAL && resultCode == Activity.RESULT_OK) {
9    // 判断是否是身份证正面
10        if (CameraActivity.CONTENT_TYPE_ID_CARD_FRONT.equals(contentType)){
11        // 获取图片文件调用sdk数据接口,见数据接口说明
12        }
13    }
14}

数据接口

通用文字识别

  • 调用示例

    // 通用文字识别参数设置 GeneralBasicParams param = new GeneralBasicParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务 OCR.getInstance().recognizeGeneralBasic(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { // 调用成功,返回GeneralResult对象 for (WordSimple wordSimple : result.getWordList()) { // wordSimple不包含位置信息 wordSimple word = wordSimple; sb.append(word.getWords()); sb.append("\n"); } // json格式返回字符串 listener.onResult(result.getJsonRes()); } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
language_type false string CHN_ENG、ENG、POR、FRE、GER、ITA、SPA、RUS、JAP 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language FALSE string true、false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
+words string 识别结果字符串
JSON
1// 示例
2返回格式参考通用文字识别

通用文字识别(高精度版)

  • 调用示例

    // 通用文字识别参数设置 GeneralBasicParams param = new GeneralBasicParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务 OCR.getInstance().recognizeAccurateBasic(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { // 调用成功,返回GeneralResult对象 for (WordSimple wordSimple : result.getWordList()) { // wordSimple不包含位置信息 wordSimple word = wordSimple; sb.append(word.getWords()); sb.append("\n"); } // json格式返回字符串 listener.onResult(result.getJsonRes()); } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
+words string 识别结果字符串
JSON
1// 示例
2{
3"log_id": 2471272194, 
4"words_result_num": 2,
5"words_result": 
6    [
7        {"words": " TSINGTAO"}, 
8        {"words": "青島睥酒"}
9    ]
10}

通用文字识别(含位置信息版)

  • 调用示例

    // 通用文字识别参数设置 GeneralParams param = new GeneralParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务(含位置信息版) OCR.getInstance().recognizeGeneral(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { StringBuilder sb = new StringBuilder(); for (WordSimple wordSimple : result.getWordList()) { // word包含位置 Word word = (Word) wordSimple; sb.append(word.getWords()); sb.append("\n"); } // 调用成功,返回GeneralResult对象,通过getJsonRes方法获取API返回字符串 listener.onResult(result.getJsonRes()); } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过1M,最短边至少15px,最长边最大2048px,支持jpg/png/bmp格式
recognize_granularity false string big、small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
language_type false string CHN_ENG、ENG、POR、FRE、GER、ITA、SPA、RUS、JAP 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language false string true、false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
vertexes_location false string true、false 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result array() 定位和识别结果数组
words_result_num uint32 识别结果数,表示words_result的元素个数
+vertexes_location array() 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在
++x uint32 水平坐标(坐标0点为左上角)
++y uint32 垂直坐标(坐标0点为左上角)
+location array() 位置数组(坐标0点为左上角)
++left uint32 表示定位位置的长方形左上顶点的水平坐标
++top uint32 表示定位位置的长方形左上顶点的垂直坐标
++width uint32 表示定位位置的长方形的宽度
++height uint32 表示定位位置的长方形的高度
+words string 识别结果字符串
+chars array() 单字符结果,recognize_granularity=small时存在
++location array() 位置数组(坐标0点为左上角)
+++left uint32 表示定位位置的长方形左上顶点的水平坐标
+++top uint32 表示定位位置的长方形左上顶点的垂直坐标
+++width uint32 表示定位定位位置的长方形的宽度
+++height uint32 表示位置的长方形的高度
++char string 单字符识别结果
JSON
1// 示例
2{
3    direction : 2,
4    log_id : 676709620,
5    words_result : [ {
6            location : {
7                height : 20;
8                left : 86;
9                top : 387;
10                width : 22;
11            };
12            words : "N";
13        },
14    ],
15    words_result_num : 1;
16}

通用文字识别(高精度含位置信息版)

  • 调用示例

    // 通用文字识别参数设置 GeneralParams param = new GeneralParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务(含位置信息版) OCR.getInstance().recognizeAccurate(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { StringBuilder sb = new StringBuilder(); for (WordSimple wordSimple : result.getWordList()) { // word包含位置 Word word = (Word) wordSimple; sb.append(word.getWords()); sb.append("\n"); } // 调用成功,返回GeneralResult对象,通过getJsonRes方法获取API返回字符串 listener.onResult(result.getJsonRes()); } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过1M,最短边至少15px,最长边最大2048px,支持jpg/png/bmp格式
vertexes_location false string true、false 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false
recognize_granularity false string big、small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result array() 定位和识别结果数组
words_result_num uint32 识别结果数,表示words_result的元素个数
+vertexes_location array() 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在
++x uint32 水平坐标(坐标0点为左上角)
++y uint32 垂直坐标(坐标0点为左上角)
+location array() 位置数组(坐标0点为左上角)
++left uint32 表示定位位置的长方形左上顶点的水平坐标
++top uint32 表示定位位置的长方形左上顶点的垂直坐标
++width uint32 表示定位位置的长方形的宽度
++height uint32 表示定位位置的长方形的高度
+words string 识别结果字符串
+chars array() 单字符结果,recognize_granularity=small时存在
++location array() 位置数组(坐标0点为左上角)
+++left uint32 表示定位位置的长方形左上顶点的水平坐标
+++top uint32 表示定位位置的长方形左上顶点的垂直坐标
+++width uint32 表示定位定位位置的长方形的宽度
+++height uint32 表示位置的长方形的高度
++char string 单字符识别结果
JSON
1// 返回结果参考通用文字识别(含位置信息版)

通用文字识别(含生僻字版)

  • 调用示例

    // 通用文字识别(含生僻字版)参数设置 GeneralBasicParams param = new GeneralBasicParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务 OCR.getInstance().recognizeGeneralEnhanced(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { // 调用成功,返回GeneralResult对象 for (WordSimple wordSimple : result.getWordList()) { // wordSimple不包含位置信息 wordSimple word = wordSimple; sb.append(word.getWords()); sb.append("\n"); } } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
language_type false string CHN_ENG、ENG、POR、FRE、GER、ITA、SPA、RUS、JAP 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language FALSE string true、false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
+words string 识别结果字符串
JSON
1// 示例
2参考通用文字识别接口

网络图片文字识别

  • 调用示例

    // 网络图片文字识别参数设置 GeneralBasicParams param = new GeneralBasicParams(); param.setDetectDirection(true); param.setImageFile(new File(filePath));

    // 调用通用文字识别服务 OCR.getInstance().recognizeWebimage(param, new OnResultListener() { @Override public void onResult(GeneralResult result) { // 调用成功,返回GeneralResult对象 for (WordSimple wordSimple : result.getWordList()) { // wordSimple不包含位置信息 wordSimple word = wordSimple; sb.append(word.getWords()); sb.append("\n"); } } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数详情

参数
是否必选
类型
可选值范围
说明
image true string - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
detect_direction false boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language false string true、false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
  • 结果返回
字段
必选
类型
说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
+words string 识别结果字符串
JSON
1// 示例
2参考通用文字识别接口

银行卡识别

  • 调用示例

    // 银行卡识别参数设置 BankCardParams param = new BankCardParams(); param.setImageFile(new File(filePath));

    // 调用银行卡识别服务 OCR.getInstance().recognizeBankCard(param, new OnResultListener() { @Override public void onResult(BankCardResult result) { // 调用成功,返回BankCardResult对象 } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

  • 结果返回
参数
类型
描述
log_id Uint64 唯一的log id,用于问题定位
result Object 定位和识别结果数组
+bank_card_number String 银行卡识别结果
+bank_name String 银行名,不能识别时为空
+bank_card_type uint32 银行卡类型,0:不能识别; 1: 借记卡; 2: 信用卡
JSON
1 // 示例
2 {
3    "log_id": 3207866271;
4    result: {
5        "bank_card_number": "6226 2288 8888 8888",
6        "bank_card_type": 1,
7        "bank_name": "\U5de5\U5546\U94f6\U884c"
8    };
9}

身份证识别

  • 调用示例

    // 身份证识别参数设置 IDCardParams param = new IDCardParams(); param.setImageFile(new File(filePath));

    // 调用身份证识别服务 OCR.getInstance().recognizeIDCard(param, new OnResultListener() { @Override public void onResult(IDCardResult result) { // 调用成功,返回IDCardResult对象 } @Override public void onError(OCRError error) { // 调用失败,返回OCRError对象 } });

options参数

参数
必选
范围
类型
说明
image true String 图像数据,支持本地图像文件路径,图像文件二进制数据,要求base64编码后大小不超过1M,最短边至少15px,最长边最大2048px,支持jpg/png/bmp格式
isFront true true、false Boolean true:身份证正面,false:身份证背面
detect_direction false true、false string 是否检测图像朝向,默认不检测,即:false。可选值为:true - 检测图像朝向;false - 不检测图像朝向。朝向是指输入图像是正常方向、逆时针旋转90/180/270度
accuracy false auto、normal、high string 精准度,精度越高,速度越慢。default:auto
  • 结果返回
参数
类型
描述
direction Int32 图像方向,当detect_direction=true时存在。-1:未定义,0:正向,1: 逆时针90度, 2:逆时针180度, 3:逆时针270度
log_id Uint64 唯一的log id,用于问题定位
words_result Array 定位和识别结果数组,数组元素的key是身份证的主体字段(正面支持:住址、公民身份号码、出生、姓名、性别、民族,背面支持:签发机关、签发日期、失效日期)。只返回识别出的字段。若身份证号码校验不通过,则不返回
words_result_num Uint32 识别结果数,表示words_result的元素个数
+location Array 位置数组(坐标0点为左上角)
++left Uint32 表示定位位置的长方形左上顶点的水平坐标
++top Uint32 表示定位位置的长方形左上顶点的垂直坐标
++width Uint32 表示定位位置的长方形的宽度
++height Uint32 表示定位位置的长方形的高度
+words String 识别结果字符串
JSON
1//示例
2{
3    "log_id": 7037721,
4    "direction": 0,
5    "words_result_num": 2,
6    "words_result": {
7        "住址": {
8            "location": {
9                "left": 227,
10                "top": 235,
11                "width": 229,
12                "height": 51
13            },
14            "words": "湖北省天门市渔薪镇杨咀村一组2号",
15        }
16        ...
17    }
18}

行驶证识别

  • 调用示例

    // 行驶证识别参数设置 OcrRequestParams param = new OcrRequestParams();

    // 设置image参数 param.setImageFile(new File(filePath)); // 设置其他参数 param.putParam("detect_direction", true); // 调用行驶证识别服务 OCR.getInstance().recognizeVehicleLicense(param, new OnResultListener() { @Override public void onResult(OcrResponseResult result) { // 调用成功,返回OcrResponseResult对象 listener.onResult(result.getJsonRes()); }

    Plain Text
    1@Override
    2public void onError(OCRError error) {
    3    // 调用失败,返回OCRError对象
    4}

    });

options参数

参数
是否必选
类型
可选值范围
说明
image File对象 - 图像数据, 要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
detect_direction boolean true/false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:- true:检测朝向;- false:不检测朝向。
vehicle_license_side string front/back - front:默认值,识别行驶证主页
- back:识别行驶证副页
unified string true/false - false:默认值,不进行归一化处理
- true:对输出字段进行归一化处理,将新/老版行驶证的“注册登记日期/注册日期”统一为”注册日期“进行输出
  • 结果返回
字段
说明
是否必选
类型
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array 识别结果数组
+words string 识别结果字符串
JSON
1//示例
2{
3	"errno": 0,
4	"msg": "success",
5	"data": {
6		"words_result_num": 10,
7		"words_result": {
8			"品牌型号": {
9				"words": "保时捷GT37182RUCRE"
10			},
11			"发证日期": {
12				"words": "20160104"
13			},
14			"使用性质": {
15				"words": "非营运"
16			},
17			"发动机号码": {
18				"words": "20832"
19			},
20			"号牌号码": {
21				"words": "苏A001"
22			},
23			"所有人": {
24				"words": "圆圆"
25			},
26			"住址": {
27				"words": "南京市江宁区弘景大道"
28			},
29			"注册日期": {
30				"words": "20160104"
31			},
32			"车辆识别代号": {
33				"words": "HCE58"
34			},
35			"车辆类型": {
36				"words": "小型轿车"
37			}
38		}
39	}
40}

驾驶证识别

  • 调用示例

    // 驾驶证识别参数设置 OcrRequestParams param = new OcrRequestParams();

    // 设置image参数 param.setImageFile(new File(filePath)); // 设置其他参数 param.putParam("detect_direction", true); // 调用驾驶证识别服务 OCR.getInstance().recognizeDrivingLicense(param, new OnResultListener() { @Override public void onResult(OcrResponseResult result) { // 调用成功,返回OcrResponseResult对象 listener.onResult(result.getJsonRes()); }

    Plain Text
    1@Override
    2public void onError(OCRError error) {
    3    // 调用失败,返回OCRError对象
    4}

    });

options参数

参数
必选
类型
可选值范围
说明
image File对象 - 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
detect_direction boolean true、false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:- true:检测朝向;- false:不检测朝向。
  • 结果返回
字段
必选
类型
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array 识别结果数组
+words string 识别结果字符串
JSON
1//示例
2{
3	"errno": 0,
4	"msg": "success",
5	"data": {
6		"words_result_num": 10,
7		"words_result": {
8			"证号": {
9				"words": "3208231999053090"
10			},
11			"有效期限": {
12				"words": "6年"
13			},
14			"准驾车型": {
15				"words": "B2"
16			},
17			"有效起始日期": {
18				"words": "20101125"
19			},
20			"住址": {
21				"words": "江苏省南通市海门镇秀山新城"
22			},
23			"姓名": {
24				"words": "小欧欧"
25			},
26			"国籍": {
27				"words": "中国"
28			},
29			"出生日期": {
30				"words": "19990530"
31			},
32			"性别": {
33				"words": "男"
34			},
35			"初次领证日期": {
36				"words": "20100125"
37			}
38		}
39	}
40}

车牌识别

  • 调用示例

    // 车牌识别参数设置 OcrRequestParams param = new OcrRequestParams();

    // 设置image参数 param.setImageFile(new File(filePath));

    // 调用车牌识别服务 OCR.getInstance().recognizeLicensePlate(param, new OnResultListener() { @Override public void onResult(OcrResponseResult result) { // 调用成功,返回OcrResponseResult对象 listener.onResult(result.getJsonRes()); }

    Plain Text
    1@Override
    2public void onError(OCRError error) {
    3    // 调用失败,返回OCRError对象
    4}

    });

options参数

参数
必选
类型
可选值范围
说明
image File对象 - 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
参数
是否必须
类型
说明
log_id number 请求标识码,随机数,唯一
words_result object 暴恐结果置信度
+color string 车牌颜色,如"blue"
+number string 车牌号码,示例:"苏HS7766"
JSON
1//示例
2{
3  "words_result":{
4     "color":"blue",
5     "number":"粤FQ0000"
6  },
7  "log_id":2783673432
8}

营业执照识别

  • 调用示例

    // 营业执照识别参数设置 OcrRequestParams param = new OcrRequestParams();

    // 设置image参数 param.setImageFile(new File(filePath));

    // 调用营业执照识别服务 OCR.getInstance().recognizeBusinessLicense(param, new OnResultListener() { @Override public void onResult(OcrResponseResult result) { listener.onResult(result.getJsonRes()); }

    Plain Text
    1@Override
    2public void onError(OCRError error) {
    3    listener.onResult(error.getMessage());
    4}

    });

options参数

参数
必选
类型
可选值范围
说明
image File对象 - 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
参数
是否必须
类型
说明
log_id uint64 请求标识码,随机数,唯一。
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 识别结果数组
left uint32 表示定位位置的长方形左上顶点的水平坐标
top uint32 表示定位位置的长方形左上顶点的垂直坐标
width uint32 表示定位位置的长方形的宽度
height uint32 表示定位位置的长方形的高度
words string 识别结果字符串
JSON
1//示例
2{
3    "log_id": 490058765,
4    "words_result": {
5        "单位名称": {
6            "location": {
7                "left": 500,
8                "top": 479,
9                "width": 618,
10                "height": 54
11            },
12            "words": "袁氏财团有限公司"
13        },
14        "法人": {
15            "location": {
16                "left": 938,
17                "top": 557,
18                "width": 94,
19                "height": 46
20            },
21            "words": "袁运筹"
22        },
23        "地址": {
24            "location": {
25                "left": 503,
26                "top": 644,
27                "width": 574,
28                "height": 57
29            },
30            "words": "江苏省南京市中山东路19号"
31        },
32        "有效期": {
33            "location": {
34                "left": 779,
35                "top": 1108,
36                "width": 271,
37                "height": 49
38            },
39            "words": "2015年02月12日"
40        },
41        "证件编号": {
42            "location": {
43                "left": 1219,
44                "top": 357,
45                "width": 466,
46                "height": 39
47            },
48            "words": "苏餐证字(2019)第666602666661号"
49        },
50        "社会信用代码": {
51            "location": {
52                "left": 0,
53                "top": 0,
54                "width": 0,
55                "height": 0
56            },
57            "words": "无"
58        }
59    },
60    "words_result_num": 6
61}

通用票据识别

  • 调用示例

    // 通用票据识别参数设置 OcrRequestParams param = new OcrRequestParams();

    // 设置image参数 param.setImageFile(new File(filePath));

    // 设置额外参数 param.putParam("detect_direction", "true");

    // 调用通用票据识别服务 OCR.getInstance().recognizeReceipt(param, new OnResultListener() { @Override public void onResult(OcrResponseResult result) { listener.onResult(result.getJsonRes()); }

    Plain Text
    1@Override
    2public void onError(OCRError error) {
    3    listener.onResult(error.getMessage());
    4}

    });

options参数

参数
必选
类型
可选值范围
说明
image File对象 - 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
recognize_granularity false string big、small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
probability false string true、false 是否返回识别结果中每一行的置信度
accuracy false string normal,缺省 normal 使用快速服务;缺省或其它值使用高精度服务
detect_direction false string true、false 是否检测图像朝向,默认不检测,即:false。可选值包括true - 检测朝向;false - 不检测朝向。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。
  • 结果返回
字段
是否必选
类型
说明
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
location object 位置数组(坐标0点为左上角)
left uint32 表示定位位置的长方形左上顶点的水平坐标
top uint32 表示定位位置的长方形左上顶点的垂直坐标
width uint32 表示定位位置的长方形的宽度
height uint32 表示定位位置的长方形的高度
words string 识别结果字符串
chars array() 单字符结果,recognize_granularity=small时存在
location array() 位置数组(坐标0点为左上角)
left uint32 表示定位位置的长方形左上顶点的水平坐标
top uint32 表示定位位置的长方形左上顶点的垂直坐标
width uint32 表示定位定位位置的长方形的宽度
height uint32 表示位置的长方形的高度
char string 单字符识别结果
probability object 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值
Plain Text
1{
2    "log_id": 2661573626,
3    "words_result": [
4        {
5            "location": {
6                "left": 10,
7                "top": 3,
8                "width": 121,
9                "height": 24
10            },
11            "words": "姓名:小明明",
12            "chars": [
13                {
14                    "location": {
15                        "left": 16,
16                        "top": 6,
17                        "width": 17,
18                        "height": 20
19                    },
20                    "char": "姓"
21                },
22                {
23                    "location": {
24                        "left": 35,
25                        "top": 6,
26                        "width": 17,
27                        "height": 20
28                    },
29                    "char": "名"
30                },
31                {
32                    "location": {
33                        "left": 55,
34                        "top": 6,
35                        "width": 11,
36                        "height": 20
37                    },
38                    "char": ":"
39                },
40                {
41                    "location": {
42                        "left": 68,
43                        "top": 6,
44                        "width": 17,
45                        "height": 20
46                    },
47                    "char": "小"
48                },
49                {
50                    "location": {
51                        "left": 87,
52                        "top": 6,
53                        "width": 17,
54                        "height": 20
55                    },
56                    "char": "明"
57                },
58                {
59                    "location": {
60                        "left": 107,
61                        "top": 6,
62                        "width": 17,
63                        "height": 20
64                    },
65                    "char": "明"
66                }
67            ]
68        }
69    ],
70    "words_result_num": 2
71}

增值税发票识别

  • 调用示例
Plain Text
1// 增值税发票识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3OCR.getInstance(ctx).recognizeVatInvoice(param, new OnResultListener<OcrResponseResult>() {
4    @Override
5    public void onResult(OcrResponseResult result) {
6        listener.onResult(result.getJsonRes());
7    }
8
9    @Override
10    public void onError(OCRError error) {
11        listener.onResult(error.getMessage());
12    }
13});
14参数
15Image  是   File对象	 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
type string 可选值:normal/roll
进行识别的增值税发票类型,默认为 normal,可缺省
- normal:可识别增值税普票、专票、电子发票
- roll:可识别增值税卷票
seal_tag string 可选值:true/false
是否开启印章判断功能,并返回印章内容的识别结果
- true:开启
- false:不开启
  • 结果返回
Plain Text
1{
2  "words_result": {
3    "AmountInWords": "",
4    "InvoiceNumConfirm": "16486500",
5    "CommodityPrice": [],
6    "NoteDrawer": "",
7    "SellerAddress": "无北司列1",
8    "CommodityNum": [],
9    "SellerRegisterNum": "",
10    "MachineCode": "",
11    "Remarks": "",
12    "SellerBank": "",
13    "CommodityTaxRate": [],
14    "TotalTax": "",
15    "InvoiceCodeConfirm": "3200092140",
16    "CheckCode": "",
17    "InvoiceCode": "3200092140",
18    "InvoiceDate": "",
19    "PurchaserRegisterNum": "",
20    "InvoiceTypeOrg": "江苏增值税专用发票",
21    "Password": "北兴57号:仟5其江市无无3福南林东道街路12338411889949",
22    "Agent": "否",
23    "AmountInFiguers": "",
24    "PurchaserBank": "",
25    "Checker": "",
26    "City": "",
27    "TotalAmount": "",
28    "CommodityAmount": [],
29    "PurchaserName": "北温雄件科技电路规高有限公司",
30    "CommodityType": [],
31    "Province": "",
32    "InvoiceType": "专用发票",
33    "SheetNum": "",
34    "PurchaserAddress": "",
35    "CommodityTax": [],
36    "CommodityUnit": [],
37    "Payee": "",
38    "CommodityName": [],
39    "SellerName": "",
40    "InvoiceNum": "16486500"
41  },
42  "log_id": 1356821167419162624,
43  "words_result_num": 38
44}

出租车票

Plain Text
1// 出租车票识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用出租车发票识别服务
4OCR.getInstance(ctx).recognizeTaxireceipt(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1  "words_result": {
2    "Time": "",
3    "FuelOilSurcharge": "0.00",
4    "City": "",
5    "Date": "",
6    "Province": "",
7    "Fare": "",
8    "CallServiceSurcharge": "0.00",
9    "TotalFare": "",
10    "TaxiNum": "",
11    "PricePerkm": "",
12    "InvoiceCode": "",
13    "Distance": "",
14    "Location": "",
15    "InvoiceNum": ""
16  },
17  "log_id": 1356822535122976768,
18  "words_result_num": 14
19}

VIN码

  • 调用示例
Plain Text
1// VIN码识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用VIN码识别服务
4OCR.getInstance(ctx).recognizeVincode(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2  "words_result": [],
3  "log_id": 1356823413598978048,
4  "words_result_num": 0
5}

火车票

  • 调用示例
Plain Text
1// 火车票识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用火车票识别服务
4OCR.getInstance(ctx).recognizeTrainticket(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2  "words_result": {
3    "date": "",
4    "starting_station": "",
5    "ticket_num": "",
6    "train_num": "",
7    "ticket_rates": "",
8    "serial_number": "",
9    "seat_category": "",
10    "id_num": "",
11    "name": "",
12    "destination_station": "",
13    "time": "",
14    "sales_station": "",
15    "seat_num": ""
16  },
17  "log_id": 1356824154413727744,
18  "words_result_num": 13,
19  "direction": 3
20}

数字识别

  • 调用示例
Plain Text
1// 数字识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用数字识别服务
4OCR.getInstance(ctx).recognizeNumbers(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2  "log_id": 7693179126190465891,
3  "words_result_num": 2,
4  "words_result": [
5    {
6      "location": {
7        "width": 122,
8        "top": 17,
9        "left": 102,
10        "height": 28
11      },
12      "words": "0"
13    },
14    {
15      "location": {
16        "width": 430,
17        "top": 41,
18        "left": 2,
19        "height": 64
20      },
21      "words": "105"
22    }
23  ]
24}

二维码识别

  • 调用示例
Plain Text
1// 二维码识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用二维码识别服务 
4OCR.getInstance(ctx).recognizeQrcode(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2  "codes_result": [],
3  "codes_result_num": 0,
4  "log_id": 1423221291786076983
5}

飞机行程单

  • 调用示例
Plain Text
1// 行程单识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用行程单识别服务
4OCR.getInstance(ctx).recognizeTripTicket(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2    "log_id": 7306800033425229106,
3    "words_result_num": 18,
4    "words_result": {
5        "insurance": "20.00",
6        "date": "2019-10-22",
7        "allow": "20K",
8        "flight": "CA6589",
9        "issued_by": "中国国际航空服务有限公司",
10        "starting_station": "武汉",
11        "fare": "260.00",
12        "endorsement": "不得签转改期退转",
13        "ticket_rates": "350.00",
14        "ck": "5866",
15        "serial_number": "51523588676",
16        "ticket_number": "7843708871196",
17        "fuel_surcharge": "EXEMPT",
18        "carrier": "南航",
19        "issued_date": "2019-10-30",
20        "other_tax": "",
21        "fare_basis": "NREOW",
22        "id_num": "411201123909020877",
23        "destination_station": "合肥",
24        "name": "郭达",
25        "agent_code": "BJS19197300025",
26        "time": "21:25",
27        "class": "N",
28        "dev_fund": "50.00"
29    }
30}

机动车销售发票

  • 调用示例
Plain Text
1// 机动车销售发票识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用机动车销售发票识别服务
4OCR.getInstance(ctx).recognizeVehicleSellInvoice(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2    "log_id": 283449393728149457,
3    "words_result_num": 26,
4    "words_result": {
5        "InvoiceNum": "00875336",
6        "Saler": "深圳市新能源汽车销售有限公司",
7        "LimitPassenger": "5",
8        "MachineCode": "669745967911",
9        "VinNum": "LJLGTCRP1J4007581",
10        "TaxRate": "16%",
11        "PriceTaxLow": "106100.00",
12        "InvoiceDate": "2018-11-29",
13        "Price": "¥91465.52",
14        "SalerBank": "中国工商银行股份有限公司深圳岭园支行",
15        "TaxAuthor": "国家锐务总局深圳市龙岗区税务局第五税务所",
16        "ManuModel": "江淮牌HFC7007EYBD6",
17        "CertificateNum": "WCH0794J0976801",
18        "Purchaser": "苏子潇",
19        "VehicleType": "纯电动轿车",
20        "InvoiceCode": "14975047560",
21        "PriceTax": "壹拾万陆仟壹佰圆整",
22        "SalerPhone": "0755-83489306",
23        "SalerAddress": "深圳市龙岗区龙岗街道百世国际汽车城",
24        "Origin": "安徽省合肥市",
25        "EngineNum": "18958407",
26        "Tax": "14634.48",
27        "PurchaserCode": "5135934475603742222",
28        "TaxAuthorCode": "14037589413",
29        "SalerAccountNum": "中国工商银行股份有限公司深圳岭园支行",
30        "SalerCode": "9144928346458292278H"
31    }
32}

车辆合格证

  • 调用示例
Plain Text
1// 车辆合格证识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用车辆合格证识别服务
4OCR.getInstance(ctx).recoginzeVehicleCertificate(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数 | 字段 | 是否必选 | 类型 | 说明 | | ---------------- | ---- | ------- | ----------------------------------------------------------- | |Image|是 | File对象 | 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式|
  • 结果返回
Plain Text
1{
2    "log_id": 14814098736243057,
3    "words_result_num": 28,
4    "direction": 0,
5    "words_result": {
6        "ManufactureDate": "2016年10月13日",
7        "CarColor": "红",
8        "LimitPassenger": "2",
9        "EngineType": "WP12.460E50",
10        "TotalWeight": "25000",
11        "Power": "338",
12        "CertificationNo": "WEK29JX98645437",
13        "FuelType": "汽油",
14        "Manufacturer": "陕西汽车集团有限责任公司",
15        "SteeringType": "方向盘",
16        "Wheelbase": "3175+1350",
17        "SpeedLimit": "105",
18        "EngineNo": "1418K129178",
19        "SaddleMass": "8600",
20        "AxleNum": "3",
21        "CarModel": "SX4250MC4",
22        "VinNo": "LZGJHYD83JX197344",
23        "CarBrand": "陕汽牌",
24        "EmissionStandard": "GB17691-2005国V,GB3847-2005",
25        "Displacement": "11596",
26        "CertificateDate": "2018年11月28日",
27        "CarName": "牵引汽车",
28        "TyreNum": "10",
29        "ChassisID": "",
30        "ChassisModel": "",
31        "SeatingCapacity": "5",
32        "QualifySeal": "1",
33        "CGSSeal": "0"
34    }
35}

试卷分析与识别

  • 调用示例
Plain Text
1// 试卷分析与识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用试卷分析与识别服务
4OCR.getInstance(ctx).recognizeExampleDoc(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2	"results_num": 6,
3	"log_id": "4488766695474114139",
4	"img_direction": 0,
5	"layouts_num": 0,
6	"results": [
7		{
8			"words_type": "print",
9			"words": {
10				"words_location": {
11					"top": 124,
12					"left": 136,
13					"width": 418,
14					"height": 65
15				},
16				"word": "五默写(4分)"
17			},
18		},
19		{
20			"words_type": "handwriting",
21			"words": {
22				"words_location": {
23					"top": 195,
24					"left": 237,
25					"width": 469,
26					"height": 104
27				},
28				"word": "采菊东篱下"
29			},
30		},
31		{
32			"words_type": "print",
33			"words": {
34				"words_location": {
35					"top": 241,
36					"left": 889,
37					"width": 287,
38					"height": 52
39				},
40				"word": "悠然见南山"
41			},
42		}
43	]
44}

手写文字识别

  • 调用示例
Plain Text
1// 手写文字识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用手写文字识别服务
4OCR.getInstance(ctx).recognizeWrittenText(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2    "log_id": 620759800,
3    "words_result": [
4        {
5            "location": {
6                "left": 56,
7                "top": 0,
8                "width": 21,
9                "height": 210
10            },
11            "words": "3"
12        }
13    ],
14    "words_result_num": 1
15}

护照

  • 调用示例
Plain Text
1// 护照识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用护照识别服务
4OCR.getInstance(ctx).recognizePassport(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2    "log_id": 7377468409496932872,
3    "words_result_num": 14,
4    "words_result": {
5        "国家码": {
6            "location": {
7                "width": 59,
8                "top": 200,
9                "left": 762,
10                "height": 26
11            },
12            "words": "CHN"
13        },
14        "护照签发地点": {
15            "location": {
16                "width": 236,
17                "top": 505,
18                "left": 558,
19                "height": 43
20            },
21            "words": "山东/SHANDONG"
22        },
23        "MRZCode2": {
24            "location": {
25                "width": 1252,
26                "top": 797,
27                "left": 145,
28                "height": 88
29            },
30            "words": "E898657303CHNSDMO7O2<<<<<<<<<<<<<"
31        },
32        "有效期至": {
33            "location": {
34                "width": 287,
35                "top": 528,
36                "left": 955,
37                "height": 46
38            },
39            "words": "20261004"
40        },
41        "签发机关": {
42            "location": {
43                "width": 271,
44                "top": 583,
45                "left": 552,
46                "height": 42
47            },
48            "words": "出入境管理局"
49        },
50        "MRZCode1": {
51            "location": {
52                "width": 1201,
53                "top": 781,
54                "left": 162,
55                "height": 45
56            },
57            "words": "PONSUN<<JIAJIA<<<<<<<<<<<<<<<<<<<<<<<<<<"
58        },
59        "护照号码": {
60            "location": {
61                "width": 237,
62                "top": 215,
63                "left": 994,
64                "height": 48
65            },
66            "words": "E89865730"
67        },
68        "签发日期": {
69            "location": {
70                "width": 279,
71                "top": 453,
72                "left": 955,
73                "height": 46
74            },
75            "words": "20161005"
76        },
77        "出生地点": {
78            "location": {
79                "width": 216,
80                "top": 429,
81                "left": 564,
82                "height": 43
83            },
84            "words": "山东/SHANDONG"
85        },
86        "姓名": {
87            "location": {
88                "width": 159,
89                "top": 247,
90                "left": 581,
91                "height": 34
92            },
93            "words": "孙嘉佳"
94        },
95        "姓名拼音": {
96            "location": {
97                "width": 229,
98                "top": 279,
99                "left": 578,
100                "height": 41
101            },
102            "words": "SUN,JIAJIA"
103        },
104        "国籍": {
105            "location": {
106                "width": 209,
107                "top": 366,
108                "left": 695,
109                "height": 42
110            },
111            "words": "中国/CHINESE"
112        },
113        "生日": {
114            "location": {
115                "width": 202,
116                "top": 382,
117                "left": 950,
118                "height": 39
119            },
120            "words": "19950723"
121        },
122        "性别": {
123            "location": {
124                "width": 73,
125                "top": 357,
126                "left": 570,
127                "height": 34
128            },
129            "words": "男/M"
130        }
131    }
132}

户口本

  • 调用示例
Plain Text
1// 户口本识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用户口本识别服务
4OCR.getInstance(ctx).recognizehousehold(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2	"words_result": {
3		"Nation": {
4			"words": "汉族"
5		},
6		"Sex": {
7			"words": "女"
8		},
9		"Birthday": {
10			"words": "1994年7月27日"
11		},
12		"Date": {
13			"words": "2017年7月27日"
14		},
15		"BirthAddress": {
16			"words": "四川省"
17		},
18		"Name": {
19			"words": "王燕"
20		},
21        "FormerName	": {
22			"words": "王佳"
23		},
24		"HouseholdNum": {
25			"words": "000007670"
26		},
27		"WWToCity": {
28			"words": "由久居"
29		},
30		"WWHere": {
31			"words": "1994年07月27日因出生迁来"
32		},
33		"CardNo": {
34			"words": "112102199407273123"
35		},
36		"Education": {
37			"words": "初中毕业"
38		},
39		"Relationship": {
40			"words": "独生女"
41		},
42		"Height": {
43			"words": "170厘米"
44		},
45        "Career": {
46			"words": "无"
47		},
48		"WorkAddress": {
49			"words": "无"
50		},
51		"Hometown": {
52			"words": "四川省"
53		}
54        "OtherAddress": {
55			"words": "四川省乐山市"
56		}
57        "Belief": {
58			"words": "佛教"
59		}
60        "BloodType": {
61			"words": "A型"
62		}
63         "MaritalStatus": {
64			"words": "未婚"
65		}
66        "VeteranStatus": {
67			"words": "无"
68		}
69	},
70	"log_id": "1407164137607266304",
71	"words_result_num": 22
72}

通用机打发票

  • 调用示例
Plain Text
1// 通用机打发票识别参数设置 OcrRequestParams param = new OcrRequestParams();
2// 设置image参数 param.setImageFile(new File(filePath));
3// 调用通用机打发票识别服务
4OCR.getInstance(ctx).recognizeMachineInvoice(param, new OnResultListener<OcrResponseResult>() {
5    @Override
6    public void onResult(OcrResponseResult result) {
7        listener.onResult(result.getJsonRes());
8    }
9
10    @Override
11    public void onError(OCRError error) {
12        listener.onResult(error.getMessage());
13    }
14});
  • 参数
字段
是否必选
类型
说明
Image File对象 图像数据,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
  • 结果返回
Plain Text
1{
2    "log_id": 4423022131715883558,
3    "direction": 0,
4    "words_result_num": 22,
5    "words_result": {
6        "City": "",
7        "InvoiceNum": "01445096",
8        "SellerName": "百度餐饮店",
9        "IndustrySort": "生活服务",
10        "Province": "广东省",
11        "CommodityAmount": [
12            {
13                "word": "183.00",
14                "row": "1"
15            }
16        ],
17        "InvoiceDate": "2020年07月28日",
18        "PurchaserName": "中信建投证券股份有限公司",
19        "CommodityNum": [],
20        "InvoiceCode": "144001901511",
21        "CommodityUnit": [],
22        "SheetNum": "",
23        "PurchaserRegisterNum": "9144223008453480X9",
24        "Time": "",
25        "CommodityPrice": [],
26        "AmountInFiguers": "183.00",
27        "AmountInWords": "壹佰捌拾叁元整",
28        "CheckCode": "61042119820421061301",
29        "TotalTax": "183.00",
30        "InvoiceType": "广东通用机打发票",
31        "SellerRegisterNum": "61042119820421061301",
32        "CommodityName": [
33            {
34                "word": "餐费",
35                "row": "1"
36            }
37        ]
38    }
39}
上一篇
快速入门
下一篇
FAQ