Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OcrResult variable Language of the wrong type. #4083

Closed
dumonjorne opened this issue Feb 20, 2018 · 2 comments · Fixed by Azure/azure-rest-api-specs#3145
Closed

OcrResult variable Language of the wrong type. #4083

dumonjorne opened this issue Feb 20, 2018 · 2 comments · Fixed by Azure/azure-rest-api-specs#3145
Labels
Cognitive Services Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@dumonjorne
Copy link

Hi,

In Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models.OcrResult, variable Language is of the wrong type, resulting in a failing json deserialization. It should be of type OcrLanguage instead of OcrResult.

@brminnick
Copy link

brminnick commented May 24, 2018

Here's my workaround for anyone else who is struggling with this error.

I created my own OcrResultModel that uses the correct type, OcrLanguages. I then create a new OcrResult, assigning Language = default(OcrResult)

Here's a link to my Xamarin app where I use this workaround: https://github.com/brminnick/XamSpeak/blob/master/Source/XamSpeak/Services/OCRServices.cs#L33

public static async Task<OcrResult> GetOcrResultsFromMediaFile(MediaFile mediaFile)
{
	try
	{
		return await ComputerVisionApiClient.RecognizePrintedTextInStreamAsync(true, ConverterHelpers.ConvertMediaFileToStream(mediaFile, false)).ConfigureAwait(false);
	}
	catch (ComputerVisionErrorException e) when (e.Response.StatusCode.Equals(HttpStatusCode.Unauthorized))
	{
		DebugHelpers.PrintException(e);

		OnInvalidComputerVisionAPIKey();

		throw;
	}
        catch (Microsoft.Rest.SerializationException e)
	{
		var xamSpeakOcrResult = JsonConvert.DeserializeObject<XamSpeakOcrResult>(e.Content);

		return new OcrResult
		{
			Language = default(OcrResult),
			Orientation = xamSpeakOcrResult.Orientation,
			Regions = xamSpeakOcrResult.Regions,
                        TextAngle = xamSpeakOcrResult.TextAngle
		};
	}
}
using System.Collections.Generic;

using Newtonsoft.Json;

using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;

namespace XamSpeak
{
	public class XamSpeakOcrResult
	{
		[JsonProperty("language")]
		public OcrLanguages Language { get; set; }

		[JsonProperty("orientation")]
		public string Orientation { get; set; }

		[JsonProperty("textAngle")]
		public double TextAngle { get; set; }

		[JsonProperty("regions")]
		public List<OcrRegion> Regions { get; set; }
	}
}

@brminnick
Copy link

To fix this bug, change this line of code in the SDK:

Change
public OcrResult Language { get; set; }
To
public OcrLanguages Language { get; set; }

