From c22d72214d3aa665549eed95af566b1906908e23 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 15 May 2020 18:23:24 +0000 Subject: [PATCH 1/3] Generated from 6c2e36f271e8bd30f4ec2ba3c79890bd441feed2 Run Prettier script on new examples --- .../README.md | 334 +----------------- .../computervision/_computer_vision_client.py | 2 +- .../vision/computervision/_configuration.py | 2 +- .../vision/computervision/models/__init__.py | 22 +- .../models/_computer_vision_client_enums.py | 27 +- .../vision/computervision/models/_models.py | 199 ++++++----- .../computervision/models/_models_py3.py | 207 ++++++----- .../_computer_vision_client_operations.py | 246 +++---------- .../setup.py | 5 +- 9 files changed, 326 insertions(+), 718 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md index 0956f6eb55b0..815aa1ff704c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md @@ -1,331 +1,21 @@ -# Azure Cognitive Services Computer Vision SDK for Python +# Microsoft Azure SDK for Python -The Computer Vision service provides developers with access to advanced algorithms for processing images and returning information. Computer Vision algorithms analyze the content of an image in different ways, depending on the visual features you're interested in. +This is the Microsoft Azure Cognitive Services Computer Vision Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/) -You can use Computer Vision in your application to: -- Analyze images for insight -- Extract text from images -- Generate thumbnails +# Usage -Looking for more documentation? +For code examples, see [Cognitive Services Computer Vision](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) +on docs.microsoft.com. -* [SDK reference documentation](https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision) -* [Cognitive Services Computer Vision documentation](https://docs.microsoft.com/azure/cognitive-services/computer-vision/) -## Prerequisites +# Provide Feedback -* Azure subscription - [Create a free account][azure_sub] -* Azure [Computer Vision resource][computervision_resource] -* [Python 3.6+][python] +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. -If you need a Computer Vision API account, you can create one with this [Azure CLI][azure_cli] command: -```Bash -RES_REGION=westeurope -RES_GROUP= -ACCT_NAME= - -az cognitiveservices account create \ - --resource-group $RES_GROUP \ - --name $ACCT_NAME \ - --location $RES_REGION \ - --kind ComputerVision \ - --sku S1 \ - --yes -``` - -## Installation - -Install the Azure Cognitive Services Computer Vision SDK with [pip][pip], optionally within a [virtual environment][venv]. - -### Configure a virtual environment (optional) - -Although not required, you can keep your base system and Azure SDK environments isolated from one another if you use a [virtual environment][virtualenv]. Execute the following commands to configure and then enter a virtual environment with [venv][venv], such as `cogsrv-vision-env`: - -```Bash -python3 -m venv cogsrv-vision-env -source cogsrv-vision-env/bin/activate -``` - -### Install the SDK - -Install the Azure Cognitive Services Computer Vision SDK for Python [package][pypi_computervision] with [pip][pip]: - -```Bash -pip install azure-cognitiveservices-vision-computervision -``` - -## Authentication - -Once you create your Computer Vision resource, you need its **region**, and one of its **account keys** to instantiate the client object. - -Use these values when you create the instance of the [ComputerVisionClient][ref_computervisionclient] client object. - -### Get credentials - -Use the [Azure CLI][cloud_shell] snippet below to populate two environment variables with the Computer Vision account **region** and one of its **keys** (you can also find these values in the [Azure portal][azure_portal]). The snippet is formatted for the Bash shell. - -```Bash -RES_GROUP= -ACCT_NAME= - -export ACCOUNT_REGION=$(az cognitiveservices account show \ - --resource-group $RES_GROUP \ - --name $ACCT_NAME \ - --query location \ - --output tsv) - -export ACCOUNT_KEY=$(az cognitiveservices account keys list \ - --resource-group $RES_GROUP \ - --name $ACCT_NAME \ - --query key1 \ - --output tsv) -``` - -### Create client - -Once you've populated the `ACCOUNT_REGION` and `ACCOUNT_KEY` environment variables, you can create the [ComputerVisionClient][ref_computervisionclient] client object. - -```Python -from azure.cognitiveservices.vision.computervision import ComputerVisionClient -from azure.cognitiveservices.vision.computervision.models import VisualFeatureTypes -from msrest.authentication import CognitiveServicesCredentials - -import os -region = os.environ['ACCOUNT_REGION'] -key = os.environ['ACCOUNT_KEY'] - -credentials = CognitiveServicesCredentials(key) -client = ComputerVisionClient( - endpoint="https://" + region + ".api.cognitive.microsoft.com/", - credentials=credentials -) -``` - -## Usage - -Once you've initialized a [ComputerVisionClient][ref_computervisionclient] client object, you can: - -* Analyze an image: You can analyze an image for certain features such as faces, colors, tags. -* Generate thumbnails: Create a custom JPEG image to use as a thumbnail of the original image. -* Get description of an image: Get a description of the image based on its subject domain. - -For more information about this service, see [What is Computer Vision?][computervision_docs]. - -## Examples - -The following sections provide several code snippets covering some of the most common Computer Vision tasks, including: - -* [Analyze an image](#analyze-an-image) -* [Get subject domain list](#get-subject-domain-list) -* [Analyze an image by domain](#analyze-an-image-by-domain) -* [Get text description of an image](#get-text-description-of-an-image) -* [Get handwritten text from image](#get-text-from-image) -* [Generate thumbnail](#generate-thumbnail) - -### Analyze an image - -You can analyze an image for certain features with [`analyze_image`][ref_computervisionclient_analyze_image]. Use the [`visual_features`][ref_computervision_model_visualfeatures] property to set the types of analysis to perform on the image. Common values are `VisualFeatureTypes.tags` and `VisualFeatureTypes.description`. - -```Python -url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/Broadway_and_Times_Square_by_night.jpg/450px-Broadway_and_Times_Square_by_night.jpg" - -image_analysis = client.analyze_image(url,visual_features=[VisualFeatureTypes.tags]) - -for tag in image_analysis.tags: - print(tag) -``` - -### Get subject domain list - -Review the subject domains used to analyze your image with [`list_models`][ref_computervisionclient_list_models]. These domain names are used when [analyzing an image by domain](#analyze-an-image-by-domain). An example of a domain is `landmarks`. - -```Python -models = client.list_models() - -for x in models.models_property: - print(x) -``` - -### Analyze an image by domain - -You can analyze an image by subject domain with [`analyze_image_by_domain`][ref_computervisionclient_analyze_image_by_domain]. Get the [list of supported subject domains](#get-subject-domain-list) in order to use the correct domain name. - -```Python -domain = "landmarks" -url = "https://images.pexels.com/photos/338515/pexels-photo-338515.jpeg" -language = "en" - -analysis = client.analyze_image_by_domain(domain, url, language) - -for landmark in analysis.result["landmarks"]: - print(landmark["name"]) - print(landmark["confidence"]) -``` - -### Get text description of an image - -You can get a language-based text description of an image with [`describe_image`][ref_computervisionclient_describe_image]. Request several descriptions with the `max_description` property if you are doing text analysis for keywords associated with the image. Examples of a text description for the following image include `a train crossing a bridge over a body of water`, `a large bridge over a body of water`, and `a train crossing a bridge over a large body of water`. - -```Python -domain = "landmarks" -url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" -language = "en" -max_descriptions = 3 - -analysis = client.describe_image(url, max_descriptions, language) - -for caption in analysis.captions: - print(caption.text) - print(caption.confidence) -``` - -### Get text from image - -You can get any handwritten or printed text from an image. This requires two calls to the SDK: [`recognize_text`][ref_computervisionclient_recognize_text] and [`get_text_operation_result`][ref_computervisionclient_get_text_operation_result]. The call to recognize_text is asynchronous. In the results of the get_text_operation_result call, you need to check if the first call completed with [`TextOperationStatusCodes`][ref_computervision_model_textoperationstatuscodes] before extracting the text data. The results include the text as well as the bounding box coordinates for the text. - -```Python -# import models -from azure.cognitiveservices.vision.computervision.models import TextRecognitionMode -from azure.cognitiveservices.vision.computervision.models import TextOperationStatusCodes - -url = "https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/raw/master/samples/vision/images/make_things_happen.jpg" -mode = TextRecognitionMode.printed -raw = True -custom_headers = None -numberOfCharsInOperationId = 36 - -# SDK call -rawHttpResponse = client.recognize_text(url, mode, custom_headers, raw) - -# Get ID from returned headers -operationLocation = rawHttpResponse.headers["Operation-Location"] -idLocation = len(operationLocation) - numberOfCharsInOperationId -operationId = operationLocation[idLocation:] - -# SDK call -result = client.get_text_operation_result(operationId) - -# Get data -if result.status == TextOperationStatusCodes.succeeded: - - for line in result.recognition_result.lines: - print(line.text) - print(line.bounding_box) -``` - -### Generate thumbnail - -You can generate a thumbnail (JPG) of an image with [`generate_thumbnail`][ref_computervisionclient_generate_thumbnail]. The thumbnail does not need to be in the same proportions as the original image. - -This example uses the [Pillow][pypi_pillow] package to save the new thumbnail image locally. - -```Python -from PIL import Image -import io - -width = 50 -height = 50 -url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" - -thumbnail = client.generate_thumbnail(width, height, url) - -for x in thumbnail: - image = Image.open(io.BytesIO(x)) - -image.save('thumbnail.jpg') -``` - -## Troubleshooting - -### General - -When you interact with the [ComputerVisionClient][ref_computervisionclient] client object using the Python SDK, the [`ComputerVisionErrorException`][ref_computervision_computervisionerrorexception] class is used to return errors. Errors returned by the service correspond to the same HTTP status codes returned for REST API requests. - -For example, if you try to analyze an image with an invalid key, a `401` error is returned. In the following snippet, the [error][ref_httpfailure] is handled gracefully by catching the exception and displaying additional information about the error. - -```Python - -domain = "landmarks" -url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" -language = "en" -max_descriptions = 3 - -try: - analysis = client.describe_image(url, max_descriptions, language) - - for caption in analysis.captions: - print(caption.text) - print(caption.confidence) -except HTTPFailure as e: - if e.status_code == 401: - print("Error unauthorized. Make sure your key and region are correct.") - else: - raise -``` - -### Handle transient errors with retries - -While working with the [ComputerVisionClient][ref_computervisionclient] client, you might encounter transient failures caused by [rate limits][computervision_request_units] enforced by the service, or other transient problems like network outages. For information about handling these types of failures, see [Retry pattern][azure_pattern_retry] in the Cloud Design Patterns guide, and the related [Circuit Breaker pattern][azure_pattern_circuit_breaker]. - -## Next steps - -### More sample code - -Several Computer Vision Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Computer Vision: - -* [recognize_text][recognize-text] - -### Additional documentation - -For more extensive documentation on the Computer Vision service, see the [Azure Computer Vision documentation][computervision_docs] on docs.microsoft.com. - - -[pip]: https://pypi.org/project/pip/ -[python]: https://www.python.org/downloads/ - -[azure_cli]: https://docs.microsoft.com/cli/azure -[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker -[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry -[azure_portal]: https://portal.azure.com -[azure_sub]: https://azure.microsoft.com/free/ - -[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview - -[venv]: https://docs.python.org/3/library/venv.html -[virtualenv]: https://virtualenv.pypa.io - -[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision - -[pypi_computervision]:https://pypi.org/project/azure-cognitiveservices-vision-computervision/ -[pypi_pillow]:https://pypi.org/project/Pillow/ - -[ref_computervision_sdk]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision?view=azure-python -[ref_computervision_computervisionerrorexception]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.computervisionerrorexception?view=azure-python -[ref_httpfailure]: https://docs.microsoft.com/python/api/msrest/msrest.exceptions.httpoperationerror?view=azure-python - - -[computervision_resource]: https://docs.microsoft.com/azure/cognitive-services/computer-vision/vision-api-how-to-topics/howtosubscribe - -[computervision_docs]: https://docs.microsoft.com/azure/cognitive-services/computer-vision/home - -[ref_computervisionclient]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python - - -[ref_computervisionclient_analyze_image]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-url--visual-features-none--details-none--language--en---custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_list_models]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#list-models-custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_analyze_image_by_domain]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-by-domain-model--url--language--en---custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_describe_image]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#describe-image-url--max-candidates--1---language--en---custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_recognize_text]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#recognize-text-url--mode--custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_get_text_operation_result]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#get-text-operation-result-operation-id--custom-headers-none--raw-false----operation-config- -[ref_computervisionclient_generate_thumbnail]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#generate-thumbnail-width--height--url--smart-cropping-false--custom-headers-none--raw-false--callback-none----operation-config- - - -[ref_computervision_model_visualfeatures]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.visualfeaturetypes?view=azure-python - -[ref_computervision_model_textoperationstatuscodes]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.textoperationstatuscodes?view=azure-python - -[computervision_request_units]:https://azure.microsoft.com/pricing/details/cognitive-services/computer-vision/ - -[recognize-text]:https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/blob/master/samples/vision/computer_vision_samples.py \ No newline at end of file +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-vision-computervision%2FREADME.png) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py index 66db7e8147cd..e2d380c69638 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py @@ -38,7 +38,7 @@ def __init__( super(ComputerVisionClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2.1' + self.api_version = '3.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py index 4231ac56a0a4..7a5c5c553bc9 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py @@ -33,7 +33,7 @@ def __init__( raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/vision/v2.1' + base_url = '{Endpoint}/vision/v3.0' super(ComputerVisionClientConfiguration, self).__init__(base_url) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 98057e314d77..5633061bc93b 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -11,6 +11,7 @@ try: from ._models_py3 import AdultInfo + from ._models_py3 import AnalyzeResults from ._models_py3 import AreaOfInterestResult from ._models_py3 import BoundingRect from ._models_py3 import Category @@ -44,12 +45,12 @@ from ._models_py3 import OcrResult from ._models_py3 import OcrWord from ._models_py3 import ReadOperationResult + from ._models_py3 import ReadResult from ._models_py3 import TagResult - from ._models_py3 import TextOperationResult - from ._models_py3 import TextRecognitionResult from ._models_py3 import Word except (SyntaxError, ImportError): from ._models import AdultInfo + from ._models import AnalyzeResults from ._models import AreaOfInterestResult from ._models import BoundingRect from ._models import Category @@ -83,24 +84,23 @@ from ._models import OcrResult from ._models import OcrWord from ._models import ReadOperationResult + from ._models import ReadResult from ._models import TagResult - from ._models import TextOperationResult - from ._models import TextRecognitionResult from ._models import Word from ._computer_vision_client_enums import ( DescriptionExclude, Details, Gender, + OcrDetectionLanguage, OcrLanguages, - TextOperationStatusCodes, - TextRecognitionMode, - TextRecognitionResultConfidenceClass, + OperationStatusCodes, TextRecognitionResultDimensionUnit, VisualFeatureTypes, ) __all__ = [ 'AdultInfo', + 'AnalyzeResults', 'AreaOfInterestResult', 'BoundingRect', 'Category', @@ -134,17 +134,15 @@ 'OcrResult', 'OcrWord', 'ReadOperationResult', + 'ReadResult', 'TagResult', - 'TextOperationResult', - 'TextRecognitionResult', 'Word', 'Gender', - 'TextOperationStatusCodes', + 'OperationStatusCodes', 'TextRecognitionResultDimensionUnit', - 'TextRecognitionResultConfidenceClass', 'DescriptionExclude', 'OcrLanguages', 'VisualFeatureTypes', - 'TextRecognitionMode', + 'OcrDetectionLanguage', 'Details', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py index 2c319134cff0..d8cb9260286e 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py @@ -18,12 +18,12 @@ class Gender(str, Enum): female = "Female" -class TextOperationStatusCodes(str, Enum): +class OperationStatusCodes(str, Enum): - not_started = "NotStarted" - running = "Running" - failed = "Failed" - succeeded = "Succeeded" + not_started = "notStarted" + running = "running" + failed = "failed" + succeeded = "succeeded" class TextRecognitionResultDimensionUnit(str, Enum): @@ -32,12 +32,6 @@ class TextRecognitionResultDimensionUnit(str, Enum): inch = "inch" -class TextRecognitionResultConfidenceClass(str, Enum): - - high = "High" - low = "Low" - - class DescriptionExclude(str, Enum): celebrities = "Celebrities" @@ -88,10 +82,15 @@ class VisualFeatureTypes(str, Enum): brands = "Brands" -class TextRecognitionMode(str, Enum): +class OcrDetectionLanguage(str, Enum): - handwritten = "Handwritten" - printed = "Printed" + en = "en" + es = "es" + fr = "fr" + de = "de" + it = "it" + nl = "nl" + pt = "pt" class Details(str, Enum): diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py index 1954cb533892..f0ef37445759 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py @@ -53,6 +53,34 @@ def __init__(self, **kwargs): self.gore_score = kwargs.get('gore_score', None) +class AnalyzeResults(Model): + """Analyze batch operation result. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Version of schema used for this result. + :type version: str + :param read_results: Required. Text extracted from the input. + :type read_results: + list[~azure.cognitiveservices.vision.computervision.models.ReadResult] + """ + + _validation = { + 'version': {'required': True}, + 'read_results': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'version', 'type': 'str'}, + 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, + } + + def __init__(self, **kwargs): + super(AnalyzeResults, self).__init__(**kwargs) + self.version = kwargs.get('version', None) + self.read_results = kwargs.get('read_results', None) + + class AreaOfInterestResult(Model): """Result of AreaOfInterest operation. @@ -767,16 +795,28 @@ def __init__(self, **kwargs): class Line(Model): """An object representing a recognized text line. - :param bounding_box: Bounding box of a recognized line. + All required parameters must be populated in order to send to Azure. + + :param language: The BCP-47 language code of the recognized text line. + Only provided where the language of the line differs from the page's. + :type language: str + :param bounding_box: Required. Bounding box of a recognized line. :type bounding_box: list[float] - :param text: The text content of the line. + :param text: Required. The text content of the line. :type text: str - :param words: List of words in the text line. + :param words: Required. List of words in the text line. :type words: list[~azure.cognitiveservices.vision.computervision.models.Word] """ + _validation = { + 'bounding_box': {'required': True}, + 'text': {'required': True}, + 'words': {'required': True}, + } + _attribute_map = { + 'language': {'key': 'language', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, 'text': {'key': 'text', 'type': 'str'}, 'words': {'key': 'words', 'type': '[Word]'}, @@ -784,6 +824,7 @@ class Line(Model): def __init__(self, **kwargs): super(Line, self).__init__(**kwargs) + self.language = kwargs.get('language', None) self.bounding_box = kwargs.get('bounding_box', None) self.text = kwargs.get('text', None) self.words = kwargs.get('words', None) @@ -989,93 +1030,56 @@ class ReadOperationResult(Model): """OCR result of the read operation. :param status: Status of the read operation. Possible values include: - 'NotStarted', 'Running', 'Failed', 'Succeeded' + 'notStarted', 'running', 'failed', 'succeeded' :type status: str or - ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_results: An array of text recognition result of the - read operation. - :type recognition_results: - list[~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult] + ~azure.cognitiveservices.vision.computervision.models.OperationStatusCodes + :param created_date_time: Get UTC date time the batch operation was + submitted. + :type created_date_time: str + :param last_updated_date_time: Get last updated UTC date time of this + batch operation. + :type last_updated_date_time: str + :param analyze_result: Analyze batch operation result. + :type analyze_result: + ~azure.cognitiveservices.vision.computervision.models.AnalyzeResults """ _attribute_map = { - 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_results': {'key': 'recognitionResults', 'type': '[TextRecognitionResult]'}, + 'status': {'key': 'status', 'type': 'OperationStatusCodes'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'str'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'str'}, + 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResults'}, } def __init__(self, **kwargs): super(ReadOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) - self.recognition_results = kwargs.get('recognition_results', None) - - -class TagResult(Model): - """The results of a image tag operation, including any tags and image - metadata. - - :param tags: A list of tags with confidence level. - :type tags: - list[~azure.cognitiveservices.vision.computervision.models.ImageTag] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '[ImageTag]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, **kwargs): - super(TagResult, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.request_id = kwargs.get('request_id', None) - self.metadata = kwargs.get('metadata', None) - - -class TextOperationResult(Model): - """Result of recognition text operation. - - :param status: Status of the text operation. Possible values include: - 'NotStarted', 'Running', 'Failed', 'Succeeded' - :type status: str or - ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_result: Text recognition result of the text operation. - :type recognition_result: - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_result': {'key': 'recognitionResult', 'type': 'TextRecognitionResult'}, - } - - def __init__(self, **kwargs): - super(TextOperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.recognition_result = kwargs.get('recognition_result', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.last_updated_date_time = kwargs.get('last_updated_date_time', None) + self.analyze_result = kwargs.get('analyze_result', None) -class TextRecognitionResult(Model): - """An object representing a recognized text region. +class ReadResult(Model): + """Text extracted from a page in the input document. All required parameters must be populated in order to send to Azure. - :param page: The 1-based page number of the recognition result. + :param page: Required. The 1-based page number of the recognition result. :type page: int - :param clockwise_orientation: The orientation of the image in degrees in - the clockwise direction. Range between [0, 360). - :type clockwise_orientation: float - :param width: The width of the image in pixels or the PDF in inches. + :param language: The BCP-47 language code of the recognized text page. + :type language: str + :param angle: Required. The orientation of the image in degrees in the + clockwise direction. Range between [-180, 180). + :type angle: float + :param width: Required. The width of the image in pixels or the PDF in + inches. :type width: float - :param height: The height of the image in pixels or the PDF in inches. + :param height: Required. The height of the image in pixels or the PDF in + inches. :type height: float - :param unit: 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' + :param unit: Required. 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' :type unit: str or ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultDimensionUnit :param lines: Required. A list of recognized text lines. @@ -1084,12 +1088,18 @@ class TextRecognitionResult(Model): """ _validation = { + 'page': {'required': True}, + 'angle': {'required': True}, + 'width': {'required': True}, + 'height': {'required': True}, + 'unit': {'required': True}, 'lines': {'required': True}, } _attribute_map = { 'page': {'key': 'page', 'type': 'int'}, - 'clockwise_orientation': {'key': 'clockwiseOrientation', 'type': 'float'}, + 'language': {'key': 'language', 'type': 'str'}, + 'angle': {'key': 'angle', 'type': 'float'}, 'width': {'key': 'width', 'type': 'float'}, 'height': {'key': 'height', 'type': 'float'}, 'unit': {'key': 'unit', 'type': 'TextRecognitionResultDimensionUnit'}, @@ -1097,15 +1107,43 @@ class TextRecognitionResult(Model): } def __init__(self, **kwargs): - super(TextRecognitionResult, self).__init__(**kwargs) + super(ReadResult, self).__init__(**kwargs) self.page = kwargs.get('page', None) - self.clockwise_orientation = kwargs.get('clockwise_orientation', None) + self.language = kwargs.get('language', None) + self.angle = kwargs.get('angle', None) self.width = kwargs.get('width', None) self.height = kwargs.get('height', None) self.unit = kwargs.get('unit', None) self.lines = kwargs.get('lines', None) +class TagResult(Model): + """The results of a image tag operation, including any tags and image + metadata. + + :param tags: A list of tags with confidence level. + :type tags: + list[~azure.cognitiveservices.vision.computervision.models.ImageTag] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[ImageTag]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, **kwargs): + super(TagResult, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.request_id = kwargs.get('request_id', None) + self.metadata = kwargs.get('metadata', None) + + class Word(Model): """An object representing a recognized word. @@ -1115,21 +1153,20 @@ class Word(Model): :type bounding_box: list[float] :param text: Required. The text content of the word. :type text: str - :param confidence: Qualitative confidence measure. Possible values - include: 'High', 'Low' - :type confidence: str or - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultConfidenceClass + :param confidence: Required. Qualitative confidence measure. + :type confidence: float """ _validation = { 'bounding_box': {'required': True}, 'text': {'required': True}, + 'confidence': {'required': True}, } _attribute_map = { 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, 'text': {'key': 'text', 'type': 'str'}, - 'confidence': {'key': 'confidence', 'type': 'TextRecognitionResultConfidenceClass'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, } def __init__(self, **kwargs): diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py index 0df15fb9e295..09951eeef9a3 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py @@ -53,6 +53,34 @@ def __init__(self, *, is_adult_content: bool=None, is_racy_content: bool=None, i self.gore_score = gore_score +class AnalyzeResults(Model): + """Analyze batch operation result. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Version of schema used for this result. + :type version: str + :param read_results: Required. Text extracted from the input. + :type read_results: + list[~azure.cognitiveservices.vision.computervision.models.ReadResult] + """ + + _validation = { + 'version': {'required': True}, + 'read_results': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'version', 'type': 'str'}, + 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, + } + + def __init__(self, *, version: str, read_results, **kwargs) -> None: + super(AnalyzeResults, self).__init__(**kwargs) + self.version = version + self.read_results = read_results + + class AreaOfInterestResult(Model): """Result of AreaOfInterest operation. @@ -767,23 +795,36 @@ def __init__(self, *, name: str=None, confidence: float=None, **kwargs) -> None: class Line(Model): """An object representing a recognized text line. - :param bounding_box: Bounding box of a recognized line. + All required parameters must be populated in order to send to Azure. + + :param language: The BCP-47 language code of the recognized text line. + Only provided where the language of the line differs from the page's. + :type language: str + :param bounding_box: Required. Bounding box of a recognized line. :type bounding_box: list[float] - :param text: The text content of the line. + :param text: Required. The text content of the line. :type text: str - :param words: List of words in the text line. + :param words: Required. List of words in the text line. :type words: list[~azure.cognitiveservices.vision.computervision.models.Word] """ + _validation = { + 'bounding_box': {'required': True}, + 'text': {'required': True}, + 'words': {'required': True}, + } + _attribute_map = { + 'language': {'key': 'language', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, 'text': {'key': 'text', 'type': 'str'}, 'words': {'key': 'words', 'type': '[Word]'}, } - def __init__(self, *, bounding_box=None, text: str=None, words=None, **kwargs) -> None: + def __init__(self, *, bounding_box, text: str, words, language: str=None, **kwargs) -> None: super(Line, self).__init__(**kwargs) + self.language = language self.bounding_box = bounding_box self.text = text self.words = words @@ -989,93 +1030,56 @@ class ReadOperationResult(Model): """OCR result of the read operation. :param status: Status of the read operation. Possible values include: - 'NotStarted', 'Running', 'Failed', 'Succeeded' + 'notStarted', 'running', 'failed', 'succeeded' :type status: str or - ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_results: An array of text recognition result of the - read operation. - :type recognition_results: - list[~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult] + ~azure.cognitiveservices.vision.computervision.models.OperationStatusCodes + :param created_date_time: Get UTC date time the batch operation was + submitted. + :type created_date_time: str + :param last_updated_date_time: Get last updated UTC date time of this + batch operation. + :type last_updated_date_time: str + :param analyze_result: Analyze batch operation result. + :type analyze_result: + ~azure.cognitiveservices.vision.computervision.models.AnalyzeResults """ _attribute_map = { - 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_results': {'key': 'recognitionResults', 'type': '[TextRecognitionResult]'}, + 'status': {'key': 'status', 'type': 'OperationStatusCodes'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'str'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'str'}, + 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResults'}, } - def __init__(self, *, status=None, recognition_results=None, **kwargs) -> None: + def __init__(self, *, status=None, created_date_time: str=None, last_updated_date_time: str=None, analyze_result=None, **kwargs) -> None: super(ReadOperationResult, self).__init__(**kwargs) self.status = status - self.recognition_results = recognition_results - - -class TagResult(Model): - """The results of a image tag operation, including any tags and image - metadata. - - :param tags: A list of tags with confidence level. - :type tags: - list[~azure.cognitiveservices.vision.computervision.models.ImageTag] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '[ImageTag]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, *, tags=None, request_id: str=None, metadata=None, **kwargs) -> None: - super(TagResult, self).__init__(**kwargs) - self.tags = tags - self.request_id = request_id - self.metadata = metadata - - -class TextOperationResult(Model): - """Result of recognition text operation. - - :param status: Status of the text operation. Possible values include: - 'NotStarted', 'Running', 'Failed', 'Succeeded' - :type status: str or - ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_result: Text recognition result of the text operation. - :type recognition_result: - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_result': {'key': 'recognitionResult', 'type': 'TextRecognitionResult'}, - } - - def __init__(self, *, status=None, recognition_result=None, **kwargs) -> None: - super(TextOperationResult, self).__init__(**kwargs) - self.status = status - self.recognition_result = recognition_result + self.created_date_time = created_date_time + self.last_updated_date_time = last_updated_date_time + self.analyze_result = analyze_result -class TextRecognitionResult(Model): - """An object representing a recognized text region. +class ReadResult(Model): + """Text extracted from a page in the input document. All required parameters must be populated in order to send to Azure. - :param page: The 1-based page number of the recognition result. + :param page: Required. The 1-based page number of the recognition result. :type page: int - :param clockwise_orientation: The orientation of the image in degrees in - the clockwise direction. Range between [0, 360). - :type clockwise_orientation: float - :param width: The width of the image in pixels or the PDF in inches. + :param language: The BCP-47 language code of the recognized text page. + :type language: str + :param angle: Required. The orientation of the image in degrees in the + clockwise direction. Range between [-180, 180). + :type angle: float + :param width: Required. The width of the image in pixels or the PDF in + inches. :type width: float - :param height: The height of the image in pixels or the PDF in inches. + :param height: Required. The height of the image in pixels or the PDF in + inches. :type height: float - :param unit: 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' + :param unit: Required. 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' :type unit: str or ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultDimensionUnit :param lines: Required. A list of recognized text lines. @@ -1084,28 +1088,62 @@ class TextRecognitionResult(Model): """ _validation = { + 'page': {'required': True}, + 'angle': {'required': True}, + 'width': {'required': True}, + 'height': {'required': True}, + 'unit': {'required': True}, 'lines': {'required': True}, } _attribute_map = { 'page': {'key': 'page', 'type': 'int'}, - 'clockwise_orientation': {'key': 'clockwiseOrientation', 'type': 'float'}, + 'language': {'key': 'language', 'type': 'str'}, + 'angle': {'key': 'angle', 'type': 'float'}, 'width': {'key': 'width', 'type': 'float'}, 'height': {'key': 'height', 'type': 'float'}, 'unit': {'key': 'unit', 'type': 'TextRecognitionResultDimensionUnit'}, 'lines': {'key': 'lines', 'type': '[Line]'}, } - def __init__(self, *, lines, page: int=None, clockwise_orientation: float=None, width: float=None, height: float=None, unit=None, **kwargs) -> None: - super(TextRecognitionResult, self).__init__(**kwargs) + def __init__(self, *, page: int, angle: float, width: float, height: float, unit, lines, language: str=None, **kwargs) -> None: + super(ReadResult, self).__init__(**kwargs) self.page = page - self.clockwise_orientation = clockwise_orientation + self.language = language + self.angle = angle self.width = width self.height = height self.unit = unit self.lines = lines +class TagResult(Model): + """The results of a image tag operation, including any tags and image + metadata. + + :param tags: A list of tags with confidence level. + :type tags: + list[~azure.cognitiveservices.vision.computervision.models.ImageTag] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[ImageTag]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, *, tags=None, request_id: str=None, metadata=None, **kwargs) -> None: + super(TagResult, self).__init__(**kwargs) + self.tags = tags + self.request_id = request_id + self.metadata = metadata + + class Word(Model): """An object representing a recognized word. @@ -1115,24 +1153,23 @@ class Word(Model): :type bounding_box: list[float] :param text: Required. The text content of the word. :type text: str - :param confidence: Qualitative confidence measure. Possible values - include: 'High', 'Low' - :type confidence: str or - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultConfidenceClass + :param confidence: Required. Qualitative confidence measure. + :type confidence: float """ _validation = { 'bounding_box': {'required': True}, 'text': {'required': True}, + 'confidence': {'required': True}, } _attribute_map = { 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, 'text': {'key': 'text', 'type': 'str'}, - 'confidence': {'key': 'confidence', 'type': 'TextRecognitionResultConfidenceClass'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, *, bounding_box, text: str, confidence=None, **kwargs) -> None: + def __init__(self, *, bounding_box, text: str, confidence: float, **kwargs) -> None: super(Word, self).__init__(**kwargs) self.bounding_box = bounding_box self.text = text diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py index 3690d7aa9499..a2417588988b 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py @@ -715,133 +715,27 @@ def get_area_of_interest( return deserialized get_area_of_interest.metadata = {'url': '/areaOfInterest'} - def recognize_text( - self, url, mode, custom_headers=None, raw=False, **operation_config): - """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' - :type mode: str or - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionMode - :param url: Publicly reachable URL of an image. - :type url: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ComputerVisionErrorException` - """ - image_url = models.ImageUrl(url=url) - - # Construct URL - url = self.recognize_text.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['mode'] = self._serialize.query("mode", mode, 'TextRecognitionMode') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct body - body_content = self._serialize.body(image_url, 'ImageUrl') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [202]: - raise models.ComputerVisionErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'Operation-Location': 'str', - }) - return client_raw_response - recognize_text.metadata = {'url': '/recognizeText'} - - def get_text_operation_result( - self, operation_id, custom_headers=None, raw=False, **operation_config): - """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 operation_id: Id of the text operation returned in the response - of the 'Recognize Text' - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TextOperationResult or ClientRawResponse if raw=true - :rtype: - ~azure.cognitiveservices.vision.computervision.models.TextOperationResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ComputerVisionErrorException` - """ - # Construct URL - url = self.get_text_operation_result.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'operationId': self._serialize.url("operation_id", operation_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TextOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_text_operation_result.metadata = {'url': '/textOperations/{operationId}'} - - def batch_read_file( - self, url, custom_headers=None, raw=False, **operation_config): + def read( + self, url, language="en", custom_headers=None, raw=False, **operation_config): """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.​. + 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. :type url: str + :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' + :type language: str or + ~azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -855,7 +749,7 @@ def batch_read_file( image_url = models.ImageUrl(url=url) # Construct URL - url = self.batch_read_file.metadata['url'] + url = self.read.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -863,6 +757,8 @@ def batch_read_file( # Construct parameters query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} @@ -886,16 +782,16 @@ def batch_read_file( 'Operation-Location': 'str', }) return client_raw_response - batch_read_file.metadata = {'url': '/read/core/asyncBatchAnalyze'} + read.metadata = {'url': '/read/analyze'} - def get_read_operation_result( + def get_read_result( self, operation_id, custom_headers=None, raw=False, **operation_config): """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. + field returned from Read interface. :param operation_id: Id of read operation returned in the response of - the 'Batch Read File' interface. + the 'Read' interface. :type operation_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the @@ -910,7 +806,7 @@ def get_read_operation_result( :class:`ComputerVisionErrorException` """ # Construct URL - url = self.get_read_operation_result.metadata['url'] + url = self.get_read_result.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'operationId': self._serialize.url("operation_id", operation_id, 'str') @@ -942,7 +838,7 @@ def get_read_operation_result( return client_raw_response return deserialized - get_read_operation_result.metadata = {'url': '/read/operations/{operationId}'} + get_read_result.metadata = {'url': '/read/analyzeResults/{operationId}'} def analyze_image_in_stream( self, image, visual_features=None, details=None, language="en", description_exclude=None, custom_headers=None, raw=False, callback=None, **operation_config): @@ -1606,81 +1502,27 @@ def tag_image_in_stream( return deserialized tag_image_in_stream.metadata = {'url': '/tag'} - def recognize_text_in_stream( - self, image, mode, custom_headers=None, raw=False, callback=None, **operation_config): - """Recognize Text operation. When you use the Recognize Text interface, + def read_in_stream( + self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + """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 - Get Recognize Text Operation Result operation. - - :param image: An image stream. - :type image: Generator - :param mode: Type of text to recognize. Possible values include: - 'Handwritten', 'Printed' - :type mode: str or - ~azure.cognitiveservices.vision.computervision.models.TextRecognitionMode - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param callback: When specified, will be called with each chunk of - data that is streamed. The callback should take two arguments, the - bytes of the current chunk of data and the response object. If the - data is uploading, response will be None. - :type callback: Callable[Bytes, response=None] - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ComputerVisionErrorException` - """ - # Construct URL - url = self.recognize_text_in_stream.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['mode'] = self._serialize.query("mode", mode, 'TextRecognitionMode') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/octet-stream' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct body - body_content = self._client.stream_upload(image, callback) - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [202]: - raise models.ComputerVisionErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'Operation-Location': 'str', - }) - return client_raw_response - recognize_text_in_stream.metadata = {'url': '/recognizeText'} - - def batch_read_file_in_stream( - self, image, custom_headers=None, raw=False, callback=None, **operation_config): - """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.​. + 'GetReadResult' operation to access OCR results.​. :param image: An image stream. :type image: Generator + :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' + :type language: str or + ~azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1697,7 +1539,7 @@ def batch_read_file_in_stream( :class:`ComputerVisionErrorException` """ # Construct URL - url = self.batch_read_file_in_stream.metadata['url'] + url = self.read_in_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -1705,6 +1547,8 @@ def batch_read_file_in_stream( # Construct parameters query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} @@ -1728,4 +1572,4 @@ def batch_read_file_in_stream( 'Operation-Location': 'str', }) return client_raw_response - batch_read_file_in_stream.metadata = {'url': '/read/core/asyncBatchAnalyze'} + read_in_stream.metadata = {'url': '/read/analyze'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/setup.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/setup.py index e60acd4d7a62..485791c6943d 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/setup.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -67,6 +69,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ], zip_safe=False, From 04f8ee1aa48ea8af17dcd23492f08dd24f9c146e Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Mon, 18 May 2020 09:27:54 -0700 Subject: [PATCH 2/3] ChangeLog --- .../CHANGELOG.md | 23 +++++++++++++++++++ .../vision/computervision/version.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/CHANGELOG.md b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/CHANGELOG.md index 45c9901dbbd4..830deb5428e4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/CHANGELOG.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/CHANGELOG.md @@ -1,5 +1,28 @@ # Release History +## 0.6.0 (2020-05-18) + +**Features** + + - Model Line has a new parameter language + - Added operation ComputerVisionClientOperationsMixin.read + - Added operation ComputerVisionClientOperationsMixin.get_read_result + - Added operation ComputerVisionClientOperationsMixin.read_in_stream + +**Breaking changes** + + - Parameter words of model Line is now required + - Parameter bounding_box of model Line is now required + - Parameter text of model Line is now required + - Parameter confidence of model Word is now required + - Removed operation ComputerVisionClientOperationsMixin.get_text_operation_result + - Removed operation ComputerVisionClientOperationsMixin.get_read_operation_result + - Removed operation ComputerVisionClientOperationsMixin.recognize_text_in_stream + - Removed operation ComputerVisionClientOperationsMixin.recognize_text + - Removed operation ComputerVisionClientOperationsMixin.batch_read_file + - Removed operation ComputerVisionClientOperationsMixin.batch_read_file_in_stream + - Model ReadOperationResult has a new signature + ## 0.5.0 (2019-10-01) **Features** diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py index 266f5a486d79..5a7feab42d26 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.5.0" +VERSION = "0.6.0" From 72594c5fb473713a8791af718eaca7b1f9e39f07 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Mon, 18 May 2020 10:53:02 -0700 Subject: [PATCH 3/3] Udpate Readme --- .../README.md | 331 +++++++++++++++++- .../sdk_packaging.toml | 1 + 2 files changed, 320 insertions(+), 12 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md index 815aa1ff704c..8d793d5cf878 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/README.md @@ -1,21 +1,328 @@ -# Microsoft Azure SDK for Python +# Azure Cognitive Services Computer Vision SDK for Python -This is the Microsoft Azure Cognitive Services Computer Vision Client Library. -This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. -For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/) +The Computer Vision service provides developers with access to advanced algorithms for processing images and returning information. Computer Vision algorithms analyze the content of an image in different ways, depending on the visual features you're interested in. +You can use Computer Vision in your application to: -# Usage +- Analyze images for insight +- Extract text from images +- Generate thumbnails -For code examples, see [Cognitive Services Computer Vision](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) -on docs.microsoft.com. +Looking for more documentation? +* [SDK reference documentation](https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision) +* [Cognitive Services Computer Vision documentation](https://docs.microsoft.com/azure/cognitive-services/computer-vision/) -# Provide Feedback +## Prerequisites -If you encounter any bugs or have suggestions, please file an issue in the -[Issues](https://github.com/Azure/azure-sdk-for-python/issues) -section of the project. +* Azure subscription - [Create a free account][azure_sub] +* Azure [Computer Vision resource][computervision_resource] +* [Python 3.6+][python] +If you need a Computer Vision API account, you can create one with this [Azure CLI][azure_cli] command: -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-vision-computervision%2FREADME.png) +```Bash +RES_REGION=westeurope +RES_GROUP= +ACCT_NAME= + +az cognitiveservices account create \ + --resource-group $RES_GROUP \ + --name $ACCT_NAME \ + --location $RES_REGION \ + --kind ComputerVision \ + --sku S1 \ + --yes +``` + +## Installation + +Install the Azure Cognitive Services Computer Vision SDK with [pip][pip], optionally within a [virtual environment][venv]. + +### Configure a virtual environment (optional) + +Although not required, you can keep your base system and Azure SDK environments isolated from one another if you use a [virtual environment][virtualenv]. Execute the following commands to configure and then enter a virtual environment with [venv][venv], such as `cogsrv-vision-env`: + +```Bash +python3 -m venv cogsrv-vision-env +source cogsrv-vision-env/bin/activate +``` + +### Install the SDK + +Install the Azure Cognitive Services Computer Vision SDK for Python [package][pypi_computervision] with [pip][pip]: + +```Bash +pip install azure-cognitiveservices-vision-computervision +``` + +## Authentication + +Once you create your Computer Vision resource, you need its **region**, and one of its **account keys** to instantiate the client object. + +Use these values when you create the instance of the [ComputerVisionClient][ref_computervisionclient] client object. + +### Get credentials + +Use the [Azure CLI][cloud_shell] snippet below to populate two environment variables with the Computer Vision account **region** and one of its **keys** (you can also find these values in the [Azure portal][azure_portal]). The snippet is formatted for the Bash shell. + +```Bash +RES_GROUP= +ACCT_NAME= + +export ACCOUNT_REGION=$(az cognitiveservices account show \ + --resource-group $RES_GROUP \ + --name $ACCT_NAME \ + --query location \ + --output tsv) + +export ACCOUNT_KEY=$(az cognitiveservices account keys list \ + --resource-group $RES_GROUP \ + --name $ACCT_NAME \ + --query key1 \ + --output tsv) +``` + +### Create client + +Once you've populated the `ACCOUNT_REGION` and `ACCOUNT_KEY` environment variables, you can create the [ComputerVisionClient][ref_computervisionclient] client object. + +```Python +from azure.cognitiveservices.vision.computervision import ComputerVisionClient +from azure.cognitiveservices.vision.computervision.models import VisualFeatureTypes +from msrest.authentication import CognitiveServicesCredentials + +import os +region = os.environ['ACCOUNT_REGION'] +key = os.environ['ACCOUNT_KEY'] + +credentials = CognitiveServicesCredentials(key) +client = ComputerVisionClient( + endpoint="https://" + region + ".api.cognitive.microsoft.com/", + credentials=credentials +) +``` + +## Usage + +Once you've initialized a [ComputerVisionClient][ref_computervisionclient] client object, you can: + +* Analyze an image: You can analyze an image for certain features such as faces, colors, tags. +* Generate thumbnails: Create a custom JPEG image to use as a thumbnail of the original image. +* Get description of an image: Get a description of the image based on its subject domain. + +For more information about this service, see [What is Computer Vision?][computervision_docs]. + +## Examples + +The following sections provide several code snippets covering some of the most common Computer Vision tasks, including: + +* [Analyze an image](#analyze-an-image) +* [Get subject domain list](#get-subject-domain-list) +* [Analyze an image by domain](#analyze-an-image-by-domain) +* [Get text description of an image](#get-text-description-of-an-image) +* [Get handwritten text from image](#get-text-from-image) +* [Generate thumbnail](#generate-thumbnail) + +### Analyze an image + +You can analyze an image for certain features with [`analyze_image`][ref_computervisionclient_analyze_image]. Use the [`visual_features`][ref_computervision_model_visualfeatures] property to set the types of analysis to perform on the image. Common values are `VisualFeatureTypes.tags` and `VisualFeatureTypes.description`. + +```Python +url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/Broadway_and_Times_Square_by_night.jpg/450px-Broadway_and_Times_Square_by_night.jpg" + +image_analysis = client.analyze_image(url,visual_features=[VisualFeatureTypes.tags]) + +for tag in image_analysis.tags: + print(tag) +``` + +### Get subject domain list + +Review the subject domains used to analyze your image with [`list_models`][ref_computervisionclient_list_models]. These domain names are used when [analyzing an image by domain](#analyze-an-image-by-domain). An example of a domain is `landmarks`. + +```Python +models = client.list_models() + +for x in models.models_property: + print(x) +``` + +### Analyze an image by domain + +You can analyze an image by subject domain with [`analyze_image_by_domain`][ref_computervisionclient_analyze_image_by_domain]. Get the [list of supported subject domains](#get-subject-domain-list) in order to use the correct domain name. + +```Python +domain = "landmarks" +url = "https://images.pexels.com/photos/338515/pexels-photo-338515.jpeg" +language = "en" + +analysis = client.analyze_image_by_domain(domain, url, language) + +for landmark in analysis.result["landmarks"]: + print(landmark["name"]) + print(landmark["confidence"]) +``` + +### Get text description of an image + +You can get a language-based text description of an image with [`describe_image`][ref_computervisionclient_describe_image]. Request several descriptions with the `max_description` property if you are doing text analysis for keywords associated with the image. Examples of a text description for the following image include `a train crossing a bridge over a body of water`, `a large bridge over a body of water`, and `a train crossing a bridge over a large body of water`. + +```Python +domain = "landmarks" +url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" +language = "en" +max_descriptions = 3 + +analysis = client.describe_image(url, max_descriptions, language) + +for caption in analysis.captions: + print(caption.text) + print(caption.confidence) +``` + +### Get text from image + +You can get any handwritten or printed text from an image. This requires two calls to the SDK: [`read`][ref_computervisionclient_read] and [`get_read_result`][ref_computervisionclient_get_read_result]. The call to read is asynchronous. In the results of the get_read_result call, you need to check if the first call completed with [`OperationStatusCodes`][ref_computervision_model_operationstatuscodes] before extracting the text data. The results include the text as well as the bounding box coordinates for the text. + +```Python +# import models +from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes + +url = "https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/raw/master/samples/vision/images/make_things_happen.jpg" +raw = True +numberOfCharsInOperationId = 36 + +# SDK call +rawHttpResponse = client.read(url, language="en", raw=True) + +# Get ID from returned headers +operationLocation = rawHttpResponse.headers["Operation-Location"] +idLocation = len(operationLocation) - numberOfCharsInOperationId +operationId = operationLocation[idLocation:] + +# SDK call +result = client.get_read_result(operationId) + +# Get data +if result.status == OperationStatusCodes.succeeded: + + for line in result.analyze_result.read_results[0].lines: + print(line.text) + print(line.bounding_box) +``` + +### Generate thumbnail + +You can generate a thumbnail (JPG) of an image with [`generate_thumbnail`][ref_computervisionclient_generate_thumbnail]. The thumbnail does not need to be in the same proportions as the original image. + +This example uses the [Pillow][pypi_pillow] package to save the new thumbnail image locally. + +```Python +from PIL import Image +import io + +width = 50 +height = 50 +url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" + +thumbnail = client.generate_thumbnail(width, height, url) + +for x in thumbnail: + image = Image.open(io.BytesIO(x)) + +image.save('thumbnail.jpg') +``` + +## Troubleshooting + +### General + +When you interact with the [ComputerVisionClient][ref_computervisionclient] client object using the Python SDK, the [`ComputerVisionErrorException`][ref_computervision_computervisionerrorexception] class is used to return errors. Errors returned by the service correspond to the same HTTP status codes returned for REST API requests. + +For example, if you try to analyze an image with an invalid key, a `401` error is returned. In the following snippet, the [error][ref_httpfailure] is handled gracefully by catching the exception and displaying additional information about the error. + +```Python + +domain = "landmarks" +url = "http://www.public-domain-photos.com/free-stock-photos-4/travel/san-francisco/golden-gate-bridge-in-san-francisco.jpg" +language = "en" +max_descriptions = 3 + +try: + analysis = client.describe_image(url, max_descriptions, language) + + for caption in analysis.captions: + print(caption.text) + print(caption.confidence) +except HTTPFailure as e: + if e.status_code == 401: + print("Error unauthorized. Make sure your key and region are correct.") + else: + raise +``` + +### Handle transient errors with retries + +While working with the [ComputerVisionClient][ref_computervisionclient] client, you might encounter transient failures caused by [rate limits][computervision_request_units] enforced by the service, or other transient problems like network outages. For information about handling these types of failures, see [Retry pattern][azure_pattern_retry] in the Cloud Design Patterns guide, and the related [Circuit Breaker pattern][azure_pattern_circuit_breaker]. + +## Next steps + +### More sample code + +Several Computer Vision Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Computer Vision: + +* [See sample repo][recognize-text] + +### Additional documentation + +For more extensive documentation on the Computer Vision service, see the [Azure Computer Vision documentation][computervision_docs] on docs.microsoft.com. + + +[pip]: https://pypi.org/project/pip/ +[python]: https://www.python.org/downloads/ + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker +[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry +[azure_portal]: https://portal.azure.com +[azure_sub]: https://azure.microsoft.com/free/ + +[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview + +[venv]: https://docs.python.org/3/library/venv.html +[virtualenv]: https://virtualenv.pypa.io + +[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision + +[pypi_computervision]:https://pypi.org/project/azure-cognitiveservices-vision-computervision/ +[pypi_pillow]:https://pypi.org/project/Pillow/ + +[ref_computervision_sdk]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision?view=azure-python +[ref_computervision_computervisionerrorexception]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.computervisionerrorexception?view=azure-python +[ref_httpfailure]: https://docs.microsoft.com/python/api/msrest/msrest.exceptions.httpoperationerror?view=azure-python + + +[computervision_resource]: https://docs.microsoft.com/azure/cognitive-services/computer-vision/vision-api-how-to-topics/howtosubscribe + +[computervision_docs]: https://docs.microsoft.com/azure/cognitive-services/computer-vision/home + +[ref_computervisionclient]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python + + +[ref_computervisionclient_analyze_image]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-url--visual-features-none--details-none--language--en---custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_list_models]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#list-models-custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_analyze_image_by_domain]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-by-domain-model--url--language--en---custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_describe_image]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#describe-image-url--max-candidates--1---language--en---custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_read]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#read-url--mode--custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_get_read_result]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#get-read-result-operation-id--custom-headers-none--raw-false----operation-config- +[ref_computervisionclient_generate_thumbnail]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#generate-thumbnail-width--height--url--smart-cropping-false--custom-headers-none--raw-false--callback-none----operation-config- + + +[ref_computervision_model_visualfeatures]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.visualfeaturetypes?view=azure-python + +[ref_computervision_model_operationstatuscodes]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.operationstatuscodes?view=azure-python + +[computervision_request_units]:https://azure.microsoft.com/pricing/details/cognitive-services/computer-vision/ + +[recognize-text]:https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/blob/master/samples/vision/computer_vision_samples.py \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/sdk_packaging.toml b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/sdk_packaging.toml index 164ed3e891e0..287064235678 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/sdk_packaging.toml +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/sdk_packaging.toml @@ -5,3 +5,4 @@ package_doc_id = "cognitive-services" is_stable = false is_arm = false need_msrestazure = false +auto_update = false \ No newline at end of file