Reputation: 1192
I was trying this tutorial in Xamarin: Performing OCR for iOS, Android, and Windows with Microsoft Cognitive Services
But I get an: Exception of type 'Microsoft.ProjectOxford.Vision.ClientException' was thrown.'
It happens in the line:text = await client.RecognizeTextAsync(photoStream); I have looked at other post (none Xamarin) and they solved by setting the position of the stream to 0. I tried it but still get the same error. The tutorial was written by Pierce Boggan. Thanks for any help.
OcrResults text;
var client = new VisionServiceClient("my api key");
using (var photoStream = photo.GetStream())
text = await client.RecognizeTextAsync(photoStream);
Upvotes: 0
Views: 336
Reputation: 10831
It happens in the line:text = await client.RecognizeTextAsync(photoStream); I have looked at other post (none Xamarin) and they solved by setting the position of the stream to 0. I tried it but still get the same error.
Different Areas have different Rest API Url, So in most cases, you need to set your apiRoot
manually, which wasn't mentioned the tutorial, you posted. For detailed description, you can refer to Obtain Subscription Keyps.
To do that, you can obtain the API url in your subscription page:
And use the url to construct VisionServiceClient
object:
OcrResults text;
var client=new VisionServiceClient("Your API Key", "https://westcentralus.api.cognitive.microsoft.com/vision/v1.0");
using (var stream = photo.GetStream())
...
Upvotes: 2