【问题标题】:Handling Results from Computer Vision API处理来自计算机视觉 API 的结果
【发布时间】:2018-01-23 18:43:03
【问题描述】:

我正在使用 Azure 认知服务计算机视觉 API,但我遇到了不知道如何处理结果的问题。用例是我有一张图像,它是特定月份事件日历的照片。我正在通过计算机视觉 API OCR 方法运行图像

https://eastus2.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc

并获得一个 JSON,它是区域、行和单词的对象,每个对象都有边界。我很难找到将这些项目“分组”为所需格式的方法。这是为此图像返回的示例 JSON

https://drive.google.com/file/d/12dO0vIjGNQ8_nARTQbFHmaLNQNOWBC2x/view?usp=sharing

{ "textAngle": 0.0, "orientation": "NotDetected", "language": "en", "regions": [ { "boundingBox": "727,56,1692,119", "lines": [ { "boundingBox": "727,56,1692,119", "words": [ { "boundingBox": "727,57,727,118", "text": "CHILDREN!S" }, { "boundingBox": "1576,58,583,111", "text": "JANUARY" }, { "boundingBox": "2280,56,139,114", "text": "20" } ] } ] }, { "boundingBox": "361,265,159,42", "lines": [ { "boundingBox": "361,265,159,42", "words": [ { "boundingBox": "361,265,159,42", "text": "Sunday" } ] } ] }, { "boundingBox": "279,593,298,1261", "lines": [ { "boundingBox": "279,593,17,26", "words": [ { "boundingBox": "279,593,17,26", "text": "7" } ] }, { "boundingBox": "280,633,203,33", "words": [ { "boundingBox": "280,633,102,33", "text": "Library" }, { "boundingBox": "394,634,89,32", "text": "Open" } ] }, { "boundingBox": "282,675,124,32", "words": [ { "boundingBox": "282,675,7,26", "text": "1" }, { "boundingBox": "307,675,37,26", "text": "-5" }, { "boundingBox": "356,681,50,26", "text": "pm" } ] }, { "boundingBox": "280,716,252,31", "words": [ { "boundingBox": "280,716,71,25", "text": "New" }, { "boundingBox": "360,716,73,25", "text": "Year" }, { "boundingBox": "444,716,88,31", "text": "Open" } ] }, { "boundingBox": "281,757,96,26", "words": [ { "boundingBox": "281,757,96,26", "text": "House" } ] }, { "boundingBox": "280,797,297,27", "words": [ { "boundingBox": "280,797,67,27", "text": "Start" }, { "boundingBox": "357,797,55,26", "text": "The" }, { "boundingBox": "424,797,71,26", "text": "New" }, { "boundingBox": "503,797,74,26", "text": "Year" } ] }, { "boundingBox": "281,836,286,34", "words": [ { "boundingBox": "281,837,77,33", "text": "Right" }, { "boundingBox": "367,837,25,26", "text": "@" }, { "boundingBox": "401,837,51,26", "text": "the" }, { "boundingBox": "463,836,104,33", "text": "Library" } ] }, { "boundingBox": "281,878,110,32", "words": [ { "boundingBox": "281,878,48,26", "text": "1-5" }, { "boundingBox": "341,885,50,25", "text": "pm" } ] }, { "boundingBox": "282,976,34,25", "words": [ { "boundingBox": "282,976,34,25", "text": "14" } ] }, { "boundingBox": "281,1034,223,33", "words": [ { "boundingBox": "281,1034,103,33", "text": "Library" }, { "boundingBox": "395,1034,109,26", "text": "Closed" } ] } ] } ] }

例如,我希望能够按日期对所有最低级别的单词进行分组

7:图书馆开放时间为下午 1 点 -5 点, 新年开放日在图书馆开始新的一年 1-5 pm 14:图书馆关闭

是否有任何好的算法来做这样的事情,或者是暴力破解(检查每个文本的日期并获取其间的数组中的跨度)唯一的方法?如果有帮助,我可以将示例图片放在某个地方。

【问题讨论】:

    标签: azure computer-vision artificial-intelligence azure-cognitive-services


    【解决方案1】:

    我认为你忽略了这个问题。如果不使用数字作为基数,我们就无法排序。因此,无论算法是什么,您仍然必须取出“日期”并将其用作排序基础。

    所以首先创建一个字典如下

    {
        "text1": date1,
        "text2": date2,
     }
    

    然后排序。你就完成了

    【讨论】:

    • 对不起,我没有关注。节点 thst 表示日期与文本处于同一级别。在这种情况下,我该如何帮助他们?我觉得我错过了什么。
    • 如何使用lamba排序 unsorted_list.sort(key=lambda x: x["words"]["date"]) .
    • 我真的不明白如何区分代表日期的文本和代表事件的文本。他们处于同一水平。唯一的判断方法是检查文本是否为数字,但不能保证将其设为日期。也许一些示例代码会让我清楚。
    • 您的意思是“文本”:“关闭”。按日期,您的意思是 "text": "pm" 或 "text": "14" ???
    • 图片中的示例我希望它是“日期”:“14”,“文本”:“图书馆关闭”。如您所见,它们是同一级别的 3 个节点,但代表一个日期和一个事件。
    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-09
    相关资源
    最近更新 更多