OCR速算

简介

HI,您好,欢迎使用学而思网校AI开放平台OCR速算接口服务。

本文档主要针对需要集成HTTP API的技术研发工程师,详细描述OCR速算能力相关的技术内容。您可以通过快速接入安全接入使用此AI能力。

接口能力

接口名称 接口能力简要描述 api 地址
OCR速算 检测上传图像中的式子,进行 AI 自动判题 http://openapiai.xueersi.com/v1/api/img/ocr/expreg

适用范围

任意操作系统,任意编程语言,均可以通过http或https调用本接口。

图像发送方式

图像数据支持两种形式发送:

  • URL 
    • 网络上的图片 URL 地址
  • 图片数据
    • 请求图片需经过base64编码:图片的base64编码指将一副图片编码成字符串数据,便于网络传输请求。您可以首先得到图片的二进制,进行base64编码后,然后再进行urlencode(注意你所使用的网络工具或网络库有没有默认的urlencode功能,如果没有,需要你自己显式转化)。
    • 转码方式可参考base64示例
    • 注意: 图片的base64编码是不包含图片头的,如(data:image/jpg;base64,)

  • 图片大小
    • 不能大于4MB
    • 长边不能超过4096px
    • 短边不能小于15px

图像类型支持

图像数据支持以下原生类型:

  • jpg
  • jpeg
  • png
  • bmp

题型支持

目前,OCR速算接口服务支持多种题型,包括:

  1. 四则混合运算
  2. 带括号、题号四则混合运算
  3. 填空、比大小、最大最小填几
  4. 带余数除法、比、近似值和估算
  5. 最小公倍数、最大公约数
  6. 单位换算
  7. 纯手写式子
  8. 分式计算(含通分约分、混合运算、百分数等)
  9. 竖式、脱式计算(暂不支持带分数)
  10. 方程填空和解方程(暂不支持带分数)

请求方式

HTTP 方法POST

请求 URLhttp://openapiai.xueersi.com/v1/api/img/ocr/expreg

注意: Content-Type为application/x-www-form-urlencoded,然后通过urlencode格式化请求体。

Header 如下

参数名 赋值
Content-Type application/x-www-form-urlencoded

 

urlencode介绍

在请求 API 的 post 请求参数中含有图片url地址或base64字符。url地址 或 base64 字符作为参数传递时,需要把 中文 以及 '/' 做一下编码,防止解析中出现歧义,从而符合url的规范。

将中文 以及 '/'  转换为百分号编码形式,这就是 urlencode 格式化操作

部分语言的第三方包内部做了 urlencode 编码,不进行 urlencode 格式化也可以正常进行 API 请求,但    是进行 urlencode 格式化之后一定可以通过请求。所以我们推荐您对请求体中的参数进行 urlencode 操作

 

快速接入方式

请求参数详情

参数名 类型 是否必选 赋值说明 样例 备注
app_key string 应用标识 8102b22a5e81e840176d9f381ec6f837  
img string 图像数据 http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg

图像 base64数据:示例数据较长,见附件base64.txt
图像base64字符串 / 图像URL
img_type string 图像形式 base64 / URL  

请求代码示例

HTTP 代码示例:

POST /v1/api/img/ocr/expreg HTTP/1.1
Host: openapiai.xueersi.com
Content-Type: application/x-www-form-urlencoded
cache-control: no-cache
app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL

cURL 代码示例:

curl -X POST \
  http://openapiai.xueersi.com/v1/api/img/ocr/expreg \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL'

PHP 代码示例:

PHP DEMO Quick下载

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://openapiai.xueersi.com/v1/api/img/ocr/expreg",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/x-www-form-urlencoded",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Python(Python3) 代码示例:

import http.client

conn = http.client.HTTPConnection("openapiai.xueersi.com")

payload = "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL"

headers = {
    'Content-Type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache",
    }

conn.request("POST", "/v1/api/img/ocr/expreg/", payload, headers)

res = conn.getresponse()
data = res.read()
#python2.7
#print(data)
#python3.6
print(data.decode("utf-8"))
conn.close()

