C# Azure认知服务中的文本识别

C# Azure认知服务中的文本识别,c#,ocr,azure-cognitive-services,C#,Ocr,Azure Cognitive Services,我已经使用ComputerVisionClient开发了一个快速示例代码 结果很好,但由于某些原因,我无法让ComputerVisionClient输出葡萄牙语字符,如“ã”或“é”等 我查阅了文档,并尝试使用两种方法。RecognitizedDemoveStreamAsync和RecognitizedPrintedDemoveStreamAsync。只有认可的PrintedStreamAsync允许我指定语言。但即使我指定OcrLanguages.Pt,葡萄牙语字符也不会显示。我得到的不是“ç

我已经使用ComputerVisionClient开发了一个快速示例代码

结果很好,但由于某些原因,我无法让ComputerVisionClient输出葡萄牙语字符,如“ã”或“é”等

我查阅了文档,并尝试使用两种方法。RecognitizedDemoveStreamAsync和RecognitizedPrintedDemoveStreamAsync。只有认可的PrintedStreamAsync允许我指定语言。但即使我指定OcrLanguages.Pt,葡萄牙语字符也不会显示。我得到的不是“ç”,而是“c

我是否遗漏了什么,或者这是设计的预期行为


首先,这两种不同的方法用于不同的场景,如下所示

curl -v -X POST "https://southeastasia.api.cognitive.microsoft.com/vision/v2.0/ocr?language=pt" 
-H "Content-Type: application/json" 
-H "Ocp-Apim-Subscription-Key: <subscription key>" 
--data-ascii '{"url":"https://i.imgur.com/o6i3UDH.png"}' 
  • 用于提取打印的手写的文本
  • 用于提取打印的文本的可识别打印数据流异步
请仔细参考官方文档
示例的两个部分和:使用C#
浏览图像处理应用程序,如下面的屏幕截图所示

有文档引用的官方代码示例:。您可以找到这两个文件和

希望他们能帮助你使你的代码工作


更新:

我研究了计算机视觉的restapi:然后,OCR restapi可以指定语言选项作为请求参数

因此,我尝试设置
language=pt
,通过
curl
调用OCR API,命令如下

curl -v -X POST "https://southeastasia.api.cognitive.microsoft.com/vision/v2.0/ocr?language=pt" 
-H "Content-Type: application/json" 
-H "Ocp-Apim-Subscription-Key: <subscription key>" 
--data-ascii '{"url":"https://i.imgur.com/o6i3UDH.png"}' 
但是,当我设置参数
language=unk
(自动检测)时,结果良好,并且正确识别语言为
pt
葡萄牙语

curl -v -X POST "https://southeastasia.api.cognitive.microsoft.
com/vision/v2.0/ocr?language=unk" 
-H "Content-Type: application/json" 
-H "Ocp-Apim-Subscription-Key: <subscription key>" 
--data-ascii '{"url":"https://i.imgur.com/o6i3UDH.png"}'

我不知道为什么
unk
pt
好。你可以复制和比较他们的结果。希望有帮助。

