文档中心 > API类目 > 视觉开放API(viapi)

aliyun.viapi.ocr.character (通用文字识别)

获取通用的文字信息。(参数图片/链接必须通过以下方式获取: https://help.aliyun.com/document_detail/155645.html )

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
image_url String 必须 http://xx.xxx.com/a.jpeg 待检测图片链接
image_type Number 可选 0 图片类型, ,取范围[0:ImageURL, 1:ImageContent]
min_height Number 必须 10 图片中文字的最小高度,单位像素
output_probability Boolean 必须 true 是否输出文字框的概率,取值范围[true:是, false:否]

响应参数

名称 类型 示例值 描述
taobao_request_id String 83FFDEFE-F863-4490-8C8F-165CFFC1954F 请求ID
data Data {} 系统自动生成
  • results
  • Result []
  • []
  • 返回识别信息
  • text_rectangle
  • TextRectangle
  • []
  • 文字区域
  • └ left
  • Number
  • 50
  • 文字区域左上角x坐标
  • └ angle
  • Number
  • 0
  • 文字区域角度,角度范围[0, 360]
  • └ top
  • Number
  • 50
  • 文字区域左上角y坐标
  • └ height
  • Number
  • 40
  • 文字区域高度
  • └ width
  • Number
  • 100
  • 文字区域宽度
  • └ probability
  • Number
  • 0.95983
  • 文字区域概率,概率值的范围为[0, 1]
  • └ text
  • String
  • 文字内容
  • 文字内容

请求示例

  • JAVA
  • .NET
  • PHP
  • CURL
  • Python
  • C/C++
  • NodeJS
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AliyunViapiOcrCharacterRequest req = new AliyunViapiOcrCharacterRequest();
req.setImageUrl("http://xx.xxx.com/a.jpeg");
req.setImageType(0L);
req.setMinHeight(10L);
req.setOutputProbability(true);
AliyunViapiOcrCharacterResponse rsp = client.execute(req);
System.out.println(rsp.getBody());

响应示例

  • XML示例
  • JSON示例
<aliyun_viapi_ocr_character_response>
    <taobao_request_id>83FFDEFE-F863-4490-8C8F-165CFFC1954F</taobao_request_id>
    <data>
        <results>
            <result>
                <text_rectangle>
                    <left>50</left>
                    <angle>0</angle>
                    <top>50</top>
                    <height>40</height>
                    <width>100</width>
                </text_rectangle>
                <probability>0.95983</probability>
                <text>文字内容</text>
            </result>
        </results>
    </data>
</aliyun_viapi_ocr_character_response>

异常示例

  • XML示例
  • JSON示例
<error_response>
    <code>50</code>
    <msg>Remote service error</msg>
    <sub_code>isv.invalid-parameter</sub_code>
    <sub_msg>非法参数</sub_msg>
</error_response>

错误码解释

错误码 错误描述 解决方案

API工具

如何获得此API

FAQ

返回
顶部