我有几个需要用OCR识别的图像的例子。
我试着在演示页面https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/上识别它们,它工作得很好。我使用“读取图像中的文本”选项,它比“从图像中读取手写文本”的效果更好。
但是,当我尝试从脚本中使用REST调用时(根据文档中给出的示例),结果要糟糕得多。有些字母被认为是错误的,有些则完全遗漏了。如果我尝试从开发控制台https://westcentralus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fc/console运行相同的示例,仍然会得到同样糟糕的结果。
造成这种差异的原因是什么?在演示页面生成时,我如何修复它以获得可靠的结果?
也许需要任何额外的信息?
UPD:由于我找不到任何解决方案,甚至无法解释其中的差异,所以我创建了一个示例文件(类似于实际文件),因此您可以查看一下。文件url为http://sfiles.herokuapp.com/sample.png
您可以看到,如果在演示页面https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/的“在图像中读取文本”一节中使用了它,则生成的JSON为
{
"status": "Succeeded",
"succeeded": true,
"failed": false,
"finished": true,
"recognitionResult": {
"lines": [
{
"boundingBox": [
307,
159,
385,
158,
386,
173,
308,
174
],
"text": "October 2011",
"words": [
{
"boundingBox": [
308,
160,
357,
160,
357,
174,
308,
175
],
"text": "October"
},
{
"boundingBox": [
357,
160,
387,
159,
387,
174,
357,
174
],
"text": "2011"
}
]
},
{
"boundingBox": [
426,
157,
519,
158,
519,
173,
425,
172
],
"text": "07UC14PII0244",
"words": [
{
"boundingBox": [
426,
160,
520,
159,
520,
174,
426,
174
],
"text": "07UC14PII0244"
}
]
}
]
}
}如果我在控制台中使用此文件并执行以下调用:
POST https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/ocr?language=unk&detectOrientation =true HTTP/1.1
Host: westcentralus.api.cognitive.microsoft.com
Content-Type: application/json
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••
{"url":"http://sfiles.herokuapp.com/sample.png"}我得到不同的结果:
{
"language": "el",
"textAngle": 0.0,
"orientation": "Up",
"regions": [{
"boundingBox": "309,161,75,10",
"lines": [{
"boundingBox": "309,161,75,10",
"words": [{
"boundingBox": "309,161,46,10",
"text": "October"
}, {
"boundingBox": "358,162,26,9",
"text": "2011"
}]
}]
}, {
"boundingBox": "428,161,92,10",
"lines": [{
"boundingBox": "428,161,92,10",
"words": [{
"boundingBox": "428,161,92,10",
"text": "071_lC14P110244"
}]
}]
}]
}如您所见,结果完全不同(甚至是JSON格式)。有没有人知道我做错了什么,或者我漏掉了什么,“在图像中读取文本”演示与API的ocr方法不匹配?
都会非常感谢你的帮助。
发布于 2019-01-20 05:36:31
Microsoft Cognitive Services中有两种风格的OCR。较新的端点(/recognizeText)具有更好的识别功能,但目前仅支持英语。较旧的端点(/ocr)具有更广泛的语言覆盖范围。
有关这些差异的更多详细信息,请参阅this post。
https://stackoverflow.com/questions/54201358
复制相似问题