财务报表识别

接口描述

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

接口说明

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

请求方式:HTTP Post

返回格式:json

参数
Content-Type 使用二进制方式时,为multipart/form-data;使用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/financial_report";

      //设置请求参数

      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/medicine.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": [
        {
            "column_info": [
                "",
                "金额",
                "年初余额"
            ],
            "data": [
                [
                    {
                        "quad": "2273,2043,2341,2043,2341,2054,2273,2054",
                        "score": 1.0,
                        "words": "短期情款"
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    }
                ],
                [
                    {
                        "quad": "2279,2066,2380,2066,2380,2077,2279,2077",
                        "score": 1.0,
                        "words": "向中史设行值。"
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    }
                ],
                [
                    {
                        "quad": "2279,2088,2374,2088,2374,2099,2279,2099",
                        "score": 1.0,
                        "words": "收收名款及:"
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    },
                    {
                        "quad": "0,0,0,0,0,0,0,0",
                        "score": 1.0,
                        "words": ""
                    }
                ],
                [
                    {
                        "quad": "2279,3665,2374,3665,2374,3682,2279,3682",
                        "score": 1.0,
                        "words": "少数股东权益"
                    },
                    {
                        "quad": "3172,3665,3267,3665,3267,3682,3172,3682",
                        "score": 1.0,
                        "words": "172,700,030.64"
                    },
                    {
                        "quad": "3413,3665,3508,3665,3508,3682,3413,3682",
                        "score": 1.0,
                        "words": "163,729,548.46"
                    }
                ],
                [
                    {
                        "quad": "2268,3688,2369,3688,2369,3705,2268,3705",
                        "score": 1.0,
                        "words": "所有者权益合计"
                    },
                    {
                        "quad": "3160,3688,3267,3688,3267,3705,3160,3705",
                        "score": 1.0,
                        "words": "1,548,006,553.23"
                    },
                    {
                        "quad": "3402,3688,3508,3688,3508,3705,3402,3705",
                        "score": 1.0,
                        "words": "1,338,404,389.25"
                    }
                ],
                [
                    {
                        "quad": "2268,3710,2419,3710,2419,3727,2268,3727",
                        "score": 1.0,
                        "words": "负债和所有者权益总计"
                    },
                    {
                        "quad": "3155,3716,3267,3716,3267,3727,3155,3727",
                        "score": 1.0,
                        "words": "8,609,855,786.91"
                    },
                    {
                        "quad": "3402,3716,3503,3716,3503,3727,3402,3727",
                        "score": 1.0,
                        "words": "9,108,691,732.69"
                    }
                ]
            ],
            "description": "资产负债表",
            "type": 0
        }
    ],
    "error_code": 0,
    "description": "识别成功",
    "request_id": "309EB58D041A479683CFB853D64FF4BD",
    "recognize_time": 11638,
    "available_count": 854,
    "version": null
}

返回说明

通用参数

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

result特有参数

参数 类型 说明
column_info array 列名
data array 表格内容信息数组,包括所有识别信息
type string 文本类型

data特有参数

参数 类型 说明
quad int 每个字段的坐标
score double 得分
words string 该字段的中文名称
Copyright © 2020 易道博识 all right reserved,powered by Gitbook该文件修订时间: 2023-12-04 14:10:10

results matching ""

    No results matching ""