通用文字识别

返回文档图片指定区块列表内的文字和文字的边界框,v1版本仅支持从左到右检测识别横向文档。

请求URL

POST /v1/document/text_recognize

请求参数

参数名数据类型是否必填描述
imagefile文档图片。目前支持jpg, png, bmp等大部分格式,请注意,请求体的数据格式为FormData 格式。文件大小不超过 10M,图像宽高须介于 50 到 10000(像素)之间。
dewarpbool是否切边矫正,默认为False。
enhance_modeint增强模式。● -1 不进行增强 ● 1 智能增强 ● 2 智能增亮并锐化 ● 3 黑白。默认不进行增强。
text_blocksarray文本区块列表,用来决定识别哪些区域的文字。如果未传递,会先执行“文字检测”任务获得文本区块列表。

请求示例

curl --location --request POST 'localhost:8000/api/document/text_recognize' --header 'Content-Type: multipart/form-data; boundary=--------------------------994702659308423812684350' --form 'image=@/data/your-image.jpg'

响应参数

参数名数据类型描述
codeint0代表正常返回,其他返回值详见错误码说明。
dataobject
blocksarray文档图片指定区块列表内的文字和文字的边界框,返回的文本按照从左到右,从上到下排序,已经内置简单版面分析的结果。
boxarray文字区块的4个顶点坐标,每个区块由[x1,y1,x2,y2,x3,y3,x4,y4]共4个顶点构成。
textstring识别到的文字。

响应示例

{
  "code": 0,
  "data": {
    "blocks": [
      {
        "box": [
          -3,
          5,
          1602,
          -29,
          1605,
          120,
          0,
          156
        ],
        "text": "MARY POPE OSBORNE"
      },
      {
        "box": [
          -2,
          31,
          2073,
          -9,
          2076,
          110,
          0,
          152
        ],
        "text": "is the author of many novels, picture books,"
      },
      {
        "box": [
          0,
          35,
          2065,
          -1,
          2067,
          104,
          1,
          141
        ],
        "text": "story collections, and nonfiction books. Her New"
      },
      {
        "box": [
          0,
          19,
          2052,
          0,
          2053,
          101,
          0,
          121
        ],
        "text": "York Times number one bestselling Magic Tree"
      },
      {
        "box": [
          0,
          20,
          2029,
          0,
          2030,
          90,
          0,
          111
        ],
        "text": "House series has been translated into numerous"
      },
      {
        "box": [
          0,
          40,
          2031,
          0,
          2034,
          120,
          2,
          161
        ],
        "text": "languages around the world. Highly recommended"
      },
      {
        "box": [
          0,
          49,
          2019,
          0,
          2021,
          116,
          2,
          166
        ],
        "text": "by parents and educators everywhere, the series"
      },
      {
        "box": [
          0,
          46,
          2002,
          0,
          2004,
          85,
          1,
          132
        ],
        "text": "introduces young readers to different cultures and"
      },
      {
        "box": [
          0,
          26,
          2004,
          10,
          2004,
          127,
          0,
          142
        ],
        "text": "times in history, as well as to the world's legacy"
      },
      {
        "box": [
          0,
          24,
          2007,
          0,
          2008,
          121,
          1,
          146
        ],
        "text": "of ancient myth and storytelling. She and her"
      },
      {
        "box": [
          0,
          50,
          1985,
          0,
          1988,
          99,
          2,
          150
        ],
        "text": "husband, writer Will Osborne (author of Magic"
      },
      {
        "box": [
          0,
          60,
          1978,
          -1,
          1980,
          89,
          2,
          151
        ],
        "text": "Tree House: The Musical), live in northwestern"
      },
      {
        "box": [
          0,
          64,
          1966,
          0,
          1969,
          90,
          2,
          155
        ],
        "text": "Connecticut with their three dogs. Ms. Osborne"
      },
      {
        "box": [
          0,
          65,
          1977,
          0,
          1981,
          105,
          3,
          171
        ],
        "text": "is coauthor of the companion Magic Tree House⑩"
      },
      {
        "box": [
          0,
          74,
          1962,
          -1,
          1966,
          99,
          3,
          176
        ],
        "text": "Fact Trackers with Will and with her sister, Natalie"
      },
      {
        "box": [
          0,
          24,
          476,
          0,
          480,
          70,
          2,
          96
        ],
        "text": "Pope Boyce."
      }
    ]
  }
}
secure-scanner.net 版权所有@2024 京ICP备2024096961号