C++(LibCurl) 代码示例:

C++ DEMO下载

以上 C++ DEMO 依赖 libcurl 库。参考链接:https://curl.haxx.se/libcurl/features.html#thread

CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "http://openapiai.xueersi.com/v1/api/img/ocr/expreg");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL");

CURLcode ret = curl_easy_perform(hnd);

Java 代码示例:

Andriod DEMO下载

    public static void QuickConnect(){

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("app_key", "8102b22a5e81e840176d9f381ec6f837");

                   
                    params.put("img","http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg");
                    params.put("img_type","URL");

                    Log.i(TAG,"start post");
                    String result = HttpUtil.sendPostMessage(params,"utf-8");
                    System.out.println("result->"+result);

                }catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
        }).start();
      
      
    }

JavaScript 代码示例:

 JavaScript DEMO Quick下载

 

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://openapiai.xueersi.com/v1/api/img/ocr/expreg",
  "method": "POST",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "cache-control": "no-cache",
  },
  "data": {
    "app_key": "8102b22a5e81e840176d9f381ec6f837",
    "img": "http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg",
    "img_type": "URL"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Go 代码示例:

package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://openapiai.xueersi.com/v1/api/img/ocr/expreg"

	payload := strings.NewReader("app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

C# 代码示例:

C# DEMO下载

using System;
using System.IO;
using System.Net;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string celerityPost = CelerityPost();
            Console.WriteLine("快速接入方式:\n" + celerityPost);
            Console.ReadLine();
        }
        private static string CelerityPost()
        {
            string url = "http://openapiai.xueersi.com/v1/api/img/ocr/expreg";//URL地址
            string payload = "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL";
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.ContentLength = Encoding.UTF8.GetByteCount(payload);
            webRequest.ContentType = "application/x-www-form-urlencoded";//Content-Type
            webRequest.CookieContainer = cookieContainer;
            webRequest.Method = "post";
            Stream request = webRequest.GetRequestStream();
            StreamWriter streamWriter = new StreamWriter(request, Encoding.GetEncoding("gb2312"));
            streamWriter.Write(payload);
            streamWriter.Close();
            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            response.Cookies = cookieContainer.GetCookies(response.ResponseUri);
            Stream returnStream = response.GetResponseStream();
            StreamReader streamReader = new StreamReader(returnStream, Encoding.GetEncoding("utf-8"));
            string endResult = streamReader.ReadToEnd();//返回结果
            streamReader.Close();
            returnStream.Close();
            return endResult;
        }
    }
}

微信小程序 代码示例:

 wx.request({
      url: 'http://openapiai.xueersi.com/v1/api/img/ocr/expreg',
      method: "post",
      data:
      {
        app_key: "8102b22a5e81e840176d9f381ec6f837",
        img: "http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg",
        img_type: "URL",
      },
      header: {
        "content-type": "application/x-www-form-urlencoded",
      },
      success(res) {
        console.log(res.data)
      }
    })

iOS 代码示例:

iOS DEMO下载

NSURLSession *session = [NSURLSession sharedSession];
NSString *urlStr = @"http://openapiai.xueersi.com/v1/api/img/ocr/expreg";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
NSString *app_key = @"app_key=8102b22a5e81e840176d9f381ec6f837";
NSString *img = @"img=http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg";
NSString *img_type = @"img_type=URL";
NSString *paramsStr = [NSString stringWithFormat:@"%@&%@&%@", app_key, img, img_type];
request.HTTPBody = [paramsStr dataUsingEncoding:NSUTF8StringEncoding];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
    NSLog(@"result=%@",dict);
}];
[dataTask resume];

安全接入方式

请求参数详情

参数名 类型 是否必选 赋值说明 样例 备注
app_key string 应用标识 8102b22a5e81e840176d9f381ec6f837  
time_stamp string 秒级时间戳 1493468759 安全接入必备,用于唯一地标识某一刻的时间
nonce_str string 随机字符串 dd599ef889859f9fe 安全接入必备
sign string 签名信息 99880aabb33f4def5c875875b6bdc3b1 安全接入必备
img string 图像数据 http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg

