计算机视觉REST API格式

时间:2018-06-27 10:08:49

标签: azure ocr microsoft-cognitive

我目前正在使用Java中的计算机视觉API试用版,因此我从网站上获取了代码并成功获取了JSON。 但是,我得到的JSON格式与“演示”页面中显示的格式完全不同。

我的Json响应示例:

  

“区域”:[       {         “ boundingBox”:“ 21,16,304,451”,         “行”:[           {             “ boundingBox”:“ 28,16,288,41”,             “字”:[               {                 “ boundingBox”:“ 28,16,288,41”,                 “ text”:“没有”               }             ]           }

    Whereas the demo page is:
  

{       “行”:[         {           “ boundingBox”:[             122,             122,             401,             85,             404,             229,             143,             233           ]

看看边界框格式,我们可以清楚地看到差异

1 个答案:

答案 0 :(得分:0)

您得到的响应是使用计算机视觉API的OCR作为example状态的结果:

{
  "language": "en",
  "textAngle": -2.0000000000000338,
  "orientation": "Up",
  "regions": [
    {
      "boundingBox": "462,379,497,258",
      "lines": [
        {
          "boundingBox": "462,379,497,74",
          "words": [
            {
              "boundingBox": "462,379,41,73",
              "text": "A"
            },
            {
              "boundingBox": "523,379,153,73",
              "text": "GOAL"
            },
            {
              "boundingBox": "694,379,265,74",
              "text": "WITHOUT"
            }
          ]
        },
        {
          "boundingBox": "565,471,289,74",
          "words": [
            {
              "boundingBox": "565,471,41,73",
              "text": "A"
            },
            {
              "boundingBox": "626,471,150,73",
              "text": "PLAN"
            },
            {
              "boundingBox": "801,472,53,73",
              "text": "IS"
            }
          ]
        },
        {
          "boundingBox": "519,563,375,74",
          "words": [
            {
              "boundingBox": "519,563,149,74",
              "text": "JUST"
            },
            {
              "boundingBox": "683,564,41,72",
              "text": "A"
            },
            {
              "boundingBox": "741,564,153,73",
              "text": "WISH"
            }
          ]
        }
      ]
    }
  ]
}

虽然来自演示页面的响应是使用Computer Vision API的Recognize Text然后使用Get Recognize Text Operation Result来获得操作结果的结果,如example所示:

{
  "status": "Succeeded",
  "recognitionResult": {
    "lines": [
      {
        "boundingBox": [
          202,
          618,
          2047,
          643,
          2046,
          840,
          200,
          813
        ],
        "text": "Our greatest glory is not",
        "words": [
          {
            "boundingBox": [
              204,
              627,
              481,
              628,
              481,
              830,
              204,
              829
            ],
            "text": "Our"
          },
          {
            "boundingBox": [
              519,
              628,
              1057,
              630,
              1057,
              832,
              518,
              830
            ],
           "text": "greatest"
          },
          {
            "boundingBox": [
              1114,
              630,
              1549,
              631,
              1548,
              833,
              1114,
              832
            ],
            "text": "glory"
          },
          {
            "boundingBox": [
              1586,
              631,
              1785,
              632,
              1784,
              834,
              1586,
              833
            ],
            "text": "is"
          },
          {
            "boundingBox": [
              1822,
              632,
              2115,
              633,
              2115,
              835,
              1822,
              834
            ],
            "text": "not"
          }
        ]
      },
      {
        "boundingBox": [
          420,
          1273,
          2954,
          1250,
          2958,
          1488,
          422,
          1511
        ],
        "text": "but in rising every time we fall",
        "words": [
          {
            "boundingBox": [
              423,
              1269,
              634,
              1268,
              635,
              1507,
              424,
              1508
            ],
            "text": "but"
          },
          {
            "boundingBox": [
              667,
              1268,
              808,
              1268,
              809,
              1506,
              668,
              1507
            ],
            "text": "in"
          },
          {
            "boundingBox": [
              874,
              1267,
              1289,
              1265,
              1290,
              1504,
              875,
              1506
            ],
            "text": "rising"
          },
          {
            "boundingBox": [
              1331,
              1265,
              1771,
              1263,
              1772,
              1502,
              1332,
              1504
            ],
            "text": "every"
          },
          {
            "boundingBox": [
              1812,
              1263,
              2178,
              1261,
              2179,
              1500,
              1813,
              1502
            ],
            "text": "time"
          },
          {
            "boundingBox": [
              2219,
              1261,
              2510,
              1260,
              2511,
              1498,
              2220,
              1500
            ],
            "text": "we"
          },
          {
            "boundingBox": [
              2551,
              1260,
              3016,
              1258,
              3017,
              1496,
              2552,
              1498
            ],
            "text": "fall"
          }
        ]
      },
      {
        "boundingBox": [
          1612,
          903,
          2744,
          935,
          2738,
          1139,
          1607,
          1107
        ],
        "text": "in never failing ,",
        "words": [
          {
            "boundingBox": [
              1611,
              934,
              1707,
              933,
              1708,
              1147,
              1613,
              1147
            ],
            "text": "in"
          },
          {
            "boundingBox": [
              1753,
              933,
              2132,
              930,
              2133,
              1144,
              1754,
              1146
            ],
            "text": "never"
          },
          {
            "boundingBox": [
              2162,
              930,
              2673,
              927,
              2674,
              1140,
              2164,
              1144
            ],
           "text": "failing"
          },
          {
            "boundingBox": [
              2703,
              926,
              2788,
              926,
              2790,
              1139,
              2705,
              1140
            ],
           "text": ","
          }
        ]
      }
    ]
  }
}