Azure-Samples / cognitive-services-quickstart-code

Code Examples used by the Quickstarts in the Cognitive Services Documentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cognitive Services C# sample code broken

noumanqaiser opened this issue · comments

commented

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I created a windows Forms Application(.Net Framework 4.7) and utilized the sample code given at the link below: https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/dotnet/ComputerVision/ComputerVisionQuickstart.cs

My purpose was to be able to read text out of a local image. However It seems despite having a valid endpoint/subscription key, the function: await client.ReadInStreamAsync(File.OpenRead(localFile), language: "en") never completes and program is held up at this point indefinitely. I tried Cognitive services API which seems to be working just fine.

Any log messages given by the failure

No Error given, the called function never completes.

Expected/desired behavior

The function should complete and provide read text results from the image.

OS and Version?

Windows 10

Versions

NA

Mention any other details that might be useful

No others.


Thanks! We'll be in touch soon.

Hello @noumanqaiser,

First I apologize for my delayed reply. I have just re-tested this sample and made several minor fixes as a result.

  • I added null checks to several sections in the AnalyzeImageLocal function.
  • I fixed a bug where the subscriptionKey and endpoint variables were set to "COMPUTER_VISION_SUBSCRIPTION_KEY" and "COMPUTER_VISION_ENDPOINT", respectively, instead of to the values of the corresponding environment variables, as they should be.
  • I changed the value of READ_TEXT_LOCAL_IMAGE from "print_text.png" to "printed_text.jpg" to correspond to the file being renamed in https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images.

However, I do not see that any of these fixes should affect the issue you are reporting. I am currently unable to reproduce the issue. If possible, can you please try:

  1. Running the sample again with the updated code, using local images celebrities.jpg, objects.jpg, and printed_text.jpg downloaded from https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images.

  2. If that does not work, can you tell me where I can obtain the file you are passing to client.ReadInStreamAsync? I can then try to reproduce the issue with that file and pass it on to the product team for analysis.

Thank you for your patience and I apologize for the issue.
v-jaswel

Hello,

I am going to close this issue for now due to lack of activity, but please feel free to reopen it.

Thank you,
v-jaswel