图像 base64数据:示例数据较长,见附件base64.txt
图像base64字符串 / 图像URL
img_type string 图像形式 URL base64 / URL

请求代码示例

HTTP 代码示例:

POST /v1/api/img/ocr/expreg HTTP/1.1
Host: openapiai.xueersi.com
Content-Type: application/x-www-form-urlencoded
cache-control: no-cache
app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322

cURL 代码示例:

curl -X POST \
  http://openapiai.xueersi.com/v1/api/img/ocr/expreg \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322'

PHP 代码示例:

PHP DEMO下载

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://openapiai.xueersi.com/v1/api/img/ocr/expreg",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/x-www-form-urlencoded",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Python(Python3) 代码示例:

URL形式:

import http.client

conn = http.client.HTTPConnection("openapiai.xueersi.com")

payload = "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322"

headers = {
    'Content-Type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache",
    }

conn.request("POST", "/v1/api/img/ocr/expreg/", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Python(Python3) 代码示例:

base64形式:

import http.client
import urllib
import base64
from urllib import quote

with open('./test.jpg', 'rb') as bin_data:
      image_data = bin_data.read()
image_data_base64 = base64.b64encode(image_data)
image_data_base64=quote(image_data_base64)
conn = http.client.HTTPConnection("openapiai.xueersi.com")
appkey_string='app_key=8102b22a5e81e840176d9f381ec6f837'
img_string='img='+image_data_base64
img_type_string='img_type=base64'
payload =  appkey_string+'&'+img_string+'&'+img_type_string
headers = {
        'Content-Type': "application/x-www-form-urlencoded",
        'cache-control': "no-cache",
          }
conn.request("POST", "/v1/api/img/ocr/expreg/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
conn.close()

C++(LibCurl) 代码示例:

C++ DEMO下载

以上 C++ DEMO 依赖 libcurl 库。参考链接:https://curl.haxx.se/libcurl/features.html#thread

CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "http://openapiai.xueersi.com/v1/api/img/ocr/expreg");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322");

CURLcode ret = curl_easy_perform(hnd);

Java 代码示例:

Andriod DEMO下载

public static void QuickConnect(){

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("app_key", "8102b22a5e81e840176d9f381ec6f837");

                  
                    params.put("img",http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg);
                    params.put("img_type","URL");

                    Log.i(TAG,"start post");
                    String result = HttpUtil.sendPostMessage(params,"utf-8");
                    System.out.println("result->"+result);

                }catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
        }).start();


    }

JavaScript 代码示例:

JavaScript DEMO下载

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://openapiai.xueersi.com/v1/api/img/ocr/expreg",
  "method": "POST",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "cache-control": "no-cache",
  },
  "data": {
    "app_key": "8102b22a5e81e840176d9f381ec6f837",
    "img": "http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg",
    "img_type": "URL",
    "time_stamp": "1551174536",
    "nonce_str": "W8FI8oCp",
    "sign": "7d15e530e58fcf3a020ec69b48d951010fa49322"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Go 代码示例:

package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://openapiai.xueersi.com/v1/api/img/ocr/expreg"

	payload := strings.NewReader("app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

C# 代码示例:

C# DEMO下载

using System;
using System.IO;
using System.Net;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string safetyPost = SafetyPost();
            Console.WriteLine("安全接入方式:\n" + safetyPost);
            Console.ReadLine();
        }
        private static string SafetyPost()
        {
            string url = "http://openapiai.xueersi.com/v1/api/img/ocr/expreg";//URL地址
            string payload = "app_key=8102b22a5e81e840176d9f381ec6f837&img=http%3A%2F%2Fai.xueersi.com%2ForalCorrection%2Fimages%2FKPI_180.jpg&img_type=URL&time_stamp=1551174536&nonce_str=W8FI8oCp&sign=7d15e530e58fcf3a020ec69b48d951010fa49322";
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.ContentLength = Encoding.UTF8.GetByteCount(payload);
            webRequest.ContentType = "application/x-www-form-urlencoded";//Content-Type
            webRequest.CookieContainer = cookieContainer;
            webRequest.Method = "post";
            Stream request = webRequest.GetRequestStream();
            StreamWriter streamWriter = new StreamWriter(request, Encoding.GetEncoding("gb2312"));
            streamWriter.Write(payload);
            streamWriter.Close();
            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            response.Cookies = cookieContainer.GetCookies(response.ResponseUri);
            Stream returnStream = response.GetResponseStream();
            StreamReader streamReader = new StreamReader(returnStream, Encoding.GetEncoding("utf-8"));
            string endResult = streamReader.ReadToEnd();//返回结果
            streamReader.Close();
            returnStream.Close();
            return endResult;
        }
    }
}

