diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index 755387022e18..64953a34cd18 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -18,7 +18,7 @@ com.microsoft.azure.cognitiveservices:azure-cognitiveservices-newssearch;1.1.0-b com.microsoft.azure.cognitiveservices:azure-cognitiveservices-videosearch;1.1.0-beta.1;1.1.0-beta.1 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-visualsearch;1.1.0-beta.1;1.1.0-beta.1 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-websearch;1.1.0-beta.1;1.1.0-beta.1 -com.microsoft.azure.cognitiveservices:azure-cognitiveservices-computervision;1.0.3-beta;1.0.3-beta +com.microsoft.azure.cognitiveservices:azure-cognitiveservices-computervision;1.0.4-beta;1.0.4-beta com.microsoft.azure.cognitiveservices:azure-cognitiveservices-contentmoderator;1.1.0-beta.1;1.1.0-beta.1 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-prediction;1.1.0-beta.3;1.1.0-beta.3 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-training;1.1.0-beta.3;1.1.0-beta.3 diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml b/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml index 0e1924609b71..4a03cfddaa0f 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml @@ -15,7 +15,7 @@ azure-cognitiveservices-computervision com.microsoft.azure.cognitiveservices - 1.0.3-beta + 1.0.4-beta jar Microsoft Azure SDK for Cognitive Service Computer Vision This package contains Microsoft Cognitive Service Computer Vision SDK. @@ -92,4 +92,4 @@ - \ No newline at end of file + diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVision.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVision.java index cb7f1679827d..22dfd80cde78 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVision.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVision.java @@ -8,204 +8,142 @@ package com.microsoft.azure.cognitiveservices.vision.computervision; -import com.microsoft.azure.CloudException; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextInStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageInStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageOptionalParameter; +import com.microsoft.azure.CloudException; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorException; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescriptionExclude; import com.microsoft.azure.cognitiveservices.vision.computervision.models.Details; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DetectResult; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DomainModelResults; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ImageAnalysis; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ImageDescription; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ListModelsResult; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage; import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrLanguages; import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrResult; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadOperationResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TextOperationResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TextRecognitionMode; import com.microsoft.azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes; -import rx.Observable; - import java.io.InputStream; import java.util.List; +import java.util.UUID; +import rx.Observable; /** * An instance of this class provides access to all the operations defined * in ComputerVision. */ public interface ComputerVision { - - /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art - * Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use - * the Read Document interface, the response contains a field called 'Operation-Location'. The - * 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' - * to access OCR results. - * - * @param image An image stream. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void batchReadFileInStream(byte[] image); - - /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art - * Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use - * the Read Document interface, the response contains a field called 'Operation-Location'. The - * 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' - * to access OCR results. - * - * @param image An image stream. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. - */ - Observable batchReadFileInStreamAsync(byte[] image); - - - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field - * called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for - * your Get Recognize Text Operation Result operation. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ComputerVisionErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - void recognizeTextInStream(byte[] image, TextRecognitionMode mode); + void readInStream(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter); /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field - * called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for - * your Get Recognize Text Operation Result operation. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return a representation of the deferred computation of this call if successful. */ - Observable recognizeTextInStreamAsync(byte[] image, TextRecognitionMode mode); - - - - /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should - * be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the ReadOperationResult object if successful. - */ - ReadOperationResult getReadOperationResult(String operationId); + Observable readInStreamAsync(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter); /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should - * be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the ReadOperationResult object - */ - Observable getReadOperationResultAsync(String operationId); - - - - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical - * Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read - * File interface, the response contains a field called 'Operation-Location'. The - * 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' - * operation to access OCR results. - * - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void batchReadFile(String url); - - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical - * Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read - * File interface, the response contains a field called 'Operation-Location'. The - * 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' - * operation to access OCR results. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. * - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the first stage of the readInStream call */ - Observable batchReadFileAsync(String url); - - + ComputerVisionReadInStreamDefinitionStages.WithImage readInStream(); /** - * This interface is used for getting text operation result. The URL to this interface should be - * retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text'. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the TextOperationResult object if successful. + * Grouping of readInStream definition stages. */ - TextOperationResult getTextOperationResult(String operationId); + interface ComputerVisionReadInStreamDefinitionStages { + /** + * The stage of the definition to be specify image. + */ + interface WithImage { + /** + * An image stream. + * + * @return next definition stage + */ + ComputerVisionReadInStreamDefinitionStages.WithExecute withImage(byte[] image); + } - /** - * This interface is used for getting text operation result. The URL to this interface should be - * retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text'. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the TextOperationResult object - */ - Observable getTextOperationResultAsync(String operationId); + /** + * The stage of the definition which allows for any other optional settings to be specified. + */ + interface WithAllOptions { + /** + * The BCP-47 language code of the text to be detected in the image. In future versions, when language + * parameter is not passed, language detection will be used to determine the language. However, in the current + * version, missing language parameter will cause English to be used. To ensure that your document is always + * parsed in English without the use of language detection in the future, pass “en” in the language parameter. + * Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', 'pt'. + * + * @return next definition stage + */ + ComputerVisionReadInStreamDefinitionStages.WithExecute withLanguage(OcrDetectionLanguage language); + } + /** + * The last stage of the definition which will make the operation call. + */ + interface WithExecute extends ComputerVisionReadInStreamDefinitionStages.WithAllOptions { + /** + * Execute the request. + * + */ + void execute(); - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field - * called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for - * your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'. - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void recognizeText(String url, TextRecognitionMode mode); + /** + * Execute the request asynchronously. + * + * @return a representation of the deferred computation of this call if successful. + */ + Observable executeAsync(); + } + } /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field - * called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for - * your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'. - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * The entirety of readInStream definition. */ - Observable recognizeTextAsync(String url, TextRecognitionMode mode); - + interface ComputerVisionReadInStreamDefinition extends + ComputerVisionReadInStreamDefinitionStages.WithImage, + ComputerVisionReadInStreamDefinitionStages.WithExecute { + } /** * This operation generates a list of words, or tags, that are relevant to the content of the supplied image. @@ -1020,6 +958,127 @@ interface ComputerVisionAnalyzeImageInStreamDefinition extends } + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should + * be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ComputerVisionErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReadOperationResult object if successful. + */ + ReadOperationResult getReadResult(UUID operationId); + + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should + * be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReadOperationResult object + */ + Observable getReadResultAsync(UUID operationId); + + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ComputerVisionErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void read(String url, ReadOptionalParameter readOptionalParameter); + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the deferred computation of this call if successful. + */ + Observable readAsync(String url, ReadOptionalParameter readOptionalParameter); + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character + * Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the + * response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that + * you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @return the first stage of the read call + */ + ComputerVisionReadDefinitionStages.WithUrl read(); + + /** + * Grouping of read definition stages. + */ + interface ComputerVisionReadDefinitionStages { + /** + * The stage of the definition to be specify url. + */ + interface WithUrl { + /** + * Publicly reachable URL of an image. + * + * @return next definition stage + */ + ComputerVisionReadDefinitionStages.WithExecute withUrl(String url); + } + + /** + * The stage of the definition which allows for any other optional settings to be specified. + */ + interface WithAllOptions { + /** + * The BCP-47 language code of the text to be detected in the image. In future versions, when language + * parameter is not passed, language detection will be used to determine the language. However, in the current + * version, missing language parameter will cause English to be used. To ensure that your document is always + * parsed in English without the use of language detection in the future, pass “en” in the language parameter. + * Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', 'pt'. + * + * @return next definition stage + */ + ComputerVisionReadDefinitionStages.WithExecute withLanguage(OcrDetectionLanguage language); + + } + + /** + * The last stage of the definition which will make the operation call. + */ + interface WithExecute extends ComputerVisionReadDefinitionStages.WithAllOptions { + /** + * Execute the request. + * + */ + void execute(); + + /** + * Execute the request asynchronously. + * + * @return a representation of the deferred computation of this call if successful. + */ + Observable executeAsync(); + } + } + + /** + * The entirety of read definition. + */ + interface ComputerVisionReadDefinition extends + ComputerVisionReadDefinitionStages.WithUrl, + ComputerVisionReadDefinitionStages.WithExecute { + } + + /** * This operation returns a bounding box around the most important area of the image. * A successful response will be returned in JSON. If the request failed, the response contains an diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java index 7cb29635a95f..54283a59d43a 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java @@ -27,7 +27,7 @@ public class ComputerVisionManager { * @return the Computer Vision API client */ public static ComputerVisionClient authenticate(String subscriptionKey) { - return authenticate("https://{endpoint}/vision/v2.1/", subscriptionKey); + return authenticate("https://{endpoint}/vision/v3.0/", subscriptionKey); } /** @@ -67,7 +67,7 @@ public Response intercept(Chain chain) throws IOException { * @return the Computer Vision API client */ public static ComputerVisionClient authenticate(ServiceClientCredentials credentials, String endpoint) { - return authenticate("https://{endpoint}/vision/v2.1/", credentials) + return authenticate("https://{endpoint}/vision/v3.0/", credentials) .withEndpoint(endpoint); } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionClientImpl.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionClientImpl.java index dd4a36ea98e7..217d1e1edfce 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionClientImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionClientImpl.java @@ -8,12 +8,31 @@ package com.microsoft.azure.cognitiveservices.vision.computervision.implementation; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision; import com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVisionClient; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorException; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.DetectResult; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.InputStream; +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; /** * Initializes a new instance of the ComputerVisionClientImpl class. @@ -141,7 +160,7 @@ public ComputerVision computerVision() { * @param credentials the management credentials for Azure */ public ComputerVisionClientImpl(ServiceClientCredentials credentials) { - this("https://{Endpoint}/vision/v2.1", credentials); + this("https://{Endpoint}/vision/v3.0", credentials); } /** @@ -180,6 +199,6 @@ protected void initialize() { */ @Override public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "ComputerVisionClient", "2.1"); + return String.format("%s (%s, %s)", super.userAgent(), "ComputerVisionClient", "3.0"); } } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java index 6ae903565bfe..188da0fbd000 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java @@ -8,42 +8,42 @@ package com.microsoft.azure.cognitiveservices.vision.computervision.implementation; -import com.google.common.base.Joiner; -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.CloudException; -import com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextInStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageInStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageInStreamOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageByDomainOptionalParameter; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AnalyzeImageOptionalParameter; +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; import com.microsoft.azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.BatchReadFileHeaders; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.BatchReadFileInStreamHeaders; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorException; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescribeImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DescriptionExclude; import com.microsoft.azure.cognitiveservices.vision.computervision.models.Details; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DetectResult; import com.microsoft.azure.cognitiveservices.vision.computervision.models.DomainModelResults; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.GenerateThumbnailOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ImageAnalysis; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ImageDescription; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ImageUrl; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ListModelsResult; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage; import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrLanguages; import com.microsoft.azure.cognitiveservices.vision.computervision.models.OcrResult; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadHeaders; +import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadInStreamHeaders; import com.microsoft.azure.cognitiveservices.vision.computervision.models.ReadOperationResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizePrintedTextOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizeTextHeaders; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.RecognizeTextInStreamHeaders; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageInStreamOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagImageOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.computervision.models.TagResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TextOperationResult; -import com.microsoft.azure.cognitiveservices.vision.computervision.models.TextRecognitionMode; import com.microsoft.azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes; import com.microsoft.rest.CollectionFormat; import com.microsoft.rest.ServiceCallback; @@ -51,25 +51,24 @@ import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.ServiceResponseWithHeaders; import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; import okhttp3.MediaType; import okhttp3.RequestBody; import okhttp3.ResponseBody; -import retrofit2.Response; -import retrofit2.Retrofit; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; -import retrofit2.http.POST; import retrofit2.http.Path; +import retrofit2.http.POST; import retrofit2.http.Query; import retrofit2.http.Streaming; -import rx.Observable; +import retrofit2.Response; import rx.functions.Func1; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; +import rx.Observable; /** * An instance of this class provides access to all the operations defined @@ -97,29 +96,9 @@ public ComputerVisionImpl(Retrofit retrofit, ComputerVisionClientImpl client) { * used by Retrofit to perform actually REST calls. */ interface ComputerVisionService { - @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision batchReadFileInStream" }) - @POST("read/core/asyncBatchAnalyze") - Observable> batchReadFileInStream(@Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision recognizeTextInStream" }) - @POST("recognizeText") - Observable> recognizeTextInStream(@Body RequestBody image, @Query("mode") TextRecognitionMode mode, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision getReadOperationResult" }) - @GET("read/operations/{operationId}") - Observable> getReadOperationResult(@Path("operationId") String operationId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision batchReadFile" }) - @POST("read/core/asyncBatchAnalyze") - Observable> batchReadFile(@Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision getTextOperationResult" }) - @GET("textOperations/{operationId}") - Observable> getTextOperationResult(@Path("operationId") String operationId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision recognizeText" }) - @POST("recognizeText") - Observable> recognizeText(@Query("mode") TextRecognitionMode mode, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision readInStream" }) + @POST("read/analyze") + Observable> readInStream(@Query("language") OcrDetectionLanguage language, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision tagImageInStream" }) @POST("tag") @@ -152,7 +131,15 @@ interface ComputerVisionService { @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision analyzeImageInStream" }) @POST("analyze") - Observable> analyzeImageInStream(@Query("visualFeatures") String visualFeatures, @Query("details") String details1, @Query("language") String language, @Query("descriptionExclude") String descriptionExclude1, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> analyzeImageInStream(@Query("visualFeatures") String visualFeatures, @Query("details") String details, @Query("language") String language, @Query("descriptionExclude") String descriptionExclude1, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision getReadResult" }) + @GET("read/analyzeResults/{operationId}") + Observable> getReadResult(@Path("operationId") UUID operationId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision read" }) + @POST("read/analyze") + Observable> read(@Query("language") OcrDetectionLanguage language, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision getAreaOfInterest" }) @POST("areaOfInterest") @@ -189,156 +176,97 @@ interface ComputerVisionService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.computervision.ComputerVision analyzeImage" }) @POST("analyze") - Observable> analyzeImage(@Query("visualFeatures") String visualFeatures, @Query("details") String details1, @Query("language") String language, @Query("descriptionExclude") String descriptionExclude1, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> analyzeImage(@Query("visualFeatures") String visualFeatures, @Query("details") String details, @Query("language") String language, @Query("descriptionExclude") String descriptionExclude1, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } + /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read Document interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' to access OCR results. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ComputerVisionErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void batchReadFileInStream(byte[] image) { - batchReadFileInStreamWithServiceResponseAsync(image).toBlocking().single().body(); + public void readInStream(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter) { + readInStreamWithServiceResponseAsync(image, readInStreamOptionalParameter).toBlocking().single().body(); } /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read Document interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' to access OCR results. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture batchReadFileInStreamAsync(byte[] image, final ServiceCallback serviceCallback) { - return ServiceFuture.fromHeaderResponse(batchReadFileInStreamWithServiceResponseAsync(image), serviceCallback); + public ServiceFuture readInStreamAsync(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(readInStreamWithServiceResponseAsync(image, readInStreamOptionalParameter), serviceCallback); } /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read Document interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' to access OCR results. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponseWithHeaders} object if successful. */ - public Observable batchReadFileInStreamAsync(byte[] image) { - return batchReadFileInStreamWithServiceResponseAsync(image).map(new Func1, Void>() { + public Observable readInStreamAsync(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter) { + return readInStreamWithServiceResponseAsync(image, readInStreamOptionalParameter).map(new Func1, Void>() { @Override - public Void call(ServiceResponseWithHeaders response) { + public Void call(ServiceResponseWithHeaders response) { return response.body(); } }); } /** - * Use this interface to get the result of a Read Document operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read Document interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'Get Read Result operation' to access OCR results. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. + * @param readInStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponseWithHeaders} object if successful. */ - public Observable> batchReadFileInStreamWithServiceResponseAsync(byte[] image) { + public Observable> readInStreamWithServiceResponseAsync(byte[] image, ReadInStreamOptionalParameter readInStreamOptionalParameter) { if (this.client.endpoint() == null) { throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); - return service.batchReadFileInStream(imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponseWithHeaders clientResponse = batchReadFileInStreamDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponseWithHeaders batchReadFileInStreamDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(202, new TypeToken() { }.getType()) - .registerError(ComputerVisionErrorException.class) - .buildWithHeaders(response, BatchReadFileInStreamHeaders.class); - } - - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void recognizeTextInStream(byte[] image, TextRecognitionMode mode) { - recognizeTextInStreamWithServiceResponseAsync(image, mode).toBlocking().single().body(); - } + final OcrDetectionLanguage language = readInStreamOptionalParameter != null ? readInStreamOptionalParameter.language() : null; - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture recognizeTextInStreamAsync(byte[] image, TextRecognitionMode mode, final ServiceCallback serviceCallback) { - return ServiceFuture.fromHeaderResponse(recognizeTextInStreamWithServiceResponseAsync(image, mode), serviceCallback); - } - - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponseWithHeaders} object if successful. - */ - public Observable recognizeTextInStreamAsync(byte[] image, TextRecognitionMode mode) { - return recognizeTextInStreamWithServiceResponseAsync(image, mode).map(new Func1, Void>() { - @Override - public Void call(ServiceResponseWithHeaders response) { - return response.body(); - } - }); + return readInStreamWithServiceResponseAsync(image, language); } /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. * * @param image An image stream. - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' + * @param language The BCP-47 language code of the text to be detected in the image. In future versions, when language parameter is not passed, language detection will be used to determine the language. However, in the current version, missing language parameter will cause English to be used. To ensure that your document is always parsed in English without the use of language detection in the future, pass “en” in the language parameter. Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', 'pt' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponseWithHeaders} object if successful. */ - public Observable> recognizeTextInStreamWithServiceResponseAsync(byte[] image, TextRecognitionMode mode) { + public Observable> readInStreamWithServiceResponseAsync(byte[] image, OcrDetectionLanguage language) { if (this.client.endpoint() == null) { throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } - if (mode == null) { - throw new IllegalArgumentException("Parameter mode is required and cannot be null."); - } String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); - return service.recognizeTextInStream(imageConverted, mode, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + return service.readInStream(language, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponseWithHeaders clientResponse = recognizeTextInStreamDelegate(response); + ServiceResponseWithHeaders clientResponse = readInStreamDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -347,328 +275,60 @@ public Observable }); } - private ServiceResponseWithHeaders recognizeTextInStreamDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { + private ServiceResponseWithHeaders readInStreamDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) .register(202, new TypeToken() { }.getType()) .registerError(ComputerVisionErrorException.class) - .buildWithHeaders(response, RecognizeTextInStreamHeaders.class); - } - - /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the ReadOperationResult object if successful. - */ - public ReadOperationResult getReadOperationResult(String operationId) { - return getReadOperationResultWithServiceResponseAsync(operationId).toBlocking().single().body(); + .buildWithHeaders(response, ReadInStreamHeaders.class); } - /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture getReadOperationResultAsync(String operationId, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(getReadOperationResultWithServiceResponseAsync(operationId), serviceCallback); + @Override + public ComputerVisionReadInStreamParameters readInStream() { + return new ComputerVisionReadInStreamParameters(this); } /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the ReadOperationResult object + * Internal class implementing ComputerVisionReadInStreamDefinition. */ - public Observable getReadOperationResultAsync(String operationId) { - return getReadOperationResultWithServiceResponseAsync(operationId).map(new Func1, ReadOperationResult>() { - @Override - public ReadOperationResult call(ServiceResponse response) { - return response.body(); - } - }); - } + class ComputerVisionReadInStreamParameters implements ComputerVisionReadInStreamDefinition { + private ComputerVisionImpl parent; + private byte[] image; + private OcrDetectionLanguage language; - /** - * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Batch Read File interface. - * - * @param operationId Id of read operation returned in the response of the 'Batch Read File' interface. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the ReadOperationResult object - */ - public Observable> getReadOperationResultWithServiceResponseAsync(String operationId) { - if (this.client.endpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); - } - if (operationId == null) { - throw new IllegalArgumentException("Parameter operationId is required and cannot be null."); + /** + * Constructor. + * @param parent the parent object. + */ + ComputerVisionReadInStreamParameters(ComputerVisionImpl parent) { + this.parent = parent; } - String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - return service.getReadOperationResult(operationId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getReadOperationResultDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getReadOperationResultDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(ComputerVisionErrorException.class) - .build(response); - } - - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read File interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' operation to access OCR results. - * - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void batchReadFile(String url) { - batchReadFileWithServiceResponseAsync(url).toBlocking().single().body(); - } - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read File interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' operation to access OCR results. - * - * @param url Publicly reachable URL of an image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture batchReadFileAsync(String url, final ServiceCallback serviceCallback) { - return ServiceFuture.fromHeaderResponse(batchReadFileWithServiceResponseAsync(url), serviceCallback); - } - - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read File interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' operation to access OCR results. - * - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponseWithHeaders} object if successful. - */ - public Observable batchReadFileAsync(String url) { - return batchReadFileWithServiceResponseAsync(url).map(new Func1, Void>() { - @Override - public Void call(ServiceResponseWithHeaders response) { - return response.body(); - } - }); - } - - /** - * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read File interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadOperationResult' operation to access OCR results. - * - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponseWithHeaders} object if successful. - */ - public Observable> batchReadFileWithServiceResponseAsync(String url) { - if (this.client.endpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); - } - if (url == null) { - throw new IllegalArgumentException("Parameter url is required and cannot be null."); + @Override + public ComputerVisionReadInStreamParameters withImage(byte[] image) { + this.image = image; + return this; } - ImageUrl imageUrl = new ImageUrl(); - imageUrl.withUrl(url); - String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - return service.batchReadFile(this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponseWithHeaders clientResponse = batchReadFileDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponseWithHeaders batchReadFileDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(202, new TypeToken() { }.getType()) - .registerError(ComputerVisionErrorException.class) - .buildWithHeaders(response, BatchReadFileHeaders.class); - } - - /** - * This interface is used for getting text operation result. The URL to this interface should be retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the TextOperationResult object if successful. - */ - public TextOperationResult getTextOperationResult(String operationId) { - return getTextOperationResultWithServiceResponseAsync(operationId).toBlocking().single().body(); - } - - /** - * This interface is used for getting text operation result. The URL to this interface should be retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text' - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture getTextOperationResultAsync(String operationId, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(getTextOperationResultWithServiceResponseAsync(operationId), serviceCallback); - } - /** - * This interface is used for getting text operation result. The URL to this interface should be retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the TextOperationResult object - */ - public Observable getTextOperationResultAsync(String operationId) { - return getTextOperationResultWithServiceResponseAsync(operationId).map(new Func1, TextOperationResult>() { - @Override - public TextOperationResult call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * This interface is used for getting text operation result. The URL to this interface should be retrieved from 'Operation-Location' field returned from Recognize Text interface. - * - * @param operationId Id of the text operation returned in the response of the 'Recognize Text' - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the TextOperationResult object - */ - public Observable> getTextOperationResultWithServiceResponseAsync(String operationId) { - if (this.client.endpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); - } - if (operationId == null) { - throw new IllegalArgumentException("Parameter operationId is required and cannot be null."); + @Override + public ComputerVisionReadInStreamParameters withLanguage(OcrDetectionLanguage language) { + this.language = language; + return this; } - String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - return service.getTextOperationResult(operationId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getTextOperationResultDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getTextOperationResultDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(ComputerVisionErrorException.class) - .build(response); - } - - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ComputerVisionErrorException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void recognizeText(String url, TextRecognitionMode mode) { - recognizeTextWithServiceResponseAsync(url, mode).toBlocking().single().body(); - } - - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @param url Publicly reachable URL of an image. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture recognizeTextAsync(String url, TextRecognitionMode mode, final ServiceCallback serviceCallback) { - return ServiceFuture.fromHeaderResponse(recognizeTextWithServiceResponseAsync(url, mode), serviceCallback); - } - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponseWithHeaders} object if successful. - */ - public Observable recognizeTextAsync(String url, TextRecognitionMode mode) { - return recognizeTextWithServiceResponseAsync(url, mode).map(new Func1, Void>() { - @Override - public Void call(ServiceResponseWithHeaders response) { - return response.body(); - } - }); + @Override + public void execute() { + readInStreamWithServiceResponseAsync(image, language).toBlocking().single().body(); } - /** - * Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation. - * - * @param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed' - * @param url Publicly reachable URL of an image. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponseWithHeaders} object if successful. - */ - public Observable> recognizeTextWithServiceResponseAsync(String url, TextRecognitionMode mode) { - if (this.client.endpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); - } - if (mode == null) { - throw new IllegalArgumentException("Parameter mode is required and cannot be null."); - } - if (url == null) { - throw new IllegalArgumentException("Parameter url is required and cannot be null."); - } - ImageUrl imageUrl = new ImageUrl(); - imageUrl.withUrl(url); - String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - return service.recognizeText(mode, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + @Override + public Observable executeAsync() { + return readInStreamWithServiceResponseAsync(image, language).map(new Func1, Void>() { @Override - public Observable> call(Response response) { - try { - ServiceResponseWithHeaders clientResponse = recognizeTextDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } + public Void call(ServiceResponseWithHeaders response) { + return response.body(); } }); - } - - private ServiceResponseWithHeaders recognizeTextDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(202, new TypeToken() { }.getType()) - .registerError(ComputerVisionErrorException.class) - .buildWithHeaders(response, RecognizeTextHeaders.class); + } } @@ -1927,6 +1587,235 @@ public ImageAnalysis call(ServiceResponse response) { } } + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ComputerVisionErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReadOperationResult object if successful. + */ + public ReadOperationResult getReadResult(UUID operationId) { + return getReadResultWithServiceResponseAsync(operationId).toBlocking().single().body(); + } + + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getReadResultAsync(UUID operationId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getReadResultWithServiceResponseAsync(operationId), serviceCallback); + } + + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReadOperationResult object + */ + public Observable getReadResultAsync(UUID operationId) { + return getReadResultWithServiceResponseAsync(operationId).map(new Func1, ReadOperationResult>() { + @Override + public ReadOperationResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Read interface. + * + * @param operationId Id of read operation returned in the response of the 'Read' interface. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReadOperationResult object + */ + public Observable> getReadResultWithServiceResponseAsync(UUID operationId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (operationId == null) { + throw new IllegalArgumentException("Parameter operationId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getReadResult(operationId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getReadResultDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getReadResultDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ComputerVisionErrorException.class) + .build(response); + } + + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ComputerVisionErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void read(String url, ReadOptionalParameter readOptionalParameter) { + readWithServiceResponseAsync(url, readOptionalParameter).toBlocking().single().body(); + } + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture readAsync(String url, ReadOptionalParameter readOptionalParameter, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(readWithServiceResponseAsync(url, readOptionalParameter), serviceCallback); + } + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable readAsync(String url, ReadOptionalParameter readOptionalParameter) { + return readWithServiceResponseAsync(url, readOptionalParameter).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param readOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> readWithServiceResponseAsync(String url, ReadOptionalParameter readOptionalParameter) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final OcrDetectionLanguage language = readOptionalParameter != null ? readOptionalParameter.language() : null; + + return readWithServiceResponseAsync(url, language); + } + + /** + * Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.​. + * + * @param url Publicly reachable URL of an image. + * @param language The BCP-47 language code of the text to be detected in the image. In future versions, when language parameter is not passed, language detection will be used to determine the language. However, in the current version, missing language parameter will cause English to be used. To ensure that your document is always parsed in English without the use of language detection in the future, pass “en” in the language parameter. Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', 'pt' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> readWithServiceResponseAsync(String url, OcrDetectionLanguage language) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.read(language, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = readDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponseWithHeaders readDelegate(Response response) throws ComputerVisionErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(ComputerVisionErrorException.class) + .buildWithHeaders(response, ReadHeaders.class); + } + + @Override + public ComputerVisionReadParameters read() { + return new ComputerVisionReadParameters(this); + } + + /** + * Internal class implementing ComputerVisionReadDefinition. + */ + class ComputerVisionReadParameters implements ComputerVisionReadDefinition { + private ComputerVisionImpl parent; + private String url; + private OcrDetectionLanguage language; + + /** + * Constructor. + * @param parent the parent object. + */ + ComputerVisionReadParameters(ComputerVisionImpl parent) { + this.parent = parent; + } + + @Override + public ComputerVisionReadParameters withUrl(String url) { + this.url = url; + return this; + } + + @Override + public ComputerVisionReadParameters withLanguage(OcrDetectionLanguage language) { + this.language = language; + return this; + } + + @Override + public void execute() { + readWithServiceResponseAsync(url, language).toBlocking().single().body(); + } + + @Override + public Observable executeAsync() { + return readWithServiceResponseAsync(url, language).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + } + /** * This operation returns a bounding box around the most important area of the image. A successful response will be returned in JSON. If the request failed, the response contains an error code and a message to help determine what went wrong. diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/AnalyzeResults.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/AnalyzeResults.java new file mode 100644 index 000000000000..9583d598cd73 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/AnalyzeResults.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.computervision.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Analyze batch operation result. + */ +public class AnalyzeResults { + /** + * Version of schema used for this result. + */ + @JsonProperty(value = "version", required = true) + private String version; + + /** + * Text extracted from the input. + */ + @JsonProperty(value = "readResults", required = true) + private List readResults; + + /** + * Get the version value. + * + * @return the version value + */ + public String version() { + return this.version; + } + + /** + * Set the version value. + * + * @param version the version value to set + * @return the AnalyzeResults object itself. + */ + public AnalyzeResults withVersion(String version) { + this.version = version; + return this; + } + + /** + * Get the readResults value. + * + * @return the readResults value + */ + public List readResults() { + return this.readResults; + } + + /** + * Set the readResults value. + * + * @param readResults the readResults value to set + * @return the AnalyzeResults object itself. + */ + public AnalyzeResults withReadResults(List readResults) { + this.readResults = readResults; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileInStreamHeaders.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileInStreamHeaders.java deleted file mode 100644 index 62e02c24f58e..000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileInStreamHeaders.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.cognitiveservices.vision.computervision.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Defines headers for BatchReadFileInStream operation. - */ -public class BatchReadFileInStreamHeaders { - /** - * URL to query for status of the operation. The operation ID will expire - * in 48 hours. - */ - @JsonProperty(value = "Operation-Location") - private String operationLocation; - - /** - * Get the operationLocation value. - * - * @return the operationLocation value - */ - public String operationLocation() { - return this.operationLocation; - } - - /** - * Set the operationLocation value. - * - * @param operationLocation the operationLocation value to set - * @return the BatchReadFileInStreamHeaders object itself. - */ - public BatchReadFileInStreamHeaders withOperationLocation(String operationLocation) { - this.operationLocation = operationLocation; - return this; - } - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Line.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Line.java index 308c35b4e064..ab137c3f599e 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Line.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Line.java @@ -15,24 +15,51 @@ * An object representing a recognized text line. */ public class Line { + /** + * The BCP-47 language code of the recognized text line. Only provided + * where the language of the line differs from the page's. + */ + @JsonProperty(value = "language") + private String language; + /** * Bounding box of a recognized line. */ - @JsonProperty(value = "boundingBox") + @JsonProperty(value = "boundingBox", required = true) private List boundingBox; /** * The text content of the line. */ - @JsonProperty(value = "text") + @JsonProperty(value = "text", required = true) private String text; /** * List of words in the text line. */ - @JsonProperty(value = "words") + @JsonProperty(value = "words", required = true) private List words; + /** + * Get the language value. + * + * @return the language value + */ + public String language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the Line object itself. + */ + public Line withLanguage(String language) { + this.language = language; + return this; + } + /** * Get the boundingBox value. * diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OcrDetectionLanguage.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OcrDetectionLanguage.java new file mode 100644 index 000000000000..0e1cc6dcd9c9 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OcrDetectionLanguage.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.computervision.models; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for OcrDetectionLanguage. + */ +public final class OcrDetectionLanguage extends ExpandableStringEnum { + /** Static value en for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage EN = fromString("en"); + + /** Static value es for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage ES = fromString("es"); + + /** Static value fr for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage FR = fromString("fr"); + + /** Static value de for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage DE = fromString("de"); + + /** Static value it for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage IT = fromString("it"); + + /** Static value nl for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage NL = fromString("nl"); + + /** Static value pt for OcrDetectionLanguage. */ + public static final OcrDetectionLanguage PT = fromString("pt"); + + /** + * Creates or finds a OcrDetectionLanguage from its string representation. + * @param name a name to look for + * @return the corresponding OcrDetectionLanguage + */ + @JsonCreator + public static OcrDetectionLanguage fromString(String name) { + return fromString(name, OcrDetectionLanguage.class); + } + + /** + * @return known OcrDetectionLanguage values + */ + public static Collection values() { + return values(OcrDetectionLanguage.class); + } +} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionMode.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OperationStatusCodes.java similarity index 51% rename from sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionMode.java rename to sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OperationStatusCodes.java index 8a33c1ee4d69..f5a881200fa1 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionMode.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/OperationStatusCodes.java @@ -12,32 +12,38 @@ import com.fasterxml.jackson.annotation.JsonValue; /** - * Defines values for TextRecognitionMode. + * Defines values for OperationStatusCodes. */ -public enum TextRecognitionMode { - /** Enum value Handwritten. */ - HANDWRITTEN("Handwritten"), +public enum OperationStatusCodes { + /** Enum value notStarted. */ + NOT_STARTED("notStarted"), - /** Enum value Printed. */ - PRINTED("Printed"); + /** Enum value running. */ + RUNNING("running"), - /** The actual serialized value for a TextRecognitionMode instance. */ + /** Enum value failed. */ + FAILED("failed"), + + /** Enum value succeeded. */ + SUCCEEDED("succeeded"); + + /** The actual serialized value for a OperationStatusCodes instance. */ private String value; - TextRecognitionMode(String value) { + OperationStatusCodes(String value) { this.value = value; } /** - * Parses a serialized value to a TextRecognitionMode instance. + * Parses a serialized value to a OperationStatusCodes instance. * * @param value the serialized value to parse. - * @return the parsed TextRecognitionMode object, or null if unable to parse. + * @return the parsed OperationStatusCodes object, or null if unable to parse. */ @JsonCreator - public static TextRecognitionMode fromString(String value) { - TextRecognitionMode[] items = TextRecognitionMode.values(); - for (TextRecognitionMode item : items) { + public static OperationStatusCodes fromString(String value) { + OperationStatusCodes[] items = OperationStatusCodes.values(); + for (OperationStatusCodes item : items) { if (item.toString().equalsIgnoreCase(value)) { return item; } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileHeaders.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadHeaders.java similarity index 81% rename from sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileHeaders.java rename to sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadHeaders.java index 22f0ae6546d7..0e5ab8c7dd99 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/BatchReadFileHeaders.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadHeaders.java @@ -11,9 +11,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Defines headers for BatchReadFile operation. + * Defines headers for Read operation. */ -public class BatchReadFileHeaders { +public class ReadHeaders { /** * URL to query for status of the operation. The operation ID will expire * in 48 hours. @@ -34,9 +34,9 @@ public String operationLocation() { * Set the operationLocation value. * * @param operationLocation the operationLocation value to set - * @return the BatchReadFileHeaders object itself. + * @return the ReadHeaders object itself. */ - public BatchReadFileHeaders withOperationLocation(String operationLocation) { + public ReadHeaders withOperationLocation(String operationLocation) { this.operationLocation = operationLocation; return this; } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextHeaders.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamHeaders.java similarity index 81% rename from sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextHeaders.java rename to sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamHeaders.java index 1925ac1c1062..a4fe26a86197 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextHeaders.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamHeaders.java @@ -11,9 +11,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Defines headers for RecognizeText operation. + * Defines headers for ReadInStream operation. */ -public class RecognizeTextHeaders { +public class ReadInStreamHeaders { /** * URL to query for status of the operation. The operation ID will expire * in 48 hours. @@ -34,9 +34,9 @@ public String operationLocation() { * Set the operationLocation value. * * @param operationLocation the operationLocation value to set - * @return the RecognizeTextHeaders object itself. + * @return the ReadInStreamHeaders object itself. */ - public RecognizeTextHeaders withOperationLocation(String operationLocation) { + public ReadInStreamHeaders withOperationLocation(String operationLocation) { this.operationLocation = operationLocation; return this; } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamOptionalParameter.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamOptionalParameter.java new file mode 100644 index 000000000000..1a49b82a7c3e --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadInStreamOptionalParameter.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.computervision.models; + + +/** + * The ReadInStreamOptionalParameter model. + */ +public class ReadInStreamOptionalParameter { + /** + * The BCP-47 language code of the text to be detected in the image. In + * future versions, when language parameter is not passed, language + * detection will be used to determine the language. However, in the + * current version, missing language parameter will cause English to be + * used. To ensure that your document is always parsed in English without + * the use of language detection in the future, pass “en” in the language + * parameter. Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', + * 'pt'. + */ + private OcrDetectionLanguage language; + + /** + * Gets or sets the preferred language for the response. + */ + private String thisclientacceptLanguage; + + /** + * Get the language value. + * + * @return the language value + */ + public OcrDetectionLanguage language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the ReadInStreamOptionalParameter object itself. + */ + public ReadInStreamOptionalParameter withLanguage(OcrDetectionLanguage language) { + this.language = language; + return this; + } + + /** + * Get the thisclientacceptLanguage value. + * + * @return the thisclientacceptLanguage value + */ + public String thisclientacceptLanguage() { + return this.thisclientacceptLanguage; + } + + /** + * Set the thisclientacceptLanguage value. + * + * @param thisclientacceptLanguage the thisclientacceptLanguage value to set + * @return the ReadInStreamOptionalParameter object itself. + */ + public ReadInStreamOptionalParameter withThisclientacceptLanguage(String thisclientacceptLanguage) { + this.thisclientacceptLanguage = thisclientacceptLanguage; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOperationResult.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOperationResult.java index e07f016f6372..795d0add57ee 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOperationResult.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOperationResult.java @@ -8,7 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.computervision.models; -import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -16,24 +15,36 @@ */ public class ReadOperationResult { /** - * Status of the read operation. Possible values include: 'NotStarted', - * 'Running', 'Failed', 'Succeeded'. + * Status of the read operation. Possible values include: 'notStarted', + * 'running', 'failed', 'succeeded'. */ @JsonProperty(value = "status") - private TextOperationStatusCodes status; + private OperationStatusCodes status; /** - * An array of text recognition result of the read operation. + * Get UTC date time the batch operation was submitted. */ - @JsonProperty(value = "recognitionResults") - private List recognitionResults; + @JsonProperty(value = "createdDateTime") + private String createdDateTime; + + /** + * Get last updated UTC date time of this batch operation. + */ + @JsonProperty(value = "lastUpdatedDateTime") + private String lastUpdatedDateTime; + + /** + * Analyze batch operation result. + */ + @JsonProperty(value = "analyzeResult") + private AnalyzeResults analyzeResult; /** * Get the status value. * * @return the status value */ - public TextOperationStatusCodes status() { + public OperationStatusCodes status() { return this.status; } @@ -43,28 +54,68 @@ public TextOperationStatusCodes status() { * @param status the status value to set * @return the ReadOperationResult object itself. */ - public ReadOperationResult withStatus(TextOperationStatusCodes status) { + public ReadOperationResult withStatus(OperationStatusCodes status) { this.status = status; return this; } /** - * Get the recognitionResults value. + * Get the createdDateTime value. + * + * @return the createdDateTime value + */ + public String createdDateTime() { + return this.createdDateTime; + } + + /** + * Set the createdDateTime value. + * + * @param createdDateTime the createdDateTime value to set + * @return the ReadOperationResult object itself. + */ + public ReadOperationResult withCreatedDateTime(String createdDateTime) { + this.createdDateTime = createdDateTime; + return this; + } + + /** + * Get the lastUpdatedDateTime value. + * + * @return the lastUpdatedDateTime value + */ + public String lastUpdatedDateTime() { + return this.lastUpdatedDateTime; + } + + /** + * Set the lastUpdatedDateTime value. + * + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set + * @return the ReadOperationResult object itself. + */ + public ReadOperationResult withLastUpdatedDateTime(String lastUpdatedDateTime) { + this.lastUpdatedDateTime = lastUpdatedDateTime; + return this; + } + + /** + * Get the analyzeResult value. * - * @return the recognitionResults value + * @return the analyzeResult value */ - public List recognitionResults() { - return this.recognitionResults; + public AnalyzeResults analyzeResult() { + return this.analyzeResult; } /** - * Set the recognitionResults value. + * Set the analyzeResult value. * - * @param recognitionResults the recognitionResults value to set + * @param analyzeResult the analyzeResult value to set * @return the ReadOperationResult object itself. */ - public ReadOperationResult withRecognitionResults(List recognitionResults) { - this.recognitionResults = recognitionResults; + public ReadOperationResult withAnalyzeResult(AnalyzeResults analyzeResult) { + this.analyzeResult = analyzeResult; return this; } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOptionalParameter.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOptionalParameter.java new file mode 100644 index 000000000000..64ef3880343e --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadOptionalParameter.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.computervision.models; + + +/** + * The ReadOptionalParameter model. + */ +public class ReadOptionalParameter { + /** + * The BCP-47 language code of the text to be detected in the image. In + * future versions, when language parameter is not passed, language + * detection will be used to determine the language. However, in the + * current version, missing language parameter will cause English to be + * used. To ensure that your document is always parsed in English without + * the use of language detection in the future, pass “en” in the language + * parameter. Possible values include: 'en', 'es', 'fr', 'de', 'it', 'nl', + * 'pt'. + */ + private OcrDetectionLanguage language; + + /** + * Gets or sets the preferred language for the response. + */ + private String thisclientacceptLanguage; + + /** + * Get the language value. + * + * @return the language value + */ + public OcrDetectionLanguage language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the ReadOptionalParameter object itself. + */ + public ReadOptionalParameter withLanguage(OcrDetectionLanguage language) { + this.language = language; + return this; + } + + /** + * Get the thisclientacceptLanguage value. + * + * @return the thisclientacceptLanguage value + */ + public String thisclientacceptLanguage() { + return this.thisclientacceptLanguage; + } + + /** + * Set the thisclientacceptLanguage value. + * + * @param thisclientacceptLanguage the thisclientacceptLanguage value to set + * @return the ReadOptionalParameter object itself. + */ + public ReadOptionalParameter withThisclientacceptLanguage(String thisclientacceptLanguage) { + this.thisclientacceptLanguage = thisclientacceptLanguage; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResult.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadResult.java similarity index 57% rename from sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResult.java rename to sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadResult.java index ef5d10cb76a3..c4f24fc0927c 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResult.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/ReadResult.java @@ -12,40 +12,46 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * An object representing a recognized text region. + * Text extracted from a page in the input document. */ -public class TextRecognitionResult { +public class ReadResult { /** * The 1-based page number of the recognition result. */ - @JsonProperty(value = "page") - private Integer page; + @JsonProperty(value = "page", required = true) + private int page; + + /** + * The BCP-47 language code of the recognized text page. + */ + @JsonProperty(value = "language") + private String language; /** * The orientation of the image in degrees in the clockwise direction. - * Range between [0, 360). + * Range between [-180, 180). */ - @JsonProperty(value = "clockwiseOrientation") - private Double clockwiseOrientation; + @JsonProperty(value = "angle", required = true) + private double angle; /** * The width of the image in pixels or the PDF in inches. */ - @JsonProperty(value = "width") - private Double width; + @JsonProperty(value = "width", required = true) + private double width; /** * The height of the image in pixels or the PDF in inches. */ - @JsonProperty(value = "height") - private Double height; + @JsonProperty(value = "height", required = true) + private double height; /** * The unit used in the Width, Height and BoundingBox. For images, the unit * is 'pixel'. For PDF, the unit is 'inch'. Possible values include: * 'pixel', 'inch'. */ - @JsonProperty(value = "unit") + @JsonProperty(value = "unit", required = true) private TextRecognitionResultDimensionUnit unit; /** @@ -59,7 +65,7 @@ public class TextRecognitionResult { * * @return the page value */ - public Integer page() { + public int page() { return this.page; } @@ -67,30 +73,50 @@ public Integer page() { * Set the page value. * * @param page the page value to set - * @return the TextRecognitionResult object itself. + * @return the ReadResult object itself. */ - public TextRecognitionResult withPage(Integer page) { + public ReadResult withPage(int page) { this.page = page; return this; } /** - * Get the clockwiseOrientation value. + * Get the language value. + * + * @return the language value + */ + public String language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the ReadResult object itself. + */ + public ReadResult withLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the angle value. * - * @return the clockwiseOrientation value + * @return the angle value */ - public Double clockwiseOrientation() { - return this.clockwiseOrientation; + public double angle() { + return this.angle; } /** - * Set the clockwiseOrientation value. + * Set the angle value. * - * @param clockwiseOrientation the clockwiseOrientation value to set - * @return the TextRecognitionResult object itself. + * @param angle the angle value to set + * @return the ReadResult object itself. */ - public TextRecognitionResult withClockwiseOrientation(Double clockwiseOrientation) { - this.clockwiseOrientation = clockwiseOrientation; + public ReadResult withAngle(double angle) { + this.angle = angle; return this; } @@ -99,7 +125,7 @@ public TextRecognitionResult withClockwiseOrientation(Double clockwiseOrientatio * * @return the width value */ - public Double width() { + public double width() { return this.width; } @@ -107,9 +133,9 @@ public Double width() { * Set the width value. * * @param width the width value to set - * @return the TextRecognitionResult object itself. + * @return the ReadResult object itself. */ - public TextRecognitionResult withWidth(Double width) { + public ReadResult withWidth(double width) { this.width = width; return this; } @@ -119,7 +145,7 @@ public TextRecognitionResult withWidth(Double width) { * * @return the height value */ - public Double height() { + public double height() { return this.height; } @@ -127,9 +153,9 @@ public Double height() { * Set the height value. * * @param height the height value to set - * @return the TextRecognitionResult object itself. + * @return the ReadResult object itself. */ - public TextRecognitionResult withHeight(Double height) { + public ReadResult withHeight(double height) { this.height = height; return this; } @@ -147,9 +173,9 @@ public TextRecognitionResultDimensionUnit unit() { * Set the unit value. * * @param unit the unit value to set - * @return the TextRecognitionResult object itself. + * @return the ReadResult object itself. */ - public TextRecognitionResult withUnit(TextRecognitionResultDimensionUnit unit) { + public ReadResult withUnit(TextRecognitionResultDimensionUnit unit) { this.unit = unit; return this; } @@ -167,9 +193,9 @@ public List lines() { * Set the lines value. * * @param lines the lines value to set - * @return the TextRecognitionResult object itself. + * @return the ReadResult object itself. */ - public TextRecognitionResult withLines(List lines) { + public ReadResult withLines(List lines) { this.lines = lines; return this; } diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextInStreamHeaders.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextInStreamHeaders.java deleted file mode 100644 index c52814205c9a..000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/RecognizeTextInStreamHeaders.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.cognitiveservices.vision.computervision.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Defines headers for RecognizeTextInStream operation. - */ -public class RecognizeTextInStreamHeaders { - /** - * URL to query for status of the operation. The operation ID will expire - * in 48 hours. - */ - @JsonProperty(value = "Operation-Location") - private String operationLocation; - - /** - * Get the operationLocation value. - * - * @return the operationLocation value - */ - public String operationLocation() { - return this.operationLocation; - } - - /** - * Set the operationLocation value. - * - * @param operationLocation the operationLocation value to set - * @return the RecognizeTextInStreamHeaders object itself. - */ - public RecognizeTextInStreamHeaders withOperationLocation(String operationLocation) { - this.operationLocation = operationLocation; - return this; - } - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationResult.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationResult.java deleted file mode 100644 index c4448b35c356..000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationResult.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.cognitiveservices.vision.computervision.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Result of recognition text operation. - */ -public class TextOperationResult { - /** - * Status of the text operation. Possible values include: 'NotStarted', - * 'Running', 'Failed', 'Succeeded'. - */ - @JsonProperty(value = "status") - private TextOperationStatusCodes status; - - /** - * Text recognition result of the text operation. - */ - @JsonProperty(value = "recognitionResult") - private TextRecognitionResult recognitionResult; - - /** - * Get the status value. - * - * @return the status value - */ - public TextOperationStatusCodes status() { - return this.status; - } - - /** - * Set the status value. - * - * @param status the status value to set - * @return the TextOperationResult object itself. - */ - public TextOperationResult withStatus(TextOperationStatusCodes status) { - this.status = status; - return this; - } - - /** - * Get the recognitionResult value. - * - * @return the recognitionResult value - */ - public TextRecognitionResult recognitionResult() { - return this.recognitionResult; - } - - /** - * Set the recognitionResult value. - * - * @param recognitionResult the recognitionResult value to set - * @return the TextOperationResult object itself. - */ - public TextOperationResult withRecognitionResult(TextRecognitionResult recognitionResult) { - this.recognitionResult = recognitionResult; - return this; - } - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationStatusCodes.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationStatusCodes.java deleted file mode 100644 index 0dd754df317d..000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextOperationStatusCodes.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.cognitiveservices.vision.computervision.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for TextOperationStatusCodes. - */ -public enum TextOperationStatusCodes { - /** Enum value NotStarted. */ - NOT_STARTED("NotStarted"), - - /** Enum value Running. */ - RUNNING("Running"), - - /** Enum value Failed. */ - FAILED("Failed"), - - /** Enum value Succeeded. */ - SUCCEEDED("Succeeded"); - - /** The actual serialized value for a TextOperationStatusCodes instance. */ - private String value; - - TextOperationStatusCodes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a TextOperationStatusCodes instance. - * - * @param value the serialized value to parse. - * @return the parsed TextOperationStatusCodes object, or null if unable to parse. - */ - @JsonCreator - public static TextOperationStatusCodes fromString(String value) { - TextOperationStatusCodes[] items = TextOperationStatusCodes.values(); - for (TextOperationStatusCodes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResultConfidenceClass.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResultConfidenceClass.java deleted file mode 100644 index 890490ec8292..000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/TextRecognitionResultConfidenceClass.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.cognitiveservices.vision.computervision.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for TextRecognitionResultConfidenceClass. - */ -public enum TextRecognitionResultConfidenceClass { - /** Enum value High. */ - HIGH("High"), - - /** Enum value Low. */ - LOW("Low"); - - /** The actual serialized value for a TextRecognitionResultConfidenceClass instance. */ - private String value; - - TextRecognitionResultConfidenceClass(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a TextRecognitionResultConfidenceClass instance. - * - * @param value the serialized value to parse. - * @return the parsed TextRecognitionResultConfidenceClass object, or null if unable to parse. - */ - @JsonCreator - public static TextRecognitionResultConfidenceClass fromString(String value) { - TextRecognitionResultConfidenceClass[] items = TextRecognitionResultConfidenceClass.values(); - for (TextRecognitionResultConfidenceClass item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Word.java b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Word.java index 9d4d8ccd36b4..a85b4b50feb4 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Word.java +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/models/Word.java @@ -28,10 +28,10 @@ public class Word { private String text; /** - * Qualitative confidence measure. Possible values include: 'High', 'Low'. + * Qualitative confidence measure. */ - @JsonProperty(value = "confidence") - private TextRecognitionResultConfidenceClass confidence; + @JsonProperty(value = "confidence", required = true) + private double confidence; /** * Get the boundingBox value. @@ -78,7 +78,7 @@ public Word withText(String text) { * * @return the confidence value */ - public TextRecognitionResultConfidenceClass confidence() { + public double confidence() { return this.confidence; } @@ -88,7 +88,7 @@ public TextRecognitionResultConfidenceClass confidence() { * @param confidence the confidence value to set * @return the Word object itself. */ - public Word withConfidence(TextRecognitionResultConfidenceClass confidence) { + public Word withConfidence(double confidence) { this.confidence = confidence; return this; }