嗨,谢谢你的回复。我看到了相同的示例,运行该代码后,我从相同的文件中获得了相同的输出。葡萄牙语字符没有被检测到。我尝试了两种方法,得到了相同的结果:(@Paulocorriea你能为我们发布一些示例图像吗?当然。我试图从其中一个示例图像中获取文本。这是一份餐厅菜单。第三项返回“BARRIGA DE LEITAO CROCANTE//19.50E”,而不是“BARRIGA DE LEITÃO CROCANTE//19.50E”。这两种方法都返回相同的文本,但不带“Ô,而是带“A”。感谢您的帮助。这就是问题所在。未知语言而不是特定语言。当我将该语言指定为未知语言时,其具有更好的文本识别能力,这的确是一种奇怪的行为。为您致敬,伙计:)
{"language":"pt","textAngle":0.0,"orientation":"Up","regions":[{"boundingBox":"175,64,389,736","lines":[{"boundingBox":"175,64,388,20","words":[{"boundingBox":"175,69,16,15","text":"a"},{"boundingBox":"197,66,60,18","text":"cahne"},{"boundingBox":"389,64,142,20","text":"ahomemdõa"},{"boundingBox":"538,80,4,3","text":"."},{"boundingBox":"553,80,10,3","text":".."}]},{"boundingBox":"356,106,31,8","words":[{"boundingBox":"356,106,31,8","text":"CARNE"}]},{"boundingBox":"297,177,152,9","words":[{"boundingBox":"297,177,31,8","text":"PEITO"},{"boundingBox":"336,177,11,8","text":"DE"},{"boundingBox":"355,177,24,8","text":"PATO"},{"boundingBox":"387,177,11,9","text":"//"},{"boundingBox":"406,177,31,9","text":"19.50"},{"boundingBox":"444,177,5,8","text":"€"}]},{"boundingBox":"300,199,146,8","words":[{"boundingBox":"300,199,38,8","text":"BULGUR"},{"boundingBox":"345,199,12,8","text":"DE"},{"boundingBox":"364,199,82,8","text":"RAS-EL-HANOUT"}]},{"boundingBox":"262,253,223,9","words":[{"boundingBox":"262,253,63,8","text":"ENTRECOSTO"},{"boundingBox":"332,253,12,8","text":"DE"},{"boundingBox":"352,253,24,8","text":"BIFE"},{"boundingBox":"383,253,31,8","text":"HAGYU"},{"boundingBox":"422,253,11,9","text":"//"},{"boundingBox":"441,253,31,9","text":"24.00"},{"boundingBox":"479,253,6,8","text":"€"}]},{"boundingBox":"316,275,114,8","words":[{"boundingBox":"316,275,18,8","text":"COM"},{"boundingBox":"341,275,32,8","text":"MOLHO"},{"boundingBox":"380,275,50,8","text":"BARBECUE"}]},{"boundingBox":"256,327,235,11","words":[{"boundingBox":"256,329,43,8","text":"BARRIGA"},{"boundingBox":"307,329,11,8","text":"DE"},{"boundingBox":"326,327,37,10","text":"LEITÃO"},{"boundingBox":"370,329,51,8","text":"CROCANTE"},{"boundingBox":"429,329,10,9","text":"//"},{"boundingBox":"448,329,30,9","text":"19.50"},{"boundingBox":"485,329,6,8","text":"€"}]},{"boundingBox":"281,351,151,9","words":[{"boundingBox":"281,351,38,9","text":"QUINOA"},{"boundingBox":"326,351,18,8","text":"cog"},{"boundingBox":"352,351,37,8","text":"FRUTOS"},{"boundingBox":"396,351,36,9","text":"SECOS."}]},{"boundingBox":"288,372,171,10","words":[{"boundingBox":"288,374,5,8","text":"E"},{"boundingBox":"300,374,31,8","text":"MOLHO"},{"boundingBox":"339,374,11,8","text":"DE"},{"boundingBox":"357,374,51,8","text":"MOSTARDA"},{"boundingBox":"416,374,11,8","text":"EH"},{"boundingBox":"434,372,25,10","text":"GRÃO"}]},{"boundingBox":"236,427,274,9","words":[{"boundingBox":"236,427,31,8","text":"PERNA"},{"boundingBox":"275,427,11,8","text":"DE"},{"boundingBox":"294,427,43,8","text":"BORREGO"},{"boundingBox":"345,427,12,8","text":"DE"},{"boundingBox":"365,427,30,8","text":"LEITE"},{"boundingBox":"402,427,38,8","text":"ASSADA"},{"boundingBox":"448,427,11,9","text":"//"},{"boundingBox":"466,427,31,9","text":"20.50"},{"boundingBox":"504,427,6,8","text":"€"}]},{"boundingBox":"297,448,152,11","words":[{"boundingBox":"297,448,24,10","text":"PURÉ"},{"boundingBox":"329,450,42,9","text":"BATATA."},{"boundingBox":"380,450,69,8","text":"RATATOUILLE"}]},{"boundingBox":"281,501,184,11","words":[{"boundingBox":"281,501,44,10","text":"TÁRTARO"},{"boundingBox":"332,503,12,8","text":"DE"},{"boundingBox":"352,503,43,8","text":"NOVILHO"},{"boundingBox":"403,503,11,9","text":"//"},{"boundingBox":"422,503,31,9","text":"16.50"},{"boundingBox":"460,503,5,8","text":"€"}]},{"boundingBox":"256,526,235,8","words":[{"boundingBox":"256,526,37,8","text":"PICADO"},{"boundingBox":"314,526,24,8","text":"FACA"},{"boundingBox":"345,526,18,8","text":"COH"},{"boundingBox":"370,526,57,8","text":"BATATINHA"},{"boundingBox":"434,526,57,8","text":"GAUFRETTE"}]},{"boundingBox":"236,579,274,9","words":[{"boundingBox":"236,579,25,8","text":"BIFE"},{"boundingBox":"268,579,12,8","text":"OA"},{"boundingBox":"287,579,32,8","text":"VAZIA"},{"boundingBox":"326,579,50,8","text":"GRELHADO"},{"boundingBox":"384,579,55,9","text":"(NOVILHO)"},{"boundingBox":"448,579,11,9","text":"//"},{"boundingBox":"466,579,31,9","text":"20.50"},{"boundingBox":"504,579,6,8","text":"€"}]},{"boundingBox":"336,602,74,9","words":[{"boundingBox":"336,602,23,9","text":"(4/-"},{"boundingBox":"367,602,18,8","text":"220"},{"boundingBox":"393,602,17,9","text":"GR)"}]},{"boundingBox":"211,625,323,9","words":[{"boundingBox":"211,625,18,8","text":"cog"},{"boundingBox":"236,625,38,8","text":"BATATA"},{"boundingBox":"281,625,12,8","text":"00"},{"boundingBox":"300,625,23,9","text":"DIA."},{"boundingBox":"332,625,38,8","text":"CEBOLA"},{"boundingBox":"377,625,76,8","text":"CARAMELIZADA"},{"boundingBox":"460,625,5,8","text":"E"},{"boundingBox":"473,625,61,9","text":"COGUMELOS."}]},{"boundingBox":"181,645,383,10","words":[{"boundingBox":"181,647,51,8","text":"MANTEIGA"},{"boundingBox":"239,645,25,10","text":"CAFÉ"},{"boundingBox":"272,647,11,8","text":"DE"},{"boundingBox":"291,647,30,8","text":"PARIS"},{"boundingBox":"329,647,11,8","text":"OU"},{"boundingBox":"348,647,38,8","text":"CROSTA"},{"boundingBox":"393,647,12,8","text":"DE"},{"boundingBox":"412,647,44,8","text":"PIMENTA"},{"boundingBox":"463,647,12,8","text":"OU"},{"boundingBox":"482,647,31,8","text":"MOLHO"},{"boundingBox":"521,645,43,10","text":"BEARNÊS"}]},{"boundingBox":"220,698,306,11","words":[{"boundingBox":"220,698,25,10","text":"COTE"},{"boundingBox":"252,700,12,8","text":"DE"},{"boundingBox":"272,700,30,8","text":"80EUF"},{"boundingBox":"310,700,50,8","text":"GRELHADO"},{"boundingBox":"367,700,18,8","text":"COM"},{"boundingBox":"394,700,24,8","text":"FLOR"},{"boundingBox":"425,700,12,8","text":"DE"},{"boundingBox":"444,700,18,8","text":"SAL"},{"boundingBox":"470,700,11,9","text":"//"},{"boundingBox":"489,700,24,9","text":"6.80"},{"boundingBox":"520,700,6,8","text":"€"}]},{"boundingBox":"333,723,80,9","words":[{"boundingBox":"333,723,30,9","text":"(CADA"},{"boundingBox":"371,723,18,8","text":"100"},{"boundingBox":"396,723,17,9","text":"GR)"}]},{"boundingBox":"214,746,318,9","words":[{"boundingBox":"214,746,18,8","text":"COH"},{"boundingBox":"239,746,38,8","text":"BATATA"},{"boundingBox":"284,746,12,8","text":"00"},{"boundingBox":"304,746,23,9","text":"DIA."},{"boundingBox":"335,746,38,8","text":"CEBOLA"},{"boundingBox":"380,746,76,8","text":"CARAMELIZADA"},{"boundingBox":"464,746,5,8","text":"E"},{"boundingBox":"476,746,56,8","text":"COGUMELOS"}]},{"boundingBox":"297,766,151,11","words":[{"boundingBox":"297,768,31,8","text":"MOLHO"},{"boundingBox":"335,766,44,10","text":"BEARNÊS"},{"boundingBox":"387,768,61,9","text":"(OPCIONAL)"}]},{"boundingBox":"285,791,176,9","words":[{"boundingBox":"285,791,75,9","text":"(RECOMENDADO"},{"boundingBox":"368,791,24,8","text":"PARA"},{"boundingBox":"399,791,5,8","text":"2"},{* Connection #0 to host southeastasia.api.cognitive.microsoft.com left intact
"boundingBox":"412,791,49,9","text":"PESSOAS)"}]}]}]}