微信小程序 代码示例:

 wx.request({
      url: 'http://openapiai.xueersi.com/v1/api/img/ocr/expreg',
      method: "post",
      data:
      {
        app_key: "8102b22a5e81e840176d9f381ec6f837",
        img: "http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg",
        img_type: "URL",
        time_stamp: "1551174536",
        nonce_str: "W8FI8oCp",
        sign: "c08d8f9900479a3b2a348c1d7dc7e918e71be66a"
      },
      header: {
        "content-type": "application/x-www-form-urlencoded",
      },
      success(res) {
        console.log(res.data)
      }
    })

iOS 代码示例:

iOS DEMO下载

NSURLSession *session = [NSURLSession sharedSession];
NSString *urlStr = @"http://openapiai.xueersi.com/v1/api/img/ocr/expreg";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
NSString *app_key = @"app_key=8102b22a5e81e840176d9f381ec6f837";
NSString *img = @"img=http://ai.xueersi.com/oralCorrection/images/KPI_180.jpg";
NSString *img_type = @"img_type=URL";
NSString *time_stamp = @"time_stamp=1551174536";
NSString *nonce_str = @"nonce_str=W8FI8oCp";
NSString *sign = @"sign=c08d8f9900479a3b2a348c1d7dc7e918e71be66a";
NSString *paramsStr = [NSString stringWithFormat:@"%@&%@&%@&%@&%@&%@", app_key, img, img_type, time_stamp, nonce_str, sign];
request.HTTPBody = [paramsStr dataUsingEncoding:NSUTF8StringEncoding];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
    NSLog(@"result=%@",dict);
}];
[dataTask resume];

返回响应

返回格式

JSON格式

响应参数说明

参数名 类型 赋值说明 样例 备注
code int 返回码 0  
msg string 返回码解释 "请求成功"  
data obj 识别结果结构    
url string 批改图 url (有效期:1天)

"http://imgexpreg.xueersi.com/

142/20190328/TS24_1_B_100.jpg"

可下载图片保存或显示,也可以网页查看
regCount int 识别出的式子个数 3  
regResult array 所有找到的式子的识别结果   包含所有检出式子的验算信息
judge int 每一个式子的批改状态 1 0 错误 / 1 正确
pos array 每一个式子在原图中的位置 [ 243, 86, 64, 317 ] [纵坐标,横坐标,高,宽],用于绘制式子框和验算结果
text string 每一个式子的识别结果 "240×3=720" 最合理的概率最高的识别结果
score int 当前页得分 100 百分制,答对式子数除以识别出式子总数乘以100,四舍五入

响应代码示例

响应Body:

{
    "code": 0,
    "msg": "请求成功",
    "data": {
        "url": "http://imgexpreg.xueersi.com/142/20190328/TS24_1_B_100.jpg",
        "regResult": [
            {
                "judge": 1,
                "pos": [
                    243,
                    86,
                    64,
                    317
                ],
                "text": "240×3=720"
            },
            {
                "judge": 1,
                "pos": [
                    252,
                    496,
                    64,
                    303
                ],
                "text": "74×3=222"
            },
            {
                "judge": 1,
                "pos": [
                    309,
                    86,
                    59,
                    346
                ],
                "text": "800×6=4800"
            }
        ],
        "regCount": 3,
        "score": 100
    }
}

常见问题及反馈

Back to top