首页 > 解决方案 > Azure Form Recognizer boundingBox 结果转换为 XY 坐标

问题描述

我想将表单识别器“boundingBox”的结果转换为图像坐标以可视化叠加图像和识别的数据。但是,boundingBox 结果看起来不像此图像这样的 XY 坐标位置。 https://i.stack.imgur.com/DOEi5.png

我需要每个boundingBox的左上(X1,Y1)和右下(X2,Y2)计算规则。

我还用认知服务 OCR 和文本识别制定了一些计算规则,但没有关于表单识别器的信息。我试图通过减号或除法找到 XY 坐标规则,但不是我得到的规则。

这是我通过表单识别器的示例图像获得的结果 json 数据。但无法从中找到 boundingBox 规则。

Responsebody: {
  'status': 'success',
  'pages': [
    {
      'number': 1,
      'height': 792,
      'width': 612,
      'clusterId': 0,
      'keyValuePairs': [
        {
          'key': [
            {
              'text': 'Address:',
              'boundingBox': [
                57.3,
                683.0,
                100.5,
                683.0,
                100.5,
                673.7,
                57.3,
                673.7
              ]
            }
          ],
          'value': [
            {
              'text': '1020 Enterpirse Way.',
              'boundingBox': [
                57.3,
                672.2,
                153.1,
                672.2,
                153.1,
                658.8,
                57.3,
                658.8
              ],
              'confidence': 0.53
            },

我需要每个boundingBox的左上(X1,Y1)和右下(X2,Y2)计算规则。

感谢团队。

标签: azurepreviewopencv-pythonform-recognizer

解决方案


在示例中:

'boundingBox': [
            57.3,
            683.0,
            100.5,
            683.0,
            100.5,
            673.7,
            57.3,
            673.7
          ]

它表示边界框的顶点。

// Azure Bounding box:           (57.3,683.0) X1,Y1---->x2,y2(100.5,683.0)
                                                  |     |
                                                  |     |
                                 (57.3,673.7) X4,Y4<----x3,y3(100.5,673.7)

从上面的例子中,选择 (X1,y1) 和 (x3,y3) 来绘制边界框。边界框在 Azure 中是非常连续的,它从 x1、y1、x2、y2、x3、y3、x4、y4 开始。列表中的前两个值是 x1,y1,第 5,6 个是 x3,y3。


推荐阅读