cthrash added a commit to cthrash/azure-rest-api-specs that referenced this issue May 29, 2018
* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-python that referenced this issue May 29, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to AutorestCI/azure-libraries-for-java that referenced this issue May 29, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-node that referenced this issue May 29, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-ruby that referenced this issue May 29, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-go that referenced this issue May 29, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
anuchandy pushed a commit to Azure/azure-rest-api-specs that referenced this issue Jun 5, 2018
* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-python that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-node that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to AutorestCI/azure-libraries-for-java that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-ruby that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-go that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
AutorestCI added a commit to Azure/azure-sdk-for-go that referenced this issue Jun 5, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
jhendrixMSFT pushed a commit to Azure/azure-sdk-for-go that referenced this issue Jun 7, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
sarangan12 pushed a commit to Azure/azure-sdk-for-ruby that referenced this issue Jun 13, 2018
* Generated from bd6c66b615b94480a1458dde3a8bc42f3a689548 (#1322)

ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models

* Generated from b35c48945774ac7be9bf0fa05e19c0890141bb3d (#1364)

Add Spanish as an option as ServiceLanguage for ComputerVision.
AutorestCI added a commit to Azure/azure-sdk-for-python that referenced this issue Jun 21, 2018
ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models
lmazuel pushed a commit to Azure/azure-sdk-for-python that referenced this issue Jun 22, 2018
* Generated from 984c12a568b2dd36acb521eb3b1c00fbd5b42995 (#2575)

Update CognitiveService ComputerVision Swagger for new extensions (#1)

* Merged PR 17875: Add new languages

Add new languages

Also tidy up the enum definition so that AutoRest generates C# that actually compiles

* Merged PR 17942: Replace fancy quotes with plain single quotes

Make javac compile without complaint even without setting the codepage to utf-8 by dropping the gratuitous typographic quotes.

* Merged PR 17956: Rename url argument for overloaded endpoint to imageUrl

This name will become the name of the argument in Python.  Since you can used named arguments in Python, give them less ambiguous names.

* Changes to make --azure-validator run more cleanly

Errors Fixed
* XmsExamplesRequired/D5001/Documentation (7)
* XmsPathsMustOverloadPaths/R2058/SDKViolation (7)

Errors Ignored
* SecurityDefinitionsStructure/R2054/SDKViolation (1) - API Key scheme for Cognitive Services
* APIVersionPattern/R3012/ARMViolation (1) - Keeping with the Cognitive Services numbering scheme
* OperationsAPIImplementation/R3023/ARMViolation (1) - Not sure what this is

Warnings Fixed
* XmsEnumValidation/R2018/SDKViolation (1)
* DescriptionAndTitleMissing/R4000/SDKViolation (1)

Warnings Ignored
* DescriptionAndTitleMissing/R4000/SDKViolation (35) - description is contained in #ref
* EnumInsteadOfBoolean/R3018/ARMViolation (5) - fix would be a breaking change
* ListInOperationName/R1003/SDKViolation (1) - fix would be a breaking change
* LongRunningOperationsWithLongRunningExtension/R2007/SDKViolation (2) - endpoint will not ultimately yield a 200, as this extension would require
* NonApplicationJsonType/R2004/ARMViolation (15) - fix would be breaking change
* PageableOperation/R2029/SDKViolation (1) - not actually pageable
* ParameterNotDefinedInGlobalParameters/R2015/SDKViolation (1) - All our own parameters specify x-ms-parameter-location
* PostOperationIdContainsUrlVerb/R2066/SDKViolation (7) - fix would be breaking change

* Generated from bd6c66b615b94480a1458dde3a8bc42f3a689548 (#2645)

ComputerVision - collection of fixes

* fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083)
* language parameter missing for /tag path
* language parameter missing for /models/*/analyze path
* make /models/*/analyze return a more generic type
* add specific types for /models/*/analyze to return for current models

* Generated from b35c48945774ac7be9bf0fa05e19c0890141bb3d (#2731)

Add Spanish as an option as ServiceLanguage for ComputerVision.

* [AutoPR cognitiveservices/data-plane/ComputerVision] Update CognitiveService ComputerVision API to V2 (#2747)

* Generated from c2567da015994dac3301f495b6c5011d28ceaffe

Add post-processing directive to swap argument order for RecognizeText to position the url argument ahead of the mode argument.

autorest does not generate the intended order, so we add a post-processing directive,
for each target language,

* Generated from 973322cfd6ec2ced60a732f53b5318ceded5de7b

Fix validation errors

* Generated from 70efe042d607cbd973734e432da395ed35191a03

Add Spanish support for ServiceLanguage

This is for parity with V1.

* Generated from 6492fb4e04a3e5d7330ceccbb9f67e2a839e2290 (#2775)

ComputerVision add tag.hint

Hints provided additional info for whole-image analysis tags.
This PR is to make the Swagger match the service behavior.

* Update version.py

* ComputerVision 0.2.0 packaging
@bsiegel bsiegel added the Service Attention Workflow: This issue is responsible by Azure service team. label Sep 26, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Cognitive Services Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants