我想我明白你的意思:你提到的两个页面之间没有使用相同的操作。
如果您阅读了您提到的工作演示上方的段落它说:
开始使用正式发布的 OCR 服务,并发现
下面先睹为快新的预览 OCR 引擎(通过“识别
文本”API操作)具有更好的文本识别结果
英语。
如果您查看了您指向的其他文档(this one https://learn.microsoft.com/en-us/azure/cognitive-services/Computer-vision/quickstarts/python-print-text?WT.mc_id=AI-MVP-5003365),他们正在使用OCR操作:
vision_base_url = "https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/"
ocr_url = vision_base_url + "ocr"
所以如果你想使用这个新的预览版本,请将操作更改为recognizeText
它在西欧地区可用(请参阅here https://westeurope.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/587f2c6a154055056008f200/console),我做了一个快速测试:Azure 演示页面上提供的示例适用于此操作,而不适用于其他操作。
但这次操作需要2次调用:
- 一次 POST 操作即可提交您的请求(
recognizeText
操作),您将有一个202 Accepted
回答一个operationId
- 一次 GET 操作即可获取结果(
textOperations
操作),使用上一步中的操作 ID。例如:https://westeurope.api.cognitive.microsoft.com/vision/v2.0/textOperations/yourOperationId
DEMO :
对于 Microsoft 演示中的 CLOSED 标志:
OCR 操作结果:
{
"language": "unk",
"orientation": "NotDetected",
"textAngle": 0.0,
"regions": []
}
RecognizeText 的结果:
{
"status": "Succeeded",
"recognitionResult": {
"lines": [{
"boundingBox": [174, 488, 668, 675, 617, 810, 123, 622],
"text": "CLOSED",
"words": [{
"boundingBox": [164, 494, 659, 673, 621, 810, 129, 628],
"text": "CLOSED"
}]
}, {
"boundingBox": [143, 641, 601, 811, 589, 843, 132, 673],
"text": "WHEN ONE DOOR CLOSES, ANOTHER",
"words": [{
"boundingBox": [147, 646, 217, 671, 205, 698, 134, 669],
"text": "WHEN"
}, {
"boundingBox": [230, 675, 281, 694, 269, 724, 218, 703],
"text": "ONE"
}, {
"boundingBox": [291, 697, 359, 722, 348, 754, 279, 727],
"text": "DOOR"
}, {
"boundingBox": [370, 726, 479, 767, 469, 798, 359, 758],
"text": "CLOSES,"
}, {
"boundingBox": [476, 766, 598, 812, 588, 839, 466, 797],
"text": "ANOTHER"
}]
}, {
"boundingBox": [56, 668, 645, 886, 633, 919, 44, 700],
"text": "OPENS.ALL YOU HAVE TO DO IS WALK IN",
"words": [{
"boundingBox": [74, 677, 223, 731, 213, 764, 65, 707],
"text": "OPENS.ALL"
}, {
"boundingBox": [233, 735, 291, 756, 280, 789, 223, 767],
"text": "YOU"
}, {
"boundingBox": [298, 759, 377, 788, 367, 821, 288, 792],
"text": "HAVE"
}, {
"boundingBox": [387, 792, 423, 805, 413, 838, 376, 824],
"text": "TO"
}, {
"boundingBox": [431, 808, 472, 824, 461, 855, 420, 841],
"text": "DO"
}, {
"boundingBox": [479, 826, 510, 838, 499, 869, 468, 858],
"text": "IS"
}, {
"boundingBox": [518, 841, 598, 872, 587, 901, 506, 872],
"text": "WALK"
}, {
"boundingBox": [606, 875, 639, 887, 627, 916, 594, 904],
"text": "IN"
}]
}]
}
}