【问题标题】:Azure OCR [printed text] is not reading the receipt lines in the right orderAzure OCR [打印文本] 未按正确顺序读取收据行
【发布时间】:2019-10-17 15:51:57
【问题描述】:

应用目标:读取收据图像,提取商店/组织名称以及支付的总金额。将其输入网络表单以进行自动填写和提交。

发布请求 - "https://*.cognitiveservices.azure.com/vision/v2.0/recognizeText?{params}

获取请求 - https://*.cognitiveservices.azure.com/vision/v2.0/textOperations/{operationId}

但是,当我返回结果时,有时会在行排序中混淆(见下图 [JSON 响应中的类似结果])

这种混合导致总金额为 0.88 美元

9 份测试收据中有 2 份存在类似情况。

问:为什么它适用于类似和不同的结构化收据,但由于某种原因并非对所有人都一致?另外,任何想法如何解决它?

【问题讨论】:

  • 您是否尝试过带有收据模型的“表单识别器”?这似乎完全是您的情况(获取组织名称和支付的总金额)
  • 此外,您仍然可以根据边界框在 OCR 结果上构建自己的逻辑
  • 我确实尝试过边界框,不幸的是它并没有变得更好。

标签: azure microsoft-cognitive azure-cognitive-services form-recognizer


【解决方案1】:

我快速浏览了您的案例。

OCR 结果

正如您所提到的,结果并没有像您想象的那样排序。我快速查看了边界框的值,但我不知道它们是如何排序的。您可以尝试在此基础上整合字段,但有一项服务已经在为您做这件事。

表单识别器:

使用表单识别器和您的图片,我得到了以下收据结果。

如下所示,understandingResults 包含 total 及其值(“value”:9.11)、MerchantName(“Chick-fil-a”)和其他字段。

{
    "status": "Succeeded",
    "recognitionResults": [
        {
            "page": 1,
            "clockwiseOrientation": 0.17,
            "width": 404,
            "height": 1226,
            "unit": "pixel",
            "lines": [
                {
                    "boundingBox": [
                        108,
                        55,
                        297,
                        56,
                        296,
                        71,
                        107,
                        70
                    ],
                    "text": "Welcome to Chick-fil-a",
                    "words": [
                        {
                            "boundingBox": [
                                108,
                                56,
                                169,
                                56,
                                169,
                                71,
                                108,
                                71
                            ],
                            "text": "Welcome",
                            "confidence": "Low"
                        },
                        {
                            "boundingBox": [
                                177,
                                56,
                                194,
                                56,
                                194,
                                71,
                                177,
                                71
                            ],
                            "text": "to"
                        },
                        {
                            "boundingBox": [
                                201,
                                56,
                                296,
                                57,
                                296,
                                71,
                                201,
                                71
                            ],
                            "text": "Chick-fil-a"
                        }
                    ]
                },
...
OTHER LINES CUT FOR DISPLAY
...
            ]
        }
    ],
    "understandingResults": [
        {
            "pages": [
                1
            ],
            "fields": {
                "Subtotal": null,
                "Total": {
                    "valueType": "numberValue",
                    "value": 9.11,
                    "text": "$9.11",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/32/words/0"
                        },
                        {
                            "$ref": "#/recognitionResults/0/lines/32/words/1"
                        }
                    ]
                },
                "Tax": {
                    "valueType": "numberValue",
                    "value": 0.88,
                    "text": "$0.88",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/31/words/0"
                        },
                        {
                            "$ref": "#/recognitionResults/0/lines/31/words/1"
                        },
                        {
                            "$ref": "#/recognitionResults/0/lines/31/words/2"
                        }
                    ]
                },
                "MerchantAddress": null,
                "MerchantName": {
                    "valueType": "stringValue",
                    "value": "Chick-fil-a",
                    "text": "Chick-fil-a",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/0/words/2"
                        }
                    ]
                },
                "MerchantPhoneNumber": {
                    "valueType": "stringValue",
                    "value": "+13092689500",
                    "text": "309-268-9500",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/4/words/0"
                        }
                    ]
                },
                "TransactionDate": {
                    "valueType": "stringValue",
                    "value": "2019-06-21",
                    "text": "6/21/2019",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/6/words/0"
                        }
                    ]
                },
                "TransactionTime": {
                    "valueType": "stringValue",
                    "value": "13:00:57",
                    "text": "1:00:57 PM",
                    "elements": [
                        {
                            "$ref": "#/recognitionResults/0/lines/6/words/1"
                        },
                        {
                            "$ref": "#/recognitionResults/0/lines/6/words/2"
                        }
                    ]
                }
            }
        }
    ]
}

有关表单识别器的更多详细信息:https://azure.microsoft.com/en-us/services/cognitive-services/form-recognizer/

【讨论】:

  • 嗯,很有趣,实际上我在那个案例上没有想到表单识别器(因为它在我正在处理的早期 PoC 案例上给了我完全错误的结果)。我暂时接受这个作为答案,并将在周一更新帖子,提供更多详细信息以及表单识别器结果。 谢谢
  • 对于From Recognizer,微软在服务发布后发布了一个专用于收据的模型
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-10
相关资源
最近更新 更多