增值税发票识别

接口描述

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

接口说明

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

请求方式: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图像为准。

调用示例

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/invoice";

      //设置请求参数

      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/invoice.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);

   }

}

返回示例

{

  "result":{

    "password_area":{

      "position":{

        "width":545,

        "top":351,

        "height":36,

        "left":1028

      },

      "chinese_key":"密码区",

      "score":1,

      "words":"7+61s23sf"

    },

    "seller_bank_info":{

      "position":{

        "width":392,

        "top":938,

        "height":29,

        "left":326

      },

       "chinese_key":"销方开户行及账号",

      "score":1,

      "words":"中国农业银行股份有限公司"

    },

    "buyer_name":{

      "position":{

        "width":345,

        "top":241,

        "height":33,

        "left":336

      },

      "chinese_key":"购方名称",

      "score":1,

      "words":"null"

    },

    "create_date":{

      "position":{

        "width":206,

        "top":181,

        "height":35,

        "left":1398

      },

      "chinese_key":"开票日期",

      "score":1,

      "words":"2017年04月07日"

    },

    "buyer_address":{

      "position":{

        "width":592,

        "top":323,

        "height":37,

        "left":335

      },

      "chinese_key":"购方地址电话",

      "score":1,

      "words":"null"

    },

    "seller_tax_no":{

      "position":{

        "width":417,

        "top":862,

        "height":31,

        "left":360

      },

      "chinese_key":"销方纳税人识别号",

      "score":1,

      "words":"012323434343434"

    },

    "total_tax":{

      "position":{

        "width":141,

        "top":724,

        "height":28,

        "left":1491

      },

      "chinese_key":"合计税额",

      "score":1,

      "words":"276.07"

    },

    "check":{

      "position":{

        "width":89,

        "top":974,

        "height":32,

        "left":613

      },

      "chinese_key":"复核",

      "score":1,

      "words":"张三"

    },

    "invoice_no1":{

      "position":{

        "width":382,

        "top":0,

        "height":172,

        "left":1161

      },

      "chinese_key":"发票号码1",

      "score":1,

      "words":""

    },

    "seller_address":{

      "position":{

        "width":445,

        "top":894,

        "height":24,

        "left":345

      },

      "chinese_key":"销方地址电话",

      "score":1,

      "words":"null"

     },

    "creator":{

      "position":{

        "width":89,

        "top":980,

        "height":32,

        "left":993

      },

      "chinese_key":"开票人",

      "score":1,

      "words":"李四"

    },

    "seller_name":{

      "position":{

        "width":291,

        "top":822,

        "height":31,

        "left":328

      },

      "chinese_key":"销方名称",

      "score":1,

      "words":"null"

    },

    "invoice_code2":{

      "position":{

        "width":127,

        "top":105,

        "height":28,

        "left":1505

      },

      "chinese_key":"发票代码2",

      "score":1,

      "words":"44e2232320"

    },

    "invoice_code1":{

      "position":{

        "width":242,

        "top":71,

        "height":48,

        "left":249

      },

      "chinese_key":"发票代码1",

      "score":1,

      "words":"440232323"

    },

    "buyer_tax_no":{

      "position":{

        "width":342,

        "top":279,

        "height":37,

        "left":360

      },

      "chinese_key":"购方纳税人识别号",

      "score":1,

      "words":"4413022323232"

    },

    "amount_big":{

      "position":{

        "width":208,

        "top":763,

        "height":39,

        "left":514

      },

      "chinese_key":"价税合计(大写)",

      "score":1,

      "words":"壹仟玖佰圆整"

    },

    "receiver":{

      "position":{

        "width":89,

        "top":970,

        "height":32,

        "left":196

      },

      "chinese_key":"收款人",

      "score":1,

      "words":"张三"

    },

    "buyer_bank_info":{

      "position":{

        "width":370,

         "top":366,

        "height":30,

        "left":332

      },

      "chinese_key":"购方开户行及账号",

      "score":1,

      "words":"null"

    },

    "total":{

      "position":{

        "width":160,

        "top":720,

        "height":30,

        "left":1161

      },

      "chinese_key":"合计金额",

      "score":1,

      "words":"1623.93"

    },

    "amount_small":{

      "position":{

        "width":174,

        "top":776,

        "height":29,

        "left":1323

      },

      "chinese_key":"价税合计(小写)",

      "score":1,

      "words":"1900.00"

    },

    "invoice_no2":{

      "position":{

        "width":148,

        "top":141,

        "height":28,

        "left":1482

      },

      "chinese_key":"发票号码2",

      "score":1,

      "words":"0232315"

    }

  },

  "error_code":0,

  "description":"识别成功",

  "request_id":"A6827A320BF647A4A91C66DCA147A488",

  "recognize_time":2671,

  "available_count":9930

}

返回说明

通用参数

参数 类型 说明
result array 返回结果数组,包括所有字段的识别信息
error_code int 错误码,返回0为正确,其他为错误
description string 识别结果描述
request_id string 请求唯一标识符
recognize_time int 识别所用时间,单位为毫秒
available_count int 识别剩余可用次数,次数不足时无法继续识别,可在控制台进行充值次数

增值税发票识别特有参数

参数 类型 说明
words string 当前字段的值
score float 可信度(1.0为可信度100%)
position array 当前字段在图像上的位置信息
left int 位置值,距离原图左侧距离x,单位为像素
top int 位置值,距离原图上方距离y,单位为像素
width int 位置值,字段所在图框宽度w,单位为像素
height int 位置值,字段所在图框高度h,单位为像素
buyer_name Object 购方名称
buyer_tax_no Object 购方纳税人识别号
buyer_address Object 购方地址电话
buyer_bank_info Object 购方开户行及账号
seller_name Object 销方名称
seller_tax_no Object 销方纳税人识别号
seller_address Object 销方地址电话
seller_bank_info Object 销方开户行及账号
create_date Object 开票日期
amount_big Object 价税合计(大写)
amount_small Object 价税合计(小写)
total Object 合计金额
total_tax Object 合计税额
invoice_code1 Object 发票代码1
invoice_code2 Object 发票代码2
invoice_no1 Object 发票号码1
invoice_no2 Object 发票号码2
check_code Object 校验码
receiver Object 收款人
check Object 复核
creator Object 开票人
qrcode Object 二维码
password_area Object 密码区
invoice_name Object 发票名称
sheet_type Object 联次
price_tax_correction Object 价税互纠
notes Object 备注
details List 明细
Copyright © 2020 易道博识 all right reserved,powered by Gitbook该文件修订时间: 2023-12-04 14:10:10

results matching ""

    No results matching ""