From 0e23e68901ade50e5358ed90704ad983bc8b292f Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 20 Jul 2018 16:42:30 -0700 Subject: [PATCH 01/14] Generated from d796a072098d20051200552d7cbd6608587ffd23 (#2951) Enable Computer Vision Client to customize endpoint. --- .../vision/computervision/__init__.py | 4 +- ...ision_api.py => computer_vision_client.py} | 78 ++++++++----------- .../vision/computervision/models/__init__.py | 4 +- ...ums.py => computer_vision_client_enums.py} | 16 ---- .../vision/computervision/version.py | 2 +- 5 files changed, 38 insertions(+), 66 deletions(-) rename azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/{computer_vision_api.py => computer_vision_client.py} (94%) rename azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/{computer_vision_api_enums.py => computer_vision_client_enums.py} (84%) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/__init__.py index 13baf4710282..4c65cab27d1b 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/__init__.py @@ -9,10 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .computer_vision_api import ComputerVisionAPI +from .computer_vision_client import ComputerVisionClient from .version import VERSION -__all__ = ['ComputerVisionAPI'] +__all__ = ['ComputerVisionClient'] __version__ = VERSION diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py similarity index 94% rename from azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py rename to azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index e6999202c26b..f163cb2d4020 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -17,63 +17,53 @@ from . import models -class ComputerVisionAPIConfiguration(Configuration): - """Configuration for ComputerVisionAPI +class ComputerVisionClientConfiguration(Configuration): + """Configuration for ComputerVisionClient Note that all parameters used to create this instance are saved as instance attributes. - :param azure_region: Supported Azure regions for Cognitive Services - endpoints. Possible values include: 'westus', 'westeurope', - 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', - 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', - 'brazilsouth' - :type azure_region: str or - ~azure.cognitiveservices.vision.computervision.models.AzureRegions + :param endpoint: Supported Cognitive Services endpoints + :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( - self, azure_region, credentials): + self, endpoint, credentials): - if azure_region is None: - raise ValueError("Parameter 'azure_region' must not be None.") + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = 'https://{AzureRegion}.api.cognitive.microsoft.com/vision/v2.0' + base_url = '{Endpoint}/vision/v2.0' - super(ComputerVisionAPIConfiguration, self).__init__(base_url) + super(ComputerVisionClientConfiguration, self).__init__(base_url) self.add_user_agent('azure-cognitiveservices-vision-computervision/{}'.format(VERSION)) - self.azure_region = azure_region + self.endpoint = endpoint self.credentials = credentials -class ComputerVisionAPI(SDKClient): +class ComputerVisionClient(SDKClient): """The Computer Vision API provides state-of-the-art algorithms to process images and return information. For example, it can be used to determine if an image contains mature content, or it can be used to find all the faces in an image. It also has other features like estimating dominant and accent colors, categorizing the content of images, and describing an image with complete English sentences. Additionally, it can also intelligently generate images thumbnails for displaying large images effectively. :ivar config: Configuration for client. - :vartype config: ComputerVisionAPIConfiguration - - :param azure_region: Supported Azure regions for Cognitive Services - endpoints. Possible values include: 'westus', 'westeurope', - 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', - 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', - 'brazilsouth' - :type azure_region: str or - ~azure.cognitiveservices.vision.computervision.models.AzureRegions + :vartype config: ComputerVisionClientConfiguration + + :param endpoint: Supported Cognitive Services endpoints + :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( - self, azure_region, credentials): + self, endpoint, credentials): - self.config = ComputerVisionAPIConfiguration(azure_region, credentials) - super(ComputerVisionAPI, self).__init__(self.config.credentials, self.config) + self.config = ComputerVisionClientConfiguration(endpoint, credentials) + 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.0' @@ -105,7 +95,7 @@ def list_models( # Construct URL url = self.list_models.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -190,7 +180,7 @@ def analyze_image( # Construct URL url = self.analyze_image.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -273,7 +263,7 @@ def generate_thumbnail( # Construct URL url = self.generate_thumbnail.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -354,7 +344,7 @@ def recognize_printed_text( # Construct URL url = self.recognize_printed_text.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -433,7 +423,7 @@ def describe_image( # Construct URL url = self.describe_image.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -509,7 +499,7 @@ def tag_image( # Construct URL url = self.tag_image.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -585,7 +575,7 @@ def analyze_image_by_domain( # Construct URL url = self.analyze_image_by_domain.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'model': self._serialize.url("model", model, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -652,7 +642,7 @@ def recognize_text( # Construct URL url = self.recognize_text.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -709,7 +699,7 @@ def get_text_operation_result( # Construct URL url = self.get_text_operation_result.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + '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) @@ -794,7 +784,7 @@ def analyze_image_in_stream( # Construct URL url = self.analyze_image_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -875,7 +865,7 @@ def generate_thumbnail_in_stream( # Construct URL url = self.generate_thumbnail_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -959,7 +949,7 @@ def recognize_printed_text_in_stream( # Construct URL url = self.recognize_printed_text_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -1041,7 +1031,7 @@ def describe_image_in_stream( # Construct URL url = self.describe_image_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -1120,7 +1110,7 @@ def tag_image_in_stream( # Construct URL url = self.tag_image_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -1199,7 +1189,7 @@ def analyze_image_by_domain_in_stream( # Construct URL url = self.analyze_image_by_domain_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'model': self._serialize.url("model", model, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1269,7 +1259,7 @@ def recognize_text_in_stream( # Construct URL url = self.recognize_text_in_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 001e34518c57..8f036444cccf 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -73,14 +73,13 @@ from .tag_result import TagResult from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException from .image_url import ImageUrl -from .computer_vision_api_enums import ( +from .computer_vision_client_enums import ( TextOperationStatusCodes, Gender, ComputerVisionErrorCodes, VisualFeatureTypes, OcrLanguages, TextRecognitionMode, - AzureRegions, Details, ) @@ -122,6 +121,5 @@ 'VisualFeatureTypes', 'OcrLanguages', 'TextRecognitionMode', - 'AzureRegions', 'Details', ] diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py similarity index 84% rename from azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py rename to azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index 66fb4dc38436..c97e56a9787a 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -91,22 +91,6 @@ class TextRecognitionMode(str, Enum): printed = "Printed" -class AzureRegions(str, Enum): - - westus = "westus" - westeurope = "westeurope" - southeastasia = "southeastasia" - eastus2 = "eastus2" - westcentralus = "westcentralus" - westus2 = "westus2" - eastus = "eastus" - southcentralus = "southcentralus" - northeurope = "northeurope" - eastasia = "eastasia" - australiaeast = "australiaeast" - brazilsouth = "brazilsouth" - - class Details(str, Enum): celebrities = "Celebrities" diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py index 9bd1dfac7ecb..63f83465c874 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.2.0" +VERSION = "2.0" From 074f39e370ff6245e0c2c51e7e9c4b518a0a96b9 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 30 Jul 2018 10:24:03 -0700 Subject: [PATCH 02/14] Generated from a3c7072f01f807edbb028085a23278d6f7980fa1 (#2990) ComputerVision: bug fixes for /describe and /analyze * Inconsistent argument type for `/analyze?details=...` between URL and stream methods * BingIU imagetype return values needs to be integral * Description `maxCandidates` argument needs to be integral --- .../computervision/computer_vision_client.py | 19 ++++++++++--------- .../computervision/models/image_type.py | 8 ++++---- .../computervision/models/image_type_py3.py | 10 +++++----- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index f163cb2d4020..fd2f9fce7750 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -384,7 +384,7 @@ def recognize_printed_text( recognize_printed_text.metadata = {'url': '/ocr'} def describe_image( - self, url, max_candidates="1", language="en", custom_headers=None, raw=False, **operation_config): + self, url, max_candidates=1, language="en", custom_headers=None, raw=False, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. @@ -399,7 +399,7 @@ def describe_image( :type url: str :param max_candidates: Maximum number of candidate descriptions to be returned. The default is 1. - :type max_candidates: str + :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -430,7 +430,7 @@ def describe_image( # Construct parameters query_parameters = {} if max_candidates is not None: - query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'str') + query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -756,8 +756,9 @@ def analyze_image_in_stream( :param details: A string indicating which domain-specific details to return. Multiple values should be comma-separated. Valid visual feature types include:Celebrities - identifies celebrities if detected - in the image. Possible values include: 'Celebrities', 'Landmarks' - :type details: str + in the image. + :type details: list[str or + ~azure.cognitiveservices.vision.computervision.models.Details] :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -793,7 +794,7 @@ def analyze_image_in_stream( if visual_features is not None: query_parameters['visualFeatures'] = self._serialize.query("visual_features", visual_features, '[VisualFeatureTypes]', div=',') if details is not None: - query_parameters['details'] = self._serialize.query("details", details, 'str') + query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -989,7 +990,7 @@ def recognize_printed_text_in_stream( recognize_printed_text_in_stream.metadata = {'url': '/ocr'} def describe_image_in_stream( - self, image, max_candidates="1", language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, max_candidates=1, language="en", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. @@ -1004,7 +1005,7 @@ def describe_image_in_stream( :type image: Generator :param max_candidates: Maximum number of candidate descriptions to be returned. The default is 1. - :type max_candidates: str + :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -1038,7 +1039,7 @@ def describe_image_in_stream( # Construct parameters query_parameters = {} if max_candidates is not None: - query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'str') + query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type.py index 2c475662850c..0ddb88e7ba12 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type.py @@ -16,15 +16,15 @@ class ImageType(Model): """An object providing possible image types and matching confidence levels. :param clip_art_type: Confidence level that the image is a clip art. - :type clip_art_type: float + :type clip_art_type: int :param line_drawing_type: Confidence level that the image is a line drawing. - :type line_drawing_type: float + :type line_drawing_type: int """ _attribute_map = { - 'clip_art_type': {'key': 'clipArtType', 'type': 'float'}, - 'line_drawing_type': {'key': 'lineDrawingType', 'type': 'float'}, + 'clip_art_type': {'key': 'clipArtType', 'type': 'int'}, + 'line_drawing_type': {'key': 'lineDrawingType', 'type': 'int'}, } def __init__(self, **kwargs): diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type_py3.py index ecfd8b6af808..ef7b200ea0af 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_type_py3.py @@ -16,18 +16,18 @@ class ImageType(Model): """An object providing possible image types and matching confidence levels. :param clip_art_type: Confidence level that the image is a clip art. - :type clip_art_type: float + :type clip_art_type: int :param line_drawing_type: Confidence level that the image is a line drawing. - :type line_drawing_type: float + :type line_drawing_type: int """ _attribute_map = { - 'clip_art_type': {'key': 'clipArtType', 'type': 'float'}, - 'line_drawing_type': {'key': 'lineDrawingType', 'type': 'float'}, + 'clip_art_type': {'key': 'clipArtType', 'type': 'int'}, + 'line_drawing_type': {'key': 'lineDrawingType', 'type': 'int'}, } - def __init__(self, *, clip_art_type: float=None, line_drawing_type: float=None, **kwargs) -> None: + def __init__(self, *, clip_art_type: int=None, line_drawing_type: int=None, **kwargs) -> None: super(ImageType, self).__init__(**kwargs) self.clip_art_type = clip_art_type self.line_drawing_type = line_drawing_type From 448ab52f1b0f13f1b7d143fe3fc1d180b4888c0d Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 11 Oct 2018 09:16:20 -0700 Subject: [PATCH 03/14] [AutoPR cognitiveservices/data-plane/ComputerVision] Split Ocr out into own Swagger file (#3543) * Generated from 0dc03413967addc6fb33eba01bf4b8074f5fe91a Split Ocr out * Packaging update of azure-cognitiveservices-vision-computervision --- .../MANIFEST.in | 1 - .../README.rst | 2 +- .../azure/__init__.py | 2 +- .../azure/cognitiveservices/__init__.py | 2 +- .../cognitiveservices/vision/__init__.py | 2 +- .../computervision/computer_vision_client.py | 94 +++++++++---------- .../vision/computervision/models/__init__.py | 28 +++--- .../models/computer_vision_client_enums.py | 16 ++-- .../azure_bdist_wheel.py | 54 ----------- .../setup.cfg | 1 - .../setup.py | 22 +++-- 11 files changed, 85 insertions(+), 139 deletions(-) delete mode 100644 azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py diff --git a/azure-cognitiveservices-vision-computervision/MANIFEST.in b/azure-cognitiveservices-vision-computervision/MANIFEST.in index 9ecaeb15de50..bb37a2723dae 100644 --- a/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -1,2 +1 @@ include *.rst -include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/README.rst b/azure-cognitiveservices-vision-computervision/README.rst index ee1ba86cf7c0..eee101b4fb52 100644 --- a/azure-cognitiveservices-vision-computervision/README.rst +++ b/azure-cognitiveservices-vision-computervision/README.rst @@ -3,7 +3,7 @@ Microsoft Azure SDK for Python This is the Microsoft Azure Cognitive Services Computer Vision Client Library. -This package has been tested with Python 2.7, 3.4, 3.5 and 3.6. +This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. For a more complete set of Azure libraries, see the `azure `__ bundle package. diff --git a/azure-cognitiveservices-vision-computervision/azure/__init__.py b/azure-cognitiveservices-vision-computervision/azure/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index fd2f9fce7750..949f9d69e590 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -104,13 +104,13 @@ def list_models( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + 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) @@ -195,6 +195,7 @@ def analyze_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -203,9 +204,8 @@ def analyze_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -276,6 +276,7 @@ def generate_thumbnail( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -284,9 +285,8 @@ def generate_thumbnail( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=True, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) @@ -356,6 +356,7 @@ def recognize_printed_text( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -364,9 +365,8 @@ def recognize_printed_text( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -436,6 +436,7 @@ def describe_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -444,9 +445,8 @@ def describe_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -510,6 +510,7 @@ def tag_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -518,9 +519,8 @@ def tag_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -587,6 +587,7 @@ def analyze_image_by_domain( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -595,9 +596,8 @@ def analyze_image_by_domain( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -660,9 +660,8 @@ def recognize_text( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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) @@ -709,13 +708,13 @@ def get_text_operation_result( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + 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) @@ -800,6 +799,7 @@ def analyze_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -808,9 +808,8 @@ def analyze_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -879,6 +878,7 @@ def generate_thumbnail_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -887,9 +887,8 @@ def generate_thumbnail_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=True, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) @@ -962,6 +961,7 @@ def recognize_printed_text_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -970,9 +970,8 @@ def recognize_printed_text_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1045,6 +1044,7 @@ def describe_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1053,9 +1053,8 @@ def describe_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1122,6 +1121,7 @@ def tag_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1130,9 +1130,8 @@ def tag_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1202,6 +1201,7 @@ def analyze_image_by_domain_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1210,9 +1210,8 @@ def analyze_image_by_domain_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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 [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1278,9 +1277,8 @@ def recognize_text_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + 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) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 8f036444cccf..f487c5eecaad 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -10,10 +10,6 @@ # -------------------------------------------------------------------------- try: - from .word_py3 import Word - from .line_py3 import Line - from .recognition_result_py3 import RecognitionResult - from .text_operation_result_py3 import TextOperationResult from .face_rectangle_py3 import FaceRectangle from .celebrities_model_py3 import CelebritiesModel from .landmarks_model_py3 import LandmarksModel @@ -41,11 +37,11 @@ from .tag_result_py3 import TagResult from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException from .image_url_py3 import ImageUrl + from .word_py3 import Word + from .line_py3 import Line + from .recognition_result_py3 import RecognitionResult + from .text_operation_result_py3 import TextOperationResult except (SyntaxError, ImportError): - from .word import Word - from .line import Line - from .recognition_result import RecognitionResult - from .text_operation_result import TextOperationResult from .face_rectangle import FaceRectangle from .celebrities_model import CelebritiesModel from .landmarks_model import LandmarksModel @@ -73,10 +69,14 @@ from .tag_result import TagResult from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException from .image_url import ImageUrl + from .word import Word + from .line import Line + from .recognition_result import RecognitionResult + from .text_operation_result import TextOperationResult from .computer_vision_client_enums import ( - TextOperationStatusCodes, Gender, ComputerVisionErrorCodes, + TextOperationStatusCodes, VisualFeatureTypes, OcrLanguages, TextRecognitionMode, @@ -84,10 +84,6 @@ ) __all__ = [ - 'Word', - 'Line', - 'RecognitionResult', - 'TextOperationResult', 'FaceRectangle', 'CelebritiesModel', 'LandmarksModel', @@ -115,9 +111,13 @@ 'TagResult', 'ComputerVisionError', 'ComputerVisionErrorException', 'ImageUrl', - 'TextOperationStatusCodes', + 'Word', + 'Line', + 'RecognitionResult', + 'TextOperationResult', 'Gender', 'ComputerVisionErrorCodes', + 'TextOperationStatusCodes', 'VisualFeatureTypes', 'OcrLanguages', 'TextRecognitionMode', diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index c97e56a9787a..3354b6007794 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -12,14 +12,6 @@ from enum import Enum -class TextOperationStatusCodes(str, Enum): - - not_started = "Not Started" - running = "Running" - failed = "Failed" - succeeded = "Succeeded" - - class Gender(str, Enum): male = "Male" @@ -43,6 +35,14 @@ class ComputerVisionErrorCodes(str, Enum): storage_exception = "StorageException" +class TextOperationStatusCodes(str, Enum): + + not_started = "Not Started" + running = "Running" + failed = "Failed" + succeeded = "Succeeded" + + class VisualFeatureTypes(str, Enum): image_type = "ImageType" diff --git a/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py b/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b61775..000000000000 --- a/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/azure-cognitiveservices-vision-computervision/setup.cfg b/azure-cognitiveservices-vision-computervision/setup.cfg index 6197b40d106e..3c6e79cf31da 100644 --- a/azure-cognitiveservices-vision-computervision/setup.cfg +++ b/azure-cognitiveservices-vision-computervision/setup.cfg @@ -1,3 +1,2 @@ [bdist_wheel] universal=1 -azure-namespace-package=azure-cognitiveservices-vision-nspkg \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/setup.py b/azure-cognitiveservices-vision-computervision/setup.py index 7402c1967c37..32cce8b8ac31 100644 --- a/azure-cognitiveservices-vision-computervision/setup.py +++ b/azure-cognitiveservices-vision-computervision/setup.py @@ -10,12 +10,6 @@ import os.path from io import open from setuptools import find_packages, setup -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - logger.warn("Wheel is not available, disabling bdist_wheel hook") - cmdclass = {} # Change the PACKAGE_NAME only to change folder and different name PACKAGE_NAME = "azure-cognitiveservices-vision-computervision" @@ -72,13 +66,23 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License', ], zip_safe=False, - packages=find_packages(exclude=["tests"]), + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.cognitiveservices', + 'azure.cognitiveservices.vision', + ]), install_requires=[ - 'msrest>=0.4.29,<2.0.0', + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], - cmdclass=cmdclass + extras_require={ + ":python_version<'3.0'": ['azure-cognitiveservices-vision-nspkg'], + } ) From 2a9d343d74d399c12a956fad063c82985d25d637 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 11 Oct 2018 16:54:33 -0700 Subject: [PATCH 04/14] [AutoPR cognitiveservices/data-plane/ComputerVision] Rename examples to match generated names (#3541) * Generated from 5aa27bd9abb8f6f416b054d64536ee2f7175f662 Rename examples to match generated names * Packaging update of azure-cognitiveservices-vision-computervision * Generated from 5aa27bd9abb8f6f416b054d64536ee2f7175f662 Rename examples to match generated names From 907b876c3cac4f66239066dec5960ced324e9004 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 10 Dec 2018 17:06:03 -0800 Subject: [PATCH 05/14] [AutoPR cognitiveservices/data-plane/ComputerVision] Add areaOfInterest and detectObject to CV API (#3997) * Generated from 0bc892729baf0d049695c873e9afe139211c259d Add areaOfInterest and detectObject * Replace the current swagger with an auto-generated one. * Add example files for areaOfInterest and detectObject. * Fix example validation errors for analyze and describe. * A few fixes for generating java sdk * Packaging update of azure-cognitiveservices-vision-computervision --- .../MANIFEST.in | 4 + .../computervision/computer_vision_client.py | 1056 +++++++++++------ .../vision/computervision/models/__init__.py | 63 +- .../computervision/models/adult_info.py | 6 +- .../computervision/models/adult_info_py3.py | 6 +- .../models/area_of_interest_result.py | 46 + .../models/area_of_interest_result_py3.py | 46 + .../computervision/models/bounding_rect.py | 40 + .../models/bounding_rect_py3.py | 40 + .../vision/computervision/models/category.py | 2 +- .../computervision/models/category_py3.py | 2 +- .../models/celebrities_model.py | 5 +- .../models/celebrities_model_py3.py | 5 +- .../models/celebrity_results.py | 4 +- .../models/celebrity_results_py3.py | 4 +- .../models/computer_vision_client_enums.py | 40 +- .../models/computer_vision_error.py | 13 +- .../models/computer_vision_error_py3.py | 13 +- .../computervision/models/detect_result.py | 45 + .../models/detect_result_py3.py | 45 + .../computervision/models/detected_object.py | 52 + .../models/detected_object_py3.py | 52 + .../models/domain_model_results.py | 2 +- .../models/domain_model_results_py3.py | 2 +- .../computervision/models/face_description.py | 3 +- .../models/face_description_py3.py | 3 +- .../computervision/models/face_rectangle.py | 10 +- .../models/face_rectangle_py3.py | 10 +- .../computervision/models/image_analysis.py | 20 +- .../models/image_analysis_py3.py | 22 +- .../computervision/models/image_caption.py | 4 +- .../models/image_caption_py3.py | 4 +- .../computervision/models/image_metadata.py | 6 +- .../models/image_metadata_py3.py | 6 +- .../vision/computervision/models/image_tag.py | 8 +- .../computervision/models/image_tag_py3.py | 8 +- .../vision/computervision/models/image_url.py | 2 +- .../computervision/models/image_url_py3.py | 2 +- .../computervision/models/landmark_results.py | 4 +- .../models/landmark_results_py3.py | 4 +- .../computervision/models/landmarks_model.py | 3 +- .../models/landmarks_model_py3.py | 3 +- .../models/model_description.py | 4 +- .../models/model_description_py3.py | 4 +- .../computervision/models/object_hierarchy.py | 40 + .../models/object_hierarchy_py3.py | 40 + .../computervision/models/ocr_region.py | 2 +- .../computervision/models/ocr_region_py3.py | 2 +- .../computervision/models/ocr_result.py | 4 +- .../computervision/models/ocr_result_py3.py | 4 +- 50 files changed, 1297 insertions(+), 518 deletions(-) create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result_py3.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect_py3.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result_py3.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object_py3.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy_py3.py diff --git a/azure-cognitiveservices-vision-computervision/MANIFEST.in b/azure-cognitiveservices-vision-computervision/MANIFEST.in index bb37a2723dae..e437a6594c1b 100644 --- a/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -1 +1,5 @@ include *.rst +include azure/__init__.py +include azure/cognitiveservices/__init__.py +include azure/cognitiveservices/vision/__init__.py + diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index 949f9d69e590..a411c2f3c4fa 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -22,7 +22,7 @@ class ComputerVisionClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Supported Cognitive Services endpoints + :param endpoint: Supported Cognitive Services endpoints. :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. @@ -52,7 +52,7 @@ class ComputerVisionClient(SDKClient): :ivar config: Configuration for client. :vartype config: ComputerVisionClientConfiguration - :param endpoint: Supported Cognitive Services endpoints + :param endpoint: Supported Cognitive Services endpoints. :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. @@ -71,29 +71,65 @@ def __init__( self._deserialize = Deserializer(client_models) - def list_models( - self, custom_headers=None, raw=False, **operation_config): - """This operation returns the list of domain-specific models that are - supported by the Computer Vision API. Currently, the API only supports - one domain-specific model: a celebrity recognizer. A successful - response will be returned in JSON. If the request failed, the response - will contain an error code and a message to help understand what went - wrong. - + def analyze_image( + self, url, visual_features=None, details=None, language="en", custom_headers=None, raw=False, **operation_config): + """This operation extracts a rich set of visual features based on the + image content. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. Within your request, there is an optional + parameter to allow you to choose which features to return. By default, + image categories are returned in the response. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. + + :param url: Publicly reachable URL of an image. + :type url: str + :param visual_features: A string indicating what visual feature types + to return. Multiple values should be comma-separated. Valid visual + feature types include: Categories - categorizes image content + according to a taxonomy defined in documentation. Tags - tags the + image with a detailed list of words related to the image content. + Description - describes the image content with a complete English + sentence. Faces - detects if faces are present. If present, generate + coordinates, gender and age. ImageType - detects if image is clipart + or a line drawing. Color - determines the accent color, dominant + color, and whether an image is black&white. Adult - detects if the + image is pornographic in nature (depicts nudity or a sex act). + Sexually suggestive content is also detected. Objects - detects + various objects within an image, including the approximate location. + The Objects argument is only available in English. + :type visual_features: list[str or + ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] + :param details: A string indicating which domain-specific details to + return. Multiple values should be comma-separated. Valid visual + feature types include: Celebrities - identifies celebrities if + detected in the image, Landmarks - identifies notable landmarks in the + image. + :type details: list[str or + ~azure.cognitiveservices.vision.computervision.models.Details] + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default. es - + Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. + Possible values include: 'en', 'es', 'ja', 'pt', 'zh' + :type language: 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: ListModelsResult or ClientRawResponse if raw=true + :return: ImageAnalysis or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.ListModelsResult - or ~msrest.pipeline.ClientRawResponse + ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or + ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ + image_url = models.ImageUrl(url=url) + # Construct URL - url = self.list_models.metadata['url'] + url = self.analyze_image.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -101,15 +137,25 @@ def list_models( # Construct parameters query_parameters = {} + if visual_features is not None: + query_parameters['visualFeatures'] = self._serialize.query("visual_features", visual_features, '[VisualFeatureTypes]', div=',') + if details is not None: + query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' + 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.get(url, query_parameters, header_parameters) + 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 [200]: @@ -118,45 +164,33 @@ def list_models( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ListModelsResult', response) + deserialized = self._deserialize('ImageAnalysis', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - list_models.metadata = {'url': '/models'} - - def analyze_image( - self, url, visual_features=None, details=None, language="en", custom_headers=None, raw=False, **operation_config): - """This operation extracts a rich set of visual features based on the - image content. Two input methods are supported -- (1) Uploading an - image or (2) specifying an image URL. Within your request, there is an - optional parameter to allow you to choose which features to return. By - default, image categories are returned in the response. + analyze_image.metadata = {'url': '/analyze'} - :param url: Publicly reachable URL of an image + def describe_image( + self, url, max_candidates=1, language="en", custom_headers=None, raw=False, **operation_config): + """This operation generates a description of an image in human readable + language with complete sentences. The description is based on a + collection of content tags, which are also returned by the operation. + More than one description can be generated for each image. Descriptions + are ordered by their confidence score. All descriptions are in English. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. + + :param url: Publicly reachable URL of an image. :type url: str - :param visual_features: A string indicating what visual feature types - to return. Multiple values should be comma-separated. Valid visual - feature types include:Categories - categorizes image content according - to a taxonomy defined in documentation. Tags - tags the image with a - detailed list of words related to the image content. Description - - describes the image content with a complete English sentence. Faces - - detects if faces are present. If present, generate coordinates, gender - and age. ImageType - detects if image is clipart or a line drawing. - Color - determines the accent color, dominant color, and whether an - image is black&white.Adult - detects if the image is pornographic in - nature (depicts nudity or a sex act). Sexually suggestive content is - also detected. - :type visual_features: list[str or - ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] - :param details: A string indicating which domain-specific details to - return. Multiple values should be comma-separated. Valid visual - feature types include:Celebrities - identifies celebrities if detected - in the image. - :type details: list[str or - ~azure.cognitiveservices.vision.computervision.models.Details] + :param max_candidates: Maximum number of candidate descriptions to be + returned. The default is 1. + :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -168,17 +202,17 @@ def analyze_image( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: ImageAnalysis or ClientRawResponse if raw=true + :return: ImageDescription or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or - ~msrest.pipeline.ClientRawResponse + ~azure.cognitiveservices.vision.computervision.models.ImageDescription + or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ image_url = models.ImageUrl(url=url) # Construct URL - url = self.analyze_image.metadata['url'] + url = self.describe_image.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -186,10 +220,8 @@ def analyze_image( # Construct parameters query_parameters = {} - if visual_features is not None: - query_parameters['visualFeatures'] = self._serialize.query("visual_features", visual_features, '[VisualFeatureTypes]', div=',') - if details is not None: - query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') + if max_candidates is not None: + query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -213,55 +245,42 @@ def analyze_image( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImageAnalysis', response) + deserialized = self._deserialize('ImageDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - analyze_image.metadata = {'url': '/analyze'} + describe_image.metadata = {'url': '/describe'} - def generate_thumbnail( - self, width, height, url, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): - """This operation generates a thumbnail image with the user-specified - width and height. By default, the service analyzes the image, - identifies the region of interest (ROI), and generates smart cropping - coordinates based on the ROI. Smart cropping helps when you specify an - aspect ratio that differs from that of the input image. A successful - response contains the thumbnail image binary. If the request failed, - the response contains an error code and a message to help determine - what went wrong. + def detect_objects( + self, url, custom_headers=None, raw=False, **operation_config): + """Performs object detection on the specified image. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. - :param width: Width of the thumbnail. It must be between 1 and 1024. - Recommended minimum of 50. - :type width: int - :param height: Height of the thumbnail. It must be between 1 and 1024. - Recommended minimum of 50. - :type height: int - :param url: Publicly reachable URL of an image + :param url: Publicly reachable URL of an image. :type url: str - :param smart_cropping: Boolean flag for enabling smart cropping. - :type smart_cropping: bool :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: object or ClientRawResponse if raw=true - :rtype: Generator or ~msrest.pipeline.ClientRawResponse + :return: DetectResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.DetectResult or + ~msrest.pipeline.ClientRawResponse :raises: - :class:`HttpOperationError` + :class:`ComputerVisionErrorException` """ image_url = models.ImageUrl(url=url) # Construct URL - url = self.generate_thumbnail.metadata['url'] + url = self.detect_objects.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -269,14 +288,10 @@ def generate_thumbnail( # Construct parameters query_parameters = {} - query_parameters['width'] = self._serialize.query("width", width, 'int', maximum=1023, minimum=1) - query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1023, minimum=1) - if smart_cropping is not None: - query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') # Construct headers header_parameters = {} - header_parameters['Accept'] = 'application/octet-stream' + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -286,39 +301,176 @@ def generate_thumbnail( # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=True, **operation_config) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) + raise models.ComputerVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: - deserialized = self._client.stream_download(response, callback) + deserialized = self._deserialize('DetectResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - generate_thumbnail.metadata = {'url': '/generateThumbnail'} + detect_objects.metadata = {'url': '/detect'} + + def list_models( + self, custom_headers=None, raw=False, **operation_config): + """This operation returns the list of domain-specific models that are + supported by the Computer Vision API. Currently, the API supports + following domain-specific models: celebrity recognizer, landmark + recognizer. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. + + :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: ListModelsResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.ListModelsResult + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ComputerVisionErrorException` + """ + # Construct URL + url = self.list_models.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 = {} + + # 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('ListModelsResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_models.metadata = {'url': '/models'} + + def analyze_image_by_domain( + self, model, url, language="en", custom_headers=None, raw=False, **operation_config): + """This operation recognizes content within an image by applying a + domain-specific model. The list of domain-specific models that are + supported by the Computer Vision API can be retrieved using the /models + GET request. Currently, the API provides following domain-specific + models: celebrities, landmarks. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. + If the request failed, the response will contain an error code and a + message to help understand what went wrong. + + :param model: The domain-specific content to recognize. + :type model: str + :param url: Publicly reachable URL of an image. + :type url: str + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default. es - + Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. + Possible values include: 'en', 'es', 'ja', 'pt', 'zh' + :type language: 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: DomainModelResults or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.DomainModelResults + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ComputerVisionErrorException` + """ + image_url = models.ImageUrl(url=url) + + # Construct URL + url = self.analyze_image_by_domain.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'model': self._serialize.url("model", model, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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 [200]: + raise models.ComputerVisionErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DomainModelResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + analyze_image_by_domain.metadata = {'url': '/models/{model}/analyze'} def recognize_printed_text( self, url, detect_orientation=True, language="unk", custom_headers=None, raw=False, **operation_config): - """Optical Character Recognition (OCR) detects printed text in an image - and extracts the recognized characters into a machine-usable character - stream. Upon success, the OCR results will be returned. Upon failure, - the error code together with an error message will be returned. The - error code can be one of InvalidImageUrl, InvalidImageFormat, - InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or - InternalServerError. + """Optical Character Recognition (OCR) detects text in an image and + extracts the recognized characters into a machine-usable character + stream. + Upon success, the OCR results will be returned. + Upon failure, the error code together with an error message will be + returned. The error code can be one of InvalidImageUrl, + InvalidImageFormat, InvalidImageSize, NotSupportedImage, + NotSupportedLanguage, or InternalServerError. :param detect_orientation: Whether detect the text orientation in the image. With detectOrientation=true the OCR service tries to detect the image orientation and correct it before further processing (e.g. if it's upside-down). :type detect_orientation: bool - :param url: Publicly reachable URL of an image + :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. The default value is 'unk'. Possible values include: @@ -383,23 +535,24 @@ def recognize_printed_text( return deserialized recognize_printed_text.metadata = {'url': '/ocr'} - def describe_image( - self, url, max_candidates=1, language="en", custom_headers=None, raw=False, **operation_config): - """This operation generates a description of an image in human readable - language with complete sentences. The description is based on a - collection of content tags, which are also returned by the operation. - More than one description can be generated for each image. - Descriptions are ordered by their confidence score. All descriptions - are in English. Two input methods are supported -- (1) Uploading an - image or (2) specifying an image URL.A successful response will be - returned in JSON. If the request failed, the response will contain an - error code and a message to help understand what went wrong. - - :param url: Publicly reachable URL of an image + def tag_image( + self, url, language="en", custom_headers=None, raw=False, **operation_config): + """This operation generates a list of words, or tags, that are relevant to + the content of the supplied image. The Computer Vision API can return + tags based on objects, living beings, scenery or actions found in + images. Unlike categories, tags are not organized according to a + hierarchical classification system, but correspond to image content. + Tags may contain hints to avoid ambiguity or provide context, for + example the tag "cello" may be accompanied by the hint "musical + instrument". All tags are in English. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. + + :param url: Publicly reachable URL of an image. :type url: str - :param max_candidates: Maximum number of candidate descriptions to be - returned. The default is 1. - :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -411,17 +564,17 @@ def describe_image( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: ImageDescription or ClientRawResponse if raw=true + :return: TagResult or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.ImageDescription - or ~msrest.pipeline.ClientRawResponse + ~azure.cognitiveservices.vision.computervision.models.TagResult or + ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ image_url = models.ImageUrl(url=url) # Construct URL - url = self.describe_image.metadata['url'] + url = self.tag_image.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -429,8 +582,6 @@ def describe_image( # Construct parameters query_parameters = {} - if max_candidates is not None: - query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -454,50 +605,59 @@ def describe_image( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImageDescription', response) + deserialized = self._deserialize('TagResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - describe_image.metadata = {'url': '/describe'} - - def tag_image( - self, url, language="en", custom_headers=None, raw=False, **operation_config): - """This operation generates a list of words, or tags, that are relevant to - the content of the supplied image. The Computer Vision API can return - tags based on objects, living beings, scenery or actions found in - images. Unlike categories, tags are not organized according to a - hierarchical classification system, but correspond to image content. - Tags may contain hints to avoid ambiguity or provide context, for - example the tag 'cello' may be accompanied by the hint 'musical - instrument'. All tags are in English. + tag_image.metadata = {'url': '/tag'} - :param url: Publicly reachable URL of an image + def generate_thumbnail( + self, width, height, url, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): + """This operation generates a thumbnail image with the user-specified + width and height. By default, the service analyzes the image, + identifies the region of interest (ROI), and generates smart cropping + coordinates based on the ROI. Smart cropping helps when you specify an + aspect ratio that differs from that of the input image. + A successful response contains the thumbnail image binary. If the + request failed, the response contains an error code and a message to + help determine what went wrong. + Upon failure, the error code and an error message are returned. The + error code could be one of InvalidImageUrl, InvalidImageFormat, + InvalidImageSize, InvalidThumbnailSize, NotSupportedImage, + FailedToProcess, Timeout, or InternalServerError. + + :param width: Width of the thumbnail, in pixels. It must be between 1 + and 1024. Recommended minimum of 50. + :type width: int + :param height: Height of the thumbnail, in pixels. It must be between + 1 and 1024. Recommended minimum of 50. + :type height: int + :param url: Publicly reachable URL of an image. :type url: str - :param language: The desired language for output generation. If this - parameter is not specified, the default value is - "en".Supported languages:en - English, Default. es - - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. - Possible values include: 'en', 'es', 'ja', 'pt', 'zh' - :type language: str + :param smart_cropping: Boolean flag for enabling smart cropping. + :type smart_cropping: bool :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: TagResult or ClientRawResponse if raw=true - :rtype: - ~azure.cognitiveservices.vision.computervision.models.TagResult or - ~msrest.pipeline.ClientRawResponse + :return: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`HttpOperationError` """ image_url = models.ImageUrl(url=url) # Construct URL - url = self.tag_image.metadata['url'] + url = self.generate_thumbnail.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -505,12 +665,14 @@ def tag_image( # Construct parameters query_parameters = {} - if language is not None: - query_parameters['language'] = self._serialize.query("language", language, 'str') + query_parameters['width'] = self._serialize.query("width", width, 'int', maximum=1024, minimum=1) + query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1024, minimum=1) + if smart_cropping is not None: + query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') # Construct headers header_parameters = {} - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -520,52 +682,45 @@ def tag_image( # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagResult', response) + deserialized = self._client.stream_download(response, callback) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - tag_image.metadata = {'url': '/tag'} + generate_thumbnail.metadata = {'url': '/generateThumbnail'} - def analyze_image_by_domain( - self, model, url, language="en", custom_headers=None, raw=False, **operation_config): - """This operation recognizes content within an image by applying a - domain-specific model. The list of domain-specific models that are - supported by the Computer Vision API can be retrieved using the /models - GET request. Currently, the API only provides a single domain-specific - model: celebrities. Two input methods are supported -- (1) Uploading an - image or (2) specifying an image URL. A successful response will be - returned in JSON. If the request failed, the response will contain an - error code and a message to help understand what went wrong. + def get_area_of_interest( + self, url, custom_headers=None, raw=False, **operation_config): + """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. + Upon failure, the error code and an error message are returned. The + error code could be one of InvalidImageUrl, InvalidImageFormat, + InvalidImageSize, NotSupportedImage, FailedToProcess, Timeout, or + InternalServerError. - :param model: The domain-specific content to recognize. - :type model: str - :param url: Publicly reachable URL of an image + :param url: Publicly reachable URL of an image. :type url: str - :param language: The desired language for output generation. If this - parameter is not specified, the default value is - "en".Supported languages:en - English, Default. es - - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. - Possible values include: 'en', 'es', 'ja', 'pt', 'zh' - :type language: 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: DomainModelResults or ClientRawResponse if raw=true + :return: AreaOfInterestResult or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.DomainModelResults + ~azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` @@ -573,17 +728,14 @@ def analyze_image_by_domain( image_url = models.ImageUrl(url=url) # Construct URL - url = self.analyze_image_by_domain.metadata['url'] + url = self.get_area_of_interest.metadata['url'] path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'model': self._serialize.url("model", model, 'str') + '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 = {} - if language is not None: - query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} @@ -605,14 +757,14 @@ def analyze_image_by_domain( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DomainModelResults', response) + deserialized = self._deserialize('AreaOfInterestResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - analyze_image_by_domain.metadata = {'url': '/models/{model}/analyze'} + get_area_of_interest.metadata = {'url': '/areaOfInterest'} def recognize_text( self, url, mode, custom_headers=None, raw=False, **operation_config): @@ -625,7 +777,7 @@ def recognize_text( 'Handwritten', 'Printed' :type mode: str or ~azure.cognitiveservices.vision.computervision.models.TextRecognitionMode - :param url: Publicly reachable URL of an image + :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 @@ -667,39 +819,210 @@ def recognize_text( raise models.ComputerVisionErrorException(self._deserialize, response) if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'Operation-Location': 'str', - }) + 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 analyze_image_in_stream( + self, image, visual_features=None, details=None, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + """This operation extracts a rich set of visual features based on the + image content. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. Within your request, there is an optional + parameter to allow you to choose which features to return. By default, + image categories are returned in the response. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. + + :param image: An image stream. + :type image: Generator + :param visual_features: A string indicating what visual feature types + to return. Multiple values should be comma-separated. Valid visual + feature types include: Categories - categorizes image content + according to a taxonomy defined in documentation. Tags - tags the + image with a detailed list of words related to the image content. + Description - describes the image content with a complete English + sentence. Faces - detects if faces are present. If present, generate + coordinates, gender and age. ImageType - detects if image is clipart + or a line drawing. Color - determines the accent color, dominant + color, and whether an image is black&white. Adult - detects if the + image is pornographic in nature (depicts nudity or a sex act). + Sexually suggestive content is also detected. Objects - detects + various objects within an image, including the approximate location. + The Objects argument is only available in English. + :type visual_features: list[str or + ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] + :param details: A string indicating which domain-specific details to + return. Multiple values should be comma-separated. Valid visual + feature types include: Celebrities - identifies celebrities if + detected in the image, Landmarks - identifies notable landmarks in the + image. + :type details: list[str or + ~azure.cognitiveservices.vision.computervision.models.Details] + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default. es - + Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. + Possible values include: 'en', 'es', 'ja', 'pt', 'zh' + :type language: 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 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: ImageAnalysis or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ComputerVisionErrorException` + """ + # Construct URL + url = self.analyze_image_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 = {} + if visual_features is not None: + query_parameters['visualFeatures'] = self._serialize.query("visual_features", visual_features, '[VisualFeatureTypes]', div=',') + if details is not None: + query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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 [200]: + raise models.ComputerVisionErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ImageAnalysis', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) 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. + return deserialized + analyze_image_in_stream.metadata = {'url': '/analyze'} - :param operation_id: Id of the text operation returned in the response - of the 'Recognize Text' - :type operation_id: str + def get_area_of_interest_in_stream( + self, image, custom_headers=None, raw=False, callback=None, **operation_config): + """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. + Upon failure, the error code and an error message are returned. The + error code could be one of InvalidImageUrl, InvalidImageFormat, + InvalidImageSize, NotSupportedImage, FailedToProcess, Timeout, or + InternalServerError. + + :param image: An image stream. + :type image: Generator :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: TextOperationResult or ClientRawResponse if raw=true + :return: AreaOfInterestResult or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.TextOperationResult + ~azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ # Construct URL - url = self.get_text_operation_result.metadata['url'] + url = self.get_area_of_interest_in_stream.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') + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -709,11 +1032,15 @@ def get_text_operation_result( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' + 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.get(url, query_parameters, header_parameters) + 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 [200]: @@ -722,42 +1049,33 @@ def get_text_operation_result( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TextOperationResult', response) + deserialized = self._deserialize('AreaOfInterestResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get_text_operation_result.metadata = {'url': '/textOperations/{operationId}'} + get_area_of_interest_in_stream.metadata = {'url': '/areaOfInterest'} - def analyze_image_in_stream( - self, image, visual_features=None, details=None, language="en", custom_headers=None, raw=False, callback=None, **operation_config): - """This operation extracts a rich set of visual features based on the - image content. + def describe_image_in_stream( + self, image, max_candidates=1, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + """This operation generates a description of an image in human readable + language with complete sentences. The description is based on a + collection of content tags, which are also returned by the operation. + More than one description can be generated for each image. Descriptions + are ordered by their confidence score. All descriptions are in English. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. :param image: An image stream. :type image: Generator - :param visual_features: A string indicating what visual feature types - to return. Multiple values should be comma-separated. Valid visual - feature types include:Categories - categorizes image content according - to a taxonomy defined in documentation. Tags - tags the image with a - detailed list of words related to the image content. Description - - describes the image content with a complete English sentence. Faces - - detects if faces are present. If present, generate coordinates, gender - and age. ImageType - detects if image is clipart or a line drawing. - Color - determines the accent color, dominant color, and whether an - image is black&white.Adult - detects if the image is pornographic in - nature (depicts nudity or a sex act). Sexually suggestive content is - also detected. - :type visual_features: list[str or - ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] - :param details: A string indicating which domain-specific details to - return. Multiple values should be comma-separated. Valid visual - feature types include:Celebrities - identifies celebrities if detected - in the image. - :type details: list[str or - ~azure.cognitiveservices.vision.computervision.models.Details] + :param max_candidates: Maximum number of candidate descriptions to be + returned. The default is 1. + :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -774,15 +1092,15 @@ def analyze_image_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: ImageAnalysis or ClientRawResponse if raw=true + :return: ImageDescription or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or - ~msrest.pipeline.ClientRawResponse + ~azure.cognitiveservices.vision.computervision.models.ImageDescription + or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ # Construct URL - url = self.analyze_image_in_stream.metadata['url'] + url = self.describe_image_in_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -790,10 +1108,8 @@ def analyze_image_in_stream( # Construct parameters query_parameters = {} - if visual_features is not None: - query_parameters['visualFeatures'] = self._serialize.query("visual_features", visual_features, '[VisualFeatureTypes]', div=',') - if details is not None: - query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') + if max_candidates is not None: + query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -817,36 +1133,26 @@ def analyze_image_in_stream( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImageAnalysis', response) + deserialized = self._deserialize('ImageDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - analyze_image_in_stream.metadata = {'url': '/analyze'} + describe_image_in_stream.metadata = {'url': '/describe'} - def generate_thumbnail_in_stream( - self, width, height, image, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): - """This operation generates a thumbnail image with the user-specified - width and height. By default, the service analyzes the image, - identifies the region of interest (ROI), and generates smart cropping - coordinates based on the ROI. Smart cropping helps when you specify an - aspect ratio that differs from that of the input image. A successful - response contains the thumbnail image binary. If the request failed, - the response contains an error code and a message to help determine - what went wrong. + def detect_objects_in_stream( + self, image, custom_headers=None, raw=False, callback=None, **operation_config): + """Performs object detection on the specified image. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. - :param width: Width of the thumbnail. It must be between 1 and 1024. - Recommended minimum of 50. - :type width: int - :param height: Height of the thumbnail. It must be between 1 and 1024. - Recommended minimum of 50. - :type height: int :param image: An image stream. :type image: Generator - :param smart_cropping: Boolean flag for enabling smart cropping. - :type smart_cropping: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -857,13 +1163,15 @@ def generate_thumbnail_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: object or ClientRawResponse if raw=true - :rtype: Generator or ~msrest.pipeline.ClientRawResponse + :return: DetectResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.DetectResult or + ~msrest.pipeline.ClientRawResponse :raises: - :class:`HttpOperationError` + :class:`ComputerVisionErrorException` """ # Construct URL - url = self.generate_thumbnail_in_stream.metadata['url'] + url = self.detect_objects_in_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -871,14 +1179,10 @@ def generate_thumbnail_in_stream( # Construct parameters query_parameters = {} - query_parameters['width'] = self._serialize.query("width", width, 'int', maximum=1023, minimum=1) - query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1023, minimum=1) - if smart_cropping is not None: - query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') # Construct headers header_parameters = {} - header_parameters['Accept'] = 'application/octet-stream' + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -888,47 +1192,48 @@ def generate_thumbnail_in_stream( # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=True, **operation_config) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise HttpOperationError(self._deserialize, response) + raise models.ComputerVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: - deserialized = self._client.stream_download(response, callback) + deserialized = self._deserialize('DetectResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - generate_thumbnail_in_stream.metadata = {'url': '/generateThumbnail'} - - def recognize_printed_text_in_stream( - self, image, detect_orientation=True, language="unk", custom_headers=None, raw=False, callback=None, **operation_config): - """Optical Character Recognition (OCR) detects printed text in an image - and extracts the recognized characters into a machine-usable character - stream. Upon success, the OCR results will be returned. Upon failure, - the error code together with an error message will be returned. The - error code can be one of InvalidImageUrl, InvalidImageFormat, - InvalidImageSize, NotSupportedImage, NotSupportedLanguage, or - InternalServerError. + detect_objects_in_stream.metadata = {'url': '/detect'} - :param detect_orientation: Whether detect the text orientation in the - image. With detectOrientation=true the OCR service tries to detect the - image orientation and correct it before further processing (e.g. if - it's upside-down). - :type detect_orientation: bool + def generate_thumbnail_in_stream( + self, width, height, image, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): + """This operation generates a thumbnail image with the user-specified + width and height. By default, the service analyzes the image, + identifies the region of interest (ROI), and generates smart cropping + coordinates based on the ROI. Smart cropping helps when you specify an + aspect ratio that differs from that of the input image. + A successful response contains the thumbnail image binary. If the + request failed, the response contains an error code and a message to + help determine what went wrong. + Upon failure, the error code and an error message are returned. The + error code could be one of InvalidImageUrl, InvalidImageFormat, + InvalidImageSize, InvalidThumbnailSize, NotSupportedImage, + FailedToProcess, Timeout, or InternalServerError. + + :param width: Width of the thumbnail, in pixels. It must be between 1 + and 1024. Recommended minimum of 50. + :type width: int + :param height: Height of the thumbnail, in pixels. It must be between + 1 and 1024. Recommended minimum of 50. + :type height: int :param image: An image stream. :type image: Generator - :param language: The BCP-47 language code of the text to be detected - in the image. The default value is 'unk'. Possible values include: - 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', - 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', - 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' - :type language: str or - ~azure.cognitiveservices.vision.computervision.models.OcrLanguages + :param smart_cropping: Boolean flag for enabling smart cropping. + :type smart_cropping: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -939,15 +1244,13 @@ def recognize_printed_text_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: OcrResult or ClientRawResponse if raw=true - :rtype: - ~azure.cognitiveservices.vision.computervision.models.OcrResult or - ~msrest.pipeline.ClientRawResponse + :return: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`HttpOperationError` """ # Construct URL - url = self.recognize_printed_text_in_stream.metadata['url'] + url = self.generate_thumbnail_in_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -955,13 +1258,14 @@ def recognize_printed_text_in_stream( # Construct parameters query_parameters = {} - if language is not None: - query_parameters['language'] = self._serialize.query("language", language, 'OcrLanguages') - query_parameters['detectOrientation'] = self._serialize.query("detect_orientation", detect_orientation, 'bool') + query_parameters['width'] = self._serialize.query("width", width, 'int', maximum=1024, minimum=1) + query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1024, minimum=1) + if smart_cropping is not None: + query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') # Construct headers header_parameters = {} - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -971,40 +1275,40 @@ def recognize_printed_text_in_stream( # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OcrResult', response) + deserialized = self._client.stream_download(response, callback) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - recognize_printed_text_in_stream.metadata = {'url': '/ocr'} + generate_thumbnail_in_stream.metadata = {'url': '/generateThumbnail'} - def describe_image_in_stream( - self, image, max_candidates=1, language="en", custom_headers=None, raw=False, callback=None, **operation_config): - """This operation generates a description of an image in human readable - language with complete sentences. The description is based on a - collection of content tags, which are also returned by the operation. - More than one description can be generated for each image. - Descriptions are ordered by their confidence score. All descriptions - are in English. Two input methods are supported -- (1) Uploading an - image or (2) specifying an image URL.A successful response will be - returned in JSON. If the request failed, the response will contain an - error code and a message to help understand what went wrong. + def analyze_image_by_domain_in_stream( + self, model, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + """This operation recognizes content within an image by applying a + domain-specific model. The list of domain-specific models that are + supported by the Computer Vision API can be retrieved using the /models + GET request. Currently, the API provides following domain-specific + models: celebrities, landmarks. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. + If the request failed, the response will contain an error code and a + message to help understand what went wrong. + :param model: The domain-specific content to recognize. + :type model: str :param image: An image stream. :type image: Generator - :param max_candidates: Maximum number of candidate descriptions to be - returned. The default is 1. - :type max_candidates: int :param language: The desired language for output generation. If this parameter is not specified, the default value is "en".Supported languages:en - English, Default. es - @@ -1021,24 +1325,23 @@ def describe_image_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: ImageDescription or ClientRawResponse if raw=true + :return: DomainModelResults or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.ImageDescription + ~azure.cognitiveservices.vision.computervision.models.DomainModelResults or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ # Construct URL - url = self.describe_image_in_stream.metadata['url'] + url = self.analyze_image_by_domain_in_stream.metadata['url'] path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'model': self._serialize.url("model", model, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} - if max_candidates is not None: - query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') @@ -1062,34 +1365,40 @@ def describe_image_in_stream( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ImageDescription', response) + deserialized = self._deserialize('DomainModelResults', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - describe_image_in_stream.metadata = {'url': '/describe'} + analyze_image_by_domain_in_stream.metadata = {'url': '/models/{model}/analyze'} - def tag_image_in_stream( - self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): - """This operation generates a list of words, or tags, that are relevant to - the content of the supplied image. The Computer Vision API can return - tags based on objects, living beings, scenery or actions found in - images. Unlike categories, tags are not organized according to a - hierarchical classification system, but correspond to image content. - Tags may contain hints to avoid ambiguity or provide context, for - example the tag 'cello' may be accompanied by the hint 'musical - instrument'. All tags are in English. + def recognize_printed_text_in_stream( + self, image, detect_orientation=True, language="unk", custom_headers=None, raw=False, callback=None, **operation_config): + """Optical Character Recognition (OCR) detects text in an image and + extracts the recognized characters into a machine-usable character + stream. + Upon success, the OCR results will be returned. + Upon failure, the error code together with an error message will be + returned. The error code can be one of InvalidImageUrl, + InvalidImageFormat, InvalidImageSize, NotSupportedImage, + NotSupportedLanguage, or InternalServerError. + :param detect_orientation: Whether detect the text orientation in the + image. With detectOrientation=true the OCR service tries to detect the + image orientation and correct it before further processing (e.g. if + it's upside-down). + :type detect_orientation: bool :param image: An image stream. :type image: Generator - :param language: The desired language for output generation. If this - parameter is not specified, the default value is - "en".Supported languages:en - English, Default. es - - Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. - Possible values include: 'en', 'es', 'ja', 'pt', 'zh' - :type language: str + :param language: The BCP-47 language code of the text to be detected + in the image. The default value is 'unk'. Possible values include: + 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', + 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', + 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' + :type language: str or + ~azure.cognitiveservices.vision.computervision.models.OcrLanguages :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1100,15 +1409,15 @@ def tag_image_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: TagResult or ClientRawResponse if raw=true + :return: OcrResult or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.TagResult or + ~azure.cognitiveservices.vision.computervision.models.OcrResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ # Construct URL - url = self.tag_image_in_stream.metadata['url'] + url = self.recognize_printed_text_in_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } @@ -1116,8 +1425,9 @@ def tag_image_in_stream( # Construct parameters query_parameters = {} + query_parameters['detectOrientation'] = self._serialize.query("detect_orientation", detect_orientation, 'bool') if language is not None: - query_parameters['language'] = self._serialize.query("language", language, 'str') + query_parameters['language'] = self._serialize.query("language", language, 'OcrLanguages') # Construct headers header_parameters = {} @@ -1139,28 +1449,31 @@ def tag_image_in_stream( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagResult', response) + deserialized = self._deserialize('OcrResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - tag_image_in_stream.metadata = {'url': '/tag'} + recognize_printed_text_in_stream.metadata = {'url': '/ocr'} - def analyze_image_by_domain_in_stream( - self, model, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): - """This operation recognizes content within an image by applying a - domain-specific model. The list of domain-specific models that are - supported by the Computer Vision API can be retrieved using the /models - GET request. Currently, the API only provides a single domain-specific - model: celebrities. Two input methods are supported -- (1) Uploading an - image or (2) specifying an image URL. A successful response will be - returned in JSON. If the request failed, the response will contain an - error code and a message to help understand what went wrong. + def tag_image_in_stream( + self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + """This operation generates a list of words, or tags, that are relevant to + the content of the supplied image. The Computer Vision API can return + tags based on objects, living beings, scenery or actions found in + images. Unlike categories, tags are not organized according to a + hierarchical classification system, but correspond to image content. + Tags may contain hints to avoid ambiguity or provide context, for + example the tag "cello" may be accompanied by the hint "musical + instrument". All tags are in English. + Two input methods are supported -- (1) Uploading an image or (2) + specifying an image URL. + A successful response will be returned in JSON. If the request failed, + the response will contain an error code and a message to help + understand what went wrong. - :param model: The domain-specific content to recognize. - :type model: str :param image: An image stream. :type image: Generator :param language: The desired language for output generation. If this @@ -1179,18 +1492,17 @@ def analyze_image_by_domain_in_stream( :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: DomainModelResults or ClientRawResponse if raw=true + :return: TagResult or ClientRawResponse if raw=true :rtype: - ~azure.cognitiveservices.vision.computervision.models.DomainModelResults - or ~msrest.pipeline.ClientRawResponse + ~azure.cognitiveservices.vision.computervision.models.TagResult or + ~msrest.pipeline.ClientRawResponse :raises: :class:`ComputerVisionErrorException` """ # Construct URL - url = self.analyze_image_by_domain_in_stream.metadata['url'] + url = self.tag_image_in_stream.metadata['url'] path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'model': self._serialize.url("model", model, 'str') + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -1219,14 +1531,14 @@ def analyze_image_by_domain_in_stream( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DomainModelResults', response) + deserialized = self._deserialize('TagResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - analyze_image_by_domain_in_stream.metadata = {'url': '/models/{model}/analyze'} + tag_image_in_stream.metadata = {'url': '/tag'} def recognize_text_in_stream( self, image, mode, custom_headers=None, raw=False, callback=None, **operation_config): diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index f487c5eecaad..d1e90a15c852 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -22,21 +22,26 @@ from .image_caption_py3 import ImageCaption from .image_description_details_py3 import ImageDescriptionDetails from .face_description_py3 import FaceDescription + from .bounding_rect_py3 import BoundingRect + from .object_hierarchy_py3 import ObjectHierarchy + from .detected_object_py3 import DetectedObject from .image_metadata_py3 import ImageMetadata from .image_analysis_py3 import ImageAnalysis + from .image_description_py3 import ImageDescription + from .detect_result_py3 import DetectResult + from .model_description_py3 import ModelDescription + from .list_models_result_py3 import ListModelsResult + from .domain_model_results_py3 import DomainModelResults from .ocr_word_py3 import OcrWord from .ocr_line_py3 import OcrLine from .ocr_region_py3 import OcrRegion from .ocr_result_py3 import OcrResult - from .model_description_py3 import ModelDescription - from .list_models_result_py3 import ListModelsResult - from .domain_model_results_py3 import DomainModelResults - from .celebrity_results_py3 import CelebrityResults - from .landmark_results_py3 import LandmarkResults - from .image_description_py3 import ImageDescription from .tag_result_py3 import TagResult - from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException + from .area_of_interest_result_py3 import AreaOfInterestResult from .image_url_py3 import ImageUrl + from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException + from .landmark_results_py3 import LandmarkResults + from .celebrity_results_py3 import CelebrityResults from .word_py3 import Word from .line_py3 import Line from .recognition_result_py3 import RecognitionResult @@ -54,31 +59,35 @@ from .image_caption import ImageCaption from .image_description_details import ImageDescriptionDetails from .face_description import FaceDescription + from .bounding_rect import BoundingRect + from .object_hierarchy import ObjectHierarchy + from .detected_object import DetectedObject from .image_metadata import ImageMetadata from .image_analysis import ImageAnalysis + from .image_description import ImageDescription + from .detect_result import DetectResult + from .model_description import ModelDescription + from .list_models_result import ListModelsResult + from .domain_model_results import DomainModelResults from .ocr_word import OcrWord from .ocr_line import OcrLine from .ocr_region import OcrRegion from .ocr_result import OcrResult - from .model_description import ModelDescription - from .list_models_result import ListModelsResult - from .domain_model_results import DomainModelResults - from .celebrity_results import CelebrityResults - from .landmark_results import LandmarkResults - from .image_description import ImageDescription from .tag_result import TagResult - from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException + from .area_of_interest_result import AreaOfInterestResult from .image_url import ImageUrl + from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException + from .landmark_results import LandmarkResults + from .celebrity_results import CelebrityResults from .word import Word from .line import Line from .recognition_result import RecognitionResult from .text_operation_result import TextOperationResult from .computer_vision_client_enums import ( Gender, - ComputerVisionErrorCodes, TextOperationStatusCodes, - VisualFeatureTypes, OcrLanguages, + VisualFeatureTypes, TextRecognitionMode, Details, ) @@ -96,30 +105,34 @@ 'ImageCaption', 'ImageDescriptionDetails', 'FaceDescription', + 'BoundingRect', + 'ObjectHierarchy', + 'DetectedObject', 'ImageMetadata', 'ImageAnalysis', + 'ImageDescription', + 'DetectResult', + 'ModelDescription', + 'ListModelsResult', + 'DomainModelResults', 'OcrWord', 'OcrLine', 'OcrRegion', 'OcrResult', - 'ModelDescription', - 'ListModelsResult', - 'DomainModelResults', - 'CelebrityResults', - 'LandmarkResults', - 'ImageDescription', 'TagResult', - 'ComputerVisionError', 'ComputerVisionErrorException', + 'AreaOfInterestResult', 'ImageUrl', + 'ComputerVisionError', 'ComputerVisionErrorException', + 'LandmarkResults', + 'CelebrityResults', 'Word', 'Line', 'RecognitionResult', 'TextOperationResult', 'Gender', - 'ComputerVisionErrorCodes', 'TextOperationStatusCodes', - 'VisualFeatureTypes', 'OcrLanguages', + 'VisualFeatureTypes', 'TextRecognitionMode', 'Details', ] diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info.py index aa674936a787..bdef886fd2cd 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info.py @@ -19,10 +19,10 @@ class AdultInfo(Model): :param is_adult_content: A value indicating if the image contains adult-oriented content. :type is_adult_content: bool - :param is_racy_content: A value indicating if the image is race. + :param is_racy_content: A value indicating if the image is racy. :type is_racy_content: bool - :param adult_score: Score from 0 to 1 that indicates how much of adult - content is within the image. + :param adult_score: Score from 0 to 1 that indicates how much the content + is considered adult-oriented within the image. :type adult_score: float :param racy_score: Score from 0 to 1 that indicates how suggestive is the image. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info_py3.py index 9c28b8351a4a..0aa79159e970 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/adult_info_py3.py @@ -19,10 +19,10 @@ class AdultInfo(Model): :param is_adult_content: A value indicating if the image contains adult-oriented content. :type is_adult_content: bool - :param is_racy_content: A value indicating if the image is race. + :param is_racy_content: A value indicating if the image is racy. :type is_racy_content: bool - :param adult_score: Score from 0 to 1 that indicates how much of adult - content is within the image. + :param adult_score: Score from 0 to 1 that indicates how much the content + is considered adult-oriented within the image. :type adult_score: float :param racy_score: Score from 0 to 1 that indicates how suggestive is the image. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result.py new file mode 100644 index 000000000000..ea59aa36ef4e --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AreaOfInterestResult(Model): + """Result of AreaOfInterest operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar area_of_interest: A bounding box for an area of interest inside an + image. + :vartype area_of_interest: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _validation = { + 'area_of_interest': {'readonly': True}, + } + + _attribute_map = { + 'area_of_interest': {'key': 'areaOfInterest', 'type': 'BoundingRect'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, **kwargs): + super(AreaOfInterestResult, self).__init__(**kwargs) + self.area_of_interest = None + self.request_id = kwargs.get('request_id', None) + self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result_py3.py new file mode 100644 index 000000000000..41bfb39fac38 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/area_of_interest_result_py3.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AreaOfInterestResult(Model): + """Result of AreaOfInterest operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar area_of_interest: A bounding box for an area of interest inside an + image. + :vartype area_of_interest: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _validation = { + 'area_of_interest': {'readonly': True}, + } + + _attribute_map = { + 'area_of_interest': {'key': 'areaOfInterest', 'type': 'BoundingRect'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, *, request_id: str=None, metadata=None, **kwargs) -> None: + super(AreaOfInterestResult, self).__init__(**kwargs) + self.area_of_interest = None + self.request_id = request_id + self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect.py new file mode 100644 index 000000000000..093d54d18e9d --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BoundingRect(Model): + """A bounding box for an area inside an image. + + :param x: X-coordinate of the top left point of the area, in pixels. + :type x: int + :param y: Y-coordinate of the top left point of the area, in pixels. + :type y: int + :param w: Width measured from the top-left point of the area, in pixels. + :type w: int + :param h: Height measured from the top-left point of the area, in pixels. + :type h: int + """ + + _attribute_map = { + 'x': {'key': 'x', 'type': 'int'}, + 'y': {'key': 'y', 'type': 'int'}, + 'w': {'key': 'w', 'type': 'int'}, + 'h': {'key': 'h', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(BoundingRect, self).__init__(**kwargs) + self.x = kwargs.get('x', None) + self.y = kwargs.get('y', None) + self.w = kwargs.get('w', None) + self.h = kwargs.get('h', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect_py3.py new file mode 100644 index 000000000000..e8a94cf06373 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/bounding_rect_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BoundingRect(Model): + """A bounding box for an area inside an image. + + :param x: X-coordinate of the top left point of the area, in pixels. + :type x: int + :param y: Y-coordinate of the top left point of the area, in pixels. + :type y: int + :param w: Width measured from the top-left point of the area, in pixels. + :type w: int + :param h: Height measured from the top-left point of the area, in pixels. + :type h: int + """ + + _attribute_map = { + 'x': {'key': 'x', 'type': 'int'}, + 'y': {'key': 'y', 'type': 'int'}, + 'w': {'key': 'w', 'type': 'int'}, + 'h': {'key': 'h', 'type': 'int'}, + } + + def __init__(self, *, x: int=None, y: int=None, w: int=None, h: int=None, **kwargs) -> None: + super(BoundingRect, self).__init__(**kwargs) + self.x = x + self.y = y + self.w = w + self.h = h diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category.py index 234f283b0d5c..ea80677bbb5f 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category.py @@ -19,7 +19,7 @@ class Category(Model): :type name: str :param score: Scoring of the category. :type score: float - :param detail: + :param detail: Details of the identified category. :type detail: ~azure.cognitiveservices.vision.computervision.models.CategoryDetail """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category_py3.py index e6c0c0485cc7..f75c495aaa10 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/category_py3.py @@ -19,7 +19,7 @@ class Category(Model): :type name: str :param score: Scoring of the category. :type score: float - :param detail: + :param detail: Details of the identified category. :type detail: ~azure.cognitiveservices.vision.computervision.models.CategoryDetail """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model.py index bb6db51def40..2248dc3ef771 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model.py @@ -17,9 +17,10 @@ class CelebritiesModel(Model): :param name: Name of the celebrity. :type name: str - :param confidence: Level of confidence ranging from 0 to 1. + :param confidence: Confidence level for the celebrity recognition as a + value ranging from 0 to 1. :type confidence: float - :param face_rectangle: + :param face_rectangle: Location of the identified face in the image. :type face_rectangle: ~azure.cognitiveservices.vision.computervision.models.FaceRectangle """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model_py3.py index d50e338a979a..b16be80a3c67 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrities_model_py3.py @@ -17,9 +17,10 @@ class CelebritiesModel(Model): :param name: Name of the celebrity. :type name: str - :param confidence: Level of confidence ranging from 0 to 1. + :param confidence: Confidence level for the celebrity recognition as a + value ranging from 0 to 1. :type confidence: float - :param face_rectangle: + :param face_rectangle: Location of the identified face in the image. :type face_rectangle: ~azure.cognitiveservices.vision.computervision.models.FaceRectangle """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py index 84b07c34ecbc..113a3312ab8c 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py @@ -13,9 +13,9 @@ class CelebrityResults(Model): - """List of celebrities recognized in the image. + """Result of domain-specific classifications for the domain of celebrities. - :param celebrities: + :param celebrities: List of celebrities recognized in the image. :type celebrities: list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] :param request_id: Id of the REST API request. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py index b6edc077463e..35e594d2bb7a 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py @@ -13,9 +13,9 @@ class CelebrityResults(Model): - """List of celebrities recognized in the image. + """Result of domain-specific classifications for the domain of celebrities. - :param celebrities: + :param celebrities: List of celebrities recognized in the image. :type celebrities: list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] :param request_id: Id of the REST API request. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index 3354b6007794..adb0ba54ef76 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -18,23 +18,6 @@ class Gender(str, Enum): female = "Female" -class ComputerVisionErrorCodes(str, Enum): - - invalid_image_url = "InvalidImageUrl" - invalid_image_format = "InvalidImageFormat" - invalid_image_size = "InvalidImageSize" - not_supported_visual_feature = "NotSupportedVisualFeature" - not_supported_image = "NotSupportedImage" - invalid_details = "InvalidDetails" - not_supported_language = "NotSupportedLanguage" - bad_argument = "BadArgument" - failed_to_process = "FailedToProcess" - timeout = "Timeout" - internal_server_error = "InternalServerError" - unspecified = "Unspecified" - storage_exception = "StorageException" - - class TextOperationStatusCodes(str, Enum): not_started = "Not Started" @@ -43,17 +26,6 @@ class TextOperationStatusCodes(str, Enum): succeeded = "Succeeded" -class VisualFeatureTypes(str, Enum): - - image_type = "ImageType" - faces = "Faces" - adult = "Adult" - categories = "Categories" - color = "Color" - tags = "Tags" - description = "Description" - - class OcrLanguages(str, Enum): unk = "unk" @@ -85,6 +57,18 @@ class OcrLanguages(str, Enum): sk = "sk" +class VisualFeatureTypes(str, Enum): + + image_type = "ImageType" + faces = "Faces" + adult = "Adult" + categories = "Categories" + color = "Color" + tags = "Tags" + description = "Description" + objects = "Objects" + + class TextRecognitionMode(str, Enum): handwritten = "Handwritten" diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error.py index 4350fe0694ab..e4e306b6746b 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error.py @@ -14,17 +14,12 @@ class ComputerVisionError(Model): - """ComputerVisionError. + """Details about the API request error. All required parameters must be populated in order to send to Azure. - :param code: Required. The error code. Possible values include: - 'InvalidImageUrl', 'InvalidImageFormat', 'InvalidImageSize', - 'NotSupportedVisualFeature', 'NotSupportedImage', 'InvalidDetails', - 'NotSupportedLanguage', 'BadArgument', 'FailedToProcess', 'Timeout', - 'InternalServerError', 'Unspecified', 'StorageException' - :type code: str or - ~azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorCodes + :param code: Required. The error code. + :type code: object :param message: Required. A message explaining the error reported by the service. :type message: str @@ -38,7 +33,7 @@ class ComputerVisionError(Model): } _attribute_map = { - 'code': {'key': 'code', 'type': 'ComputerVisionErrorCodes'}, + 'code': {'key': 'code', 'type': 'object'}, 'message': {'key': 'message', 'type': 'str'}, 'request_id': {'key': 'requestId', 'type': 'str'}, } diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error_py3.py index b4112ddba880..dc1595d71756 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_error_py3.py @@ -14,17 +14,12 @@ class ComputerVisionError(Model): - """ComputerVisionError. + """Details about the API request error. All required parameters must be populated in order to send to Azure. - :param code: Required. The error code. Possible values include: - 'InvalidImageUrl', 'InvalidImageFormat', 'InvalidImageSize', - 'NotSupportedVisualFeature', 'NotSupportedImage', 'InvalidDetails', - 'NotSupportedLanguage', 'BadArgument', 'FailedToProcess', 'Timeout', - 'InternalServerError', 'Unspecified', 'StorageException' - :type code: str or - ~azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorCodes + :param code: Required. The error code. + :type code: object :param message: Required. A message explaining the error reported by the service. :type message: str @@ -38,7 +33,7 @@ class ComputerVisionError(Model): } _attribute_map = { - 'code': {'key': 'code', 'type': 'ComputerVisionErrorCodes'}, + 'code': {'key': 'code', 'type': 'object'}, 'message': {'key': 'message', 'type': 'str'}, 'request_id': {'key': 'requestId', 'type': 'str'}, } diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result.py new file mode 100644 index 000000000000..89bd2af82277 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectResult(Model): + """Result of a DetectImage call. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar objects: An array of detected objects. + :vartype objects: + list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _validation = { + 'objects': {'readonly': True}, + } + + _attribute_map = { + 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, **kwargs): + super(DetectResult, self).__init__(**kwargs) + self.objects = None + self.request_id = kwargs.get('request_id', None) + self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result_py3.py new file mode 100644 index 000000000000..39b5e712bb16 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detect_result_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectResult(Model): + """Result of a DetectImage call. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar objects: An array of detected objects. + :vartype objects: + list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _validation = { + 'objects': {'readonly': True}, + } + + _attribute_map = { + 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, *, request_id: str=None, metadata=None, **kwargs) -> None: + super(DetectResult, self).__init__(**kwargs) + self.objects = None + self.request_id = request_id + self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object.py new file mode 100644 index 000000000000..605b6d24f67a --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectedObject(Model): + """An object detected in an image. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar rectangle: Approximate location of the detected object. + :vartype rectangle: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + :param object_property: Label for the object. + :type object_property: str + :param confidence: Confidence score of having observed the object in the + image, as a value ranging from 0 to 1. + :type confidence: float + :param parent: The parent object, from a taxonomy perspective. + The parent object is a more generic form of this object. For example, a + 'bulldog' would have a parent of 'dog'. + :type parent: + ~azure.cognitiveservices.vision.computervision.models.ObjectHierarchy + """ + + _validation = { + 'rectangle': {'readonly': True}, + } + + _attribute_map = { + 'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'}, + 'object_property': {'key': 'object', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'parent': {'key': 'parent', 'type': 'ObjectHierarchy'}, + } + + def __init__(self, **kwargs): + super(DetectedObject, self).__init__(**kwargs) + self.rectangle = None + self.object_property = kwargs.get('object_property', None) + self.confidence = kwargs.get('confidence', None) + self.parent = kwargs.get('parent', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object_py3.py new file mode 100644 index 000000000000..256e0f3fb7db --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_object_py3.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectedObject(Model): + """An object detected in an image. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar rectangle: Approximate location of the detected object. + :vartype rectangle: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + :param object_property: Label for the object. + :type object_property: str + :param confidence: Confidence score of having observed the object in the + image, as a value ranging from 0 to 1. + :type confidence: float + :param parent: The parent object, from a taxonomy perspective. + The parent object is a more generic form of this object. For example, a + 'bulldog' would have a parent of 'dog'. + :type parent: + ~azure.cognitiveservices.vision.computervision.models.ObjectHierarchy + """ + + _validation = { + 'rectangle': {'readonly': True}, + } + + _attribute_map = { + 'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'}, + 'object_property': {'key': 'object', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'parent': {'key': 'parent', 'type': 'ObjectHierarchy'}, + } + + def __init__(self, *, object_property: str=None, confidence: float=None, parent=None, **kwargs) -> None: + super(DetectedObject, self).__init__(**kwargs) + self.rectangle = None + self.object_property = object_property + self.confidence = confidence + self.parent = parent diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py index dba10b4cb224..73f5ce109bb9 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py @@ -16,7 +16,7 @@ class DomainModelResults(Model): """Result of image analysis using a specific domain model including additional metadata. - :param result: Model-specific response + :param result: Model-specific response. :type result: object :param request_id: Id of the REST API request. :type request_id: str diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py index 4b718b2258a7..56b5b6c75830 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py @@ -16,7 +16,7 @@ class DomainModelResults(Model): """Result of image analysis using a specific domain model including additional metadata. - :param result: Model-specific response + :param result: Model-specific response. :type result: object :param request_id: Id of the REST API request. :type request_id: str diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description.py index 383a6ecd9576..e6259e315a7a 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description.py @@ -21,7 +21,8 @@ class FaceDescription(Model): 'Male', 'Female' :type gender: str or ~azure.cognitiveservices.vision.computervision.models.Gender - :param face_rectangle: + :param face_rectangle: Rectangle in the image containing the identified + face. :type face_rectangle: ~azure.cognitiveservices.vision.computervision.models.FaceRectangle """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description_py3.py index 63e9e941714c..beea02fb5fdc 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_description_py3.py @@ -21,7 +21,8 @@ class FaceDescription(Model): 'Male', 'Female' :type gender: str or ~azure.cognitiveservices.vision.computervision.models.Gender - :param face_rectangle: + :param face_rectangle: Rectangle in the image containing the identified + face. :type face_rectangle: ~azure.cognitiveservices.vision.computervision.models.FaceRectangle """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle.py index 566ecc6100d4..6c376886c661 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle.py @@ -15,13 +15,15 @@ class FaceRectangle(Model): """An object describing face rectangle. - :param left: X-coordinate of the top left point of the face. + :param left: X-coordinate of the top left point of the face, in pixels. :type left: int - :param top: Y-coordinate of the top left point of the face. + :param top: Y-coordinate of the top left point of the face, in pixels. :type top: int - :param width: Width measured from the top-left point of the face. + :param width: Width measured from the top-left point of the face, in + pixels. :type width: int - :param height: Height measured from the top-left point of the face. + :param height: Height measured from the top-left point of the face, in + pixels. :type height: int """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle_py3.py index aa8b0daaff59..963fb5281139 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/face_rectangle_py3.py @@ -15,13 +15,15 @@ class FaceRectangle(Model): """An object describing face rectangle. - :param left: X-coordinate of the top left point of the face. + :param left: X-coordinate of the top left point of the face, in pixels. :type left: int - :param top: Y-coordinate of the top left point of the face. + :param top: Y-coordinate of the top left point of the face, in pixels. :type top: int - :param width: Width measured from the top-left point of the face. + :param width: Width measured from the top-left point of the face, in + pixels. :type width: int - :param height: Height measured from the top-left point of the face. + :param height: Height measured from the top-left point of the face, in + pixels. :type height: int """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py index 5d7e3c308e43..3a721e498848 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py @@ -18,25 +18,33 @@ class ImageAnalysis(Model): :param categories: An array indicating identified categories. :type categories: list[~azure.cognitiveservices.vision.computervision.models.Category] - :param adult: + :param adult: An object describing whether the image contains + adult-oriented content and/or is racy. :type adult: ~azure.cognitiveservices.vision.computervision.models.AdultInfo - :param color: + :param color: An object providing additional metadata describing color + attributes. :type color: ~azure.cognitiveservices.vision.computervision.models.ColorInfo - :param image_type: + :param image_type: An object providing possible image types and matching + confidence levels. :type image_type: ~azure.cognitiveservices.vision.computervision.models.ImageType :param tags: A list of tags with confidence level. :type tags: list[~azure.cognitiveservices.vision.computervision.models.ImageTag] - :param description: + :param description: A collection of content tags, along with a list of + captions sorted by confidence level, and image metadata. :type description: ~azure.cognitiveservices.vision.computervision.models.ImageDescriptionDetails :param faces: An array of possible faces within the image. :type faces: list[~azure.cognitiveservices.vision.computervision.models.FaceDescription] - :param request_id: Id of the request for tracking purposes. + :param objects: Array of objects describing what was detected in the + image. + :type objects: + list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param request_id: Id of the REST API request. :type request_id: str :param metadata: :type metadata: @@ -51,6 +59,7 @@ class ImageAnalysis(Model): 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'description': {'key': 'description', 'type': 'ImageDescriptionDetails'}, 'faces': {'key': 'faces', 'type': '[FaceDescription]'}, + 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } @@ -64,5 +73,6 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) self.description = kwargs.get('description', None) self.faces = kwargs.get('faces', None) + self.objects = kwargs.get('objects', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py index 45eaf49c71d8..55d392077613 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py @@ -18,25 +18,33 @@ class ImageAnalysis(Model): :param categories: An array indicating identified categories. :type categories: list[~azure.cognitiveservices.vision.computervision.models.Category] - :param adult: + :param adult: An object describing whether the image contains + adult-oriented content and/or is racy. :type adult: ~azure.cognitiveservices.vision.computervision.models.AdultInfo - :param color: + :param color: An object providing additional metadata describing color + attributes. :type color: ~azure.cognitiveservices.vision.computervision.models.ColorInfo - :param image_type: + :param image_type: An object providing possible image types and matching + confidence levels. :type image_type: ~azure.cognitiveservices.vision.computervision.models.ImageType :param tags: A list of tags with confidence level. :type tags: list[~azure.cognitiveservices.vision.computervision.models.ImageTag] - :param description: + :param description: A collection of content tags, along with a list of + captions sorted by confidence level, and image metadata. :type description: ~azure.cognitiveservices.vision.computervision.models.ImageDescriptionDetails :param faces: An array of possible faces within the image. :type faces: list[~azure.cognitiveservices.vision.computervision.models.FaceDescription] - :param request_id: Id of the request for tracking purposes. + :param objects: Array of objects describing what was detected in the + image. + :type objects: + list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param request_id: Id of the REST API request. :type request_id: str :param metadata: :type metadata: @@ -51,11 +59,12 @@ class ImageAnalysis(Model): 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'description': {'key': 'description', 'type': 'ImageDescriptionDetails'}, 'faces': {'key': 'faces', 'type': '[FaceDescription]'}, + 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } - def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, request_id: str=None, metadata=None, **kwargs) -> None: super(ImageAnalysis, self).__init__(**kwargs) self.categories = categories self.adult = adult @@ -64,5 +73,6 @@ def __init__(self, *, categories=None, adult=None, color=None, image_type=None, self.tags = tags self.description = description self.faces = faces + self.objects = objects self.request_id = request_id self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption.py index ec9aa4b93f80..486b2c975fa4 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption.py @@ -15,9 +15,9 @@ class ImageCaption(Model): """An image caption, i.e. a brief description of what the image depicts. - :param text: The text of the caption + :param text: The text of the caption. :type text: str - :param confidence: The level of confidence the service has in the caption + :param confidence: The level of confidence the service has in the caption. :type confidence: float """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption_py3.py index 782f89cda23e..8bfbf80c781a 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_caption_py3.py @@ -15,9 +15,9 @@ class ImageCaption(Model): """An image caption, i.e. a brief description of what the image depicts. - :param text: The text of the caption + :param text: The text of the caption. :type text: str - :param confidence: The level of confidence the service has in the caption + :param confidence: The level of confidence the service has in the caption. :type confidence: float """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata.py index 797206379282..e543fec9266f 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata.py @@ -15,11 +15,11 @@ class ImageMetadata(Model): """Image metadata. - :param width: Image width + :param width: Image width, in pixels. :type width: int - :param height: Image height + :param height: Image height, in pixels. :type height: int - :param format: Image format + :param format: Image format. :type format: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata_py3.py index 2d6bb256c481..46dc21f3447d 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_metadata_py3.py @@ -15,11 +15,11 @@ class ImageMetadata(Model): """Image metadata. - :param width: Image width + :param width: Image width, in pixels. :type width: int - :param height: Image height + :param height: Image height, in pixels. :type height: int - :param format: Image format + :param format: Image format. :type format: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag.py index 8e981d8e6121..34a644edda5d 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag.py @@ -13,13 +13,13 @@ class ImageTag(Model): - """An image caption, i.e. a brief description of what the image depicts. + """An entity observation in the image, along with the confidence score. - :param name: The tag value + :param name: Name of the entity. :type name: str - :param confidence: The level of confidence the service has in the caption + :param confidence: The level of confidence that the entity was observed. :type confidence: float - :param hint: Optional categorization for the tag + :param hint: Optional hint/details for this tag. :type hint: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag_py3.py index 62ba57b775b2..dc03cf493810 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_tag_py3.py @@ -13,13 +13,13 @@ class ImageTag(Model): - """An image caption, i.e. a brief description of what the image depicts. + """An entity observation in the image, along with the confidence score. - :param name: The tag value + :param name: Name of the entity. :type name: str - :param confidence: The level of confidence the service has in the caption + :param confidence: The level of confidence that the entity was observed. :type confidence: float - :param hint: Optional categorization for the tag + :param hint: Optional hint/details for this tag. :type hint: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url.py index 25106793ad9c..ba0ea688201d 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url.py @@ -17,7 +17,7 @@ class ImageUrl(Model): All required parameters must be populated in order to send to Azure. - :param url: Required. Publicly reachable URL of an image + :param url: Required. Publicly reachable URL of an image. :type url: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url_py3.py index 3e00709f804d..5099ce3db915 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_url_py3.py @@ -17,7 +17,7 @@ class ImageUrl(Model): All required parameters must be populated in order to send to Azure. - :param url: Required. Publicly reachable URL of an image + :param url: Required. Publicly reachable URL of an image. :type url: str """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py index 7b0c45eb32c6..05827c3aba04 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py @@ -13,9 +13,9 @@ class LandmarkResults(Model): - """List of landmarks recognized in the image. + """Result of domain-specific classifications for the domain of landmarks. - :param landmarks: + :param landmarks: List of landmarks recognized in the image. :type landmarks: list[~azure.cognitiveservices.vision.computervision.models.LandmarksModel] :param request_id: Id of the REST API request. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py index 93228b4cf03f..b6338a3ad6eb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py @@ -13,9 +13,9 @@ class LandmarkResults(Model): - """List of landmarks recognized in the image. + """Result of domain-specific classifications for the domain of landmarks. - :param landmarks: + :param landmarks: List of landmarks recognized in the image. :type landmarks: list[~azure.cognitiveservices.vision.computervision.models.LandmarksModel] :param request_id: Id of the REST API request. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model.py index 74ff012df89a..c588af0fa856 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model.py @@ -17,7 +17,8 @@ class LandmarksModel(Model): :param name: Name of the landmark. :type name: str - :param confidence: Confidence level for the landmark recognition. + :param confidence: Confidence level for the landmark recognition as a + value ranging from 0 to 1. :type confidence: float """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model_py3.py index 9b7ed4502168..6375b75c202d 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmarks_model_py3.py @@ -17,7 +17,8 @@ class LandmarksModel(Model): :param name: Name of the landmark. :type name: str - :param confidence: Confidence level for the landmark recognition. + :param confidence: Confidence level for the landmark recognition as a + value ranging from 0 to 1. :type confidence: float """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description.py index b12081359419..a61de961108b 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description.py @@ -15,9 +15,9 @@ class ModelDescription(Model): """An object describing supported model by name and categories. - :param name: + :param name: The name of the model. :type name: str - :param categories: + :param categories: Categories of the model. :type categories: list[str] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description_py3.py index e5fc81d86ff8..e9937408c506 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/model_description_py3.py @@ -15,9 +15,9 @@ class ModelDescription(Model): """An object describing supported model by name and categories. - :param name: + :param name: The name of the model. :type name: str - :param categories: + :param categories: Categories of the model. :type categories: list[str] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy.py new file mode 100644 index 000000000000..73c90da079dc --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ObjectHierarchy(Model): + """An object detected inside an image. + + :param object_property: Label for the object. + :type object_property: str + :param confidence: Confidence score of having observed the object in the + image, as a value ranging from 0 to 1. + :type confidence: float + :param parent: The parent object, from a taxonomy perspective. + The parent object is a more generic form of this object. For example, a + 'bulldog' would have a parent of 'dog'. + :type parent: + ~azure.cognitiveservices.vision.computervision.models.ObjectHierarchy + """ + + _attribute_map = { + 'object_property': {'key': 'object', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'parent': {'key': 'parent', 'type': 'ObjectHierarchy'}, + } + + def __init__(self, **kwargs): + super(ObjectHierarchy, self).__init__(**kwargs) + self.object_property = kwargs.get('object_property', None) + self.confidence = kwargs.get('confidence', None) + self.parent = kwargs.get('parent', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy_py3.py new file mode 100644 index 000000000000..03ee6bbb62d7 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/object_hierarchy_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ObjectHierarchy(Model): + """An object detected inside an image. + + :param object_property: Label for the object. + :type object_property: str + :param confidence: Confidence score of having observed the object in the + image, as a value ranging from 0 to 1. + :type confidence: float + :param parent: The parent object, from a taxonomy perspective. + The parent object is a more generic form of this object. For example, a + 'bulldog' would have a parent of 'dog'. + :type parent: + ~azure.cognitiveservices.vision.computervision.models.ObjectHierarchy + """ + + _attribute_map = { + 'object_property': {'key': 'object', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'parent': {'key': 'parent', 'type': 'ObjectHierarchy'}, + } + + def __init__(self, *, object_property: str=None, confidence: float=None, parent=None, **kwargs) -> None: + super(ObjectHierarchy, self).__init__(**kwargs) + self.object_property = object_property + self.confidence = confidence + self.parent = parent diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region.py index ddbeda6431ed..81565e50057c 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region.py @@ -23,7 +23,7 @@ class OcrRegion(Model): according to the detected text angle (see textAngle property), with the origin at the top-left corner, and the y-axis pointing down. :type bounding_box: str - :param lines: + :param lines: An array of recognized lines of text. :type lines: list[~azure.cognitiveservices.vision.computervision.models.OcrLine] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region_py3.py index 6ae209a84e5c..0ec93652b575 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_region_py3.py @@ -23,7 +23,7 @@ class OcrRegion(Model): according to the detected text angle (see textAngle property), with the origin at the top-left corner, and the y-axis pointing down. :type bounding_box: str - :param lines: + :param lines: An array of recognized lines of text. :type lines: list[~azure.cognitiveservices.vision.computervision.models.OcrLine] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py index 854514692604..f83c25d0fa9e 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py @@ -29,8 +29,8 @@ class OcrResult(Model): recognized correctly. :type text_angle: float :param orientation: Orientation of the text recognized in the image. The - value (up,down,left, or right) refers to the direction that the top of the - recognized text is facing, after the image has been rotated around its + value (up, down, left, or right) refers to the direction that the top of + the recognized text is facing, after the image has been rotated around its center according to the detected text angle (see textAngle property). :type orientation: str :param regions: An array of objects, where each object represents a region diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py index 6d654eac5891..b9e541acd3e1 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py @@ -29,8 +29,8 @@ class OcrResult(Model): recognized correctly. :type text_angle: float :param orientation: Orientation of the text recognized in the image. The - value (up,down,left, or right) refers to the direction that the top of the - recognized text is facing, after the image has been rotated around its + value (up, down, left, or right) refers to the direction that the top of + the recognized text is facing, after the image has been rotated around its center according to the detected text angle (see textAngle property). :type orientation: str :param regions: An array of objects, where each object represents a region From 7c7cb75b27f42af3885fb4f6bbd8290d349a0508 Mon Sep 17 00:00:00 2001 From: azuresdkci Date: Tue, 8 Jan 2019 21:44:40 +0000 Subject: [PATCH 06/14] Packaging update of azure-cognitiveservices-vision-computervision --- azure-cognitiveservices-vision-computervision/MANIFEST.in | 1 + azure-cognitiveservices-vision-computervision/setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/azure-cognitiveservices-vision-computervision/MANIFEST.in b/azure-cognitiveservices-vision-computervision/MANIFEST.in index 590056497beb..e437a6594c1b 100644 --- a/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -2,3 +2,4 @@ include *.rst include azure/__init__.py include azure/cognitiveservices/__init__.py include azure/cognitiveservices/vision/__init__.py + diff --git a/azure-cognitiveservices-vision-computervision/setup.py b/azure-cognitiveservices-vision-computervision/setup.py index 500702758cf2..32cce8b8ac31 100644 --- a/azure-cognitiveservices-vision-computervision/setup.py +++ b/azure-cognitiveservices-vision-computervision/setup.py @@ -79,6 +79,7 @@ ]), install_requires=[ 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], extras_require={ From 13a2e3f79b42f713225f68b4f6f1faf4bfe6c550 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 8 Jan 2019 16:50:15 -0800 Subject: [PATCH 07/14] Generated from 66af0936fc20f7164f70de9d36271b12fbc2a5c7 (#2985) Remove basePath from Computer Vision 2.0 swagger. --- .../vision/computervision/computer_vision_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index a411c2f3c4fa..ffcfb39a5deb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -36,7 +36,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.0' + base_url = '{Endpoint}' super(ComputerVisionClientConfiguration, self).__init__(base_url) From 856a565ccc51ce7364438f6f1c76290ab6a3f16e Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Tue, 15 Jan 2019 15:20:06 -0800 Subject: [PATCH 08/14] Update version.py --- .../azure/cognitiveservices/vision/computervision/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py index 63f83465c874..3e682bbd5fb1 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0" +VERSION = "0.3.0" From db91fd293a4300dd2adaf57b32dbcff399cafa3b Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Tue, 15 Jan 2019 15:20:26 -0800 Subject: [PATCH 09/14] Update sdk_packaging.toml --- azure-cognitiveservices-vision-computervision/sdk_packaging.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-cognitiveservices-vision-computervision/sdk_packaging.toml b/azure-cognitiveservices-vision-computervision/sdk_packaging.toml index 069c9df58b06..164ed3e891e0 100644 --- a/azure-cognitiveservices-vision-computervision/sdk_packaging.toml +++ b/azure-cognitiveservices-vision-computervision/sdk_packaging.toml @@ -4,3 +4,4 @@ package_pprint_name = "Cognitive Services Computer Vision" package_doc_id = "cognitive-services" is_stable = false is_arm = false +need_msrestazure = false From 234f04b03ee56477d5b77c5ef5bf3173b21570fa Mon Sep 17 00:00:00 2001 From: azuresdkci Date: Wed, 16 Jan 2019 00:32:28 +0000 Subject: [PATCH 10/14] Packaging update of azure-cognitiveservices-vision-computervision --- azure-cognitiveservices-vision-computervision/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-cognitiveservices-vision-computervision/setup.py b/azure-cognitiveservices-vision-computervision/setup.py index 32cce8b8ac31..500702758cf2 100644 --- a/azure-cognitiveservices-vision-computervision/setup.py +++ b/azure-cognitiveservices-vision-computervision/setup.py @@ -79,7 +79,6 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], extras_require={ From 798f589de69df66106e3ab10dc4fe759b76fb587 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 11 Feb 2019 11:42:54 -0800 Subject: [PATCH 11/14] [AutoPR cognitiveservices/data-plane/ComputerVision] Analyze brands (#4294) * Generated from 0ac968f914274f0f98612a60ac4f8998a60ff1af Analyze brands * Packaging update of azure-cognitiveservices-vision-computervision --- .../README.rst | 19 -------- .../computervision/computer_vision_client.py | 10 ++-- .../vision/computervision/models/__init__.py | 3 ++ .../models/computer_vision_client_enums.py | 1 + .../computervision/models/detected_brand.py | 47 +++++++++++++++++++ .../models/detected_brand_py3.py | 47 +++++++++++++++++++ .../computervision/models/image_analysis.py | 5 ++ .../models/image_analysis_py3.py | 7 ++- .../vision/computervision/version.py | 2 +- 9 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand_py3.py diff --git a/azure-cognitiveservices-vision-computervision/README.rst b/azure-cognitiveservices-vision-computervision/README.rst index eee101b4fb52..ecabe2887eb2 100644 --- a/azure-cognitiveservices-vision-computervision/README.rst +++ b/azure-cognitiveservices-vision-computervision/README.rst @@ -8,25 +8,6 @@ This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. For a more complete set of Azure libraries, see the `azure `__ bundle package. -Compatibility -============= - -**IMPORTANT**: If you have an earlier version of the azure package -(version < 1.0), you should uninstall it before installing this package. - -You can check the version using pip: - -.. code:: shell - - pip freeze - -If you see azure==0.11.0 (or any version below 1.0), uninstall it first: - -.. code:: shell - - pip uninstall azure - - Usage ===== diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index ffcfb39a5deb..2a0ac5f895e0 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -36,7 +36,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}' + base_url = '{Endpoint}/vision/v2.0' super(ComputerVisionClientConfiguration, self).__init__(base_url) @@ -98,7 +98,9 @@ def analyze_image( image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. Objects - detects various objects within an image, including the approximate location. - The Objects argument is only available in English. + The Objects argument is only available in English. Brands - detects + various brands within an image, including the approximate location. + The Brands argument is only available in English. :type visual_features: list[str or ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] :param details: A string indicating which domain-specific details to @@ -910,7 +912,9 @@ def analyze_image_in_stream( image is pornographic in nature (depicts nudity or a sex act). Sexually suggestive content is also detected. Objects - detects various objects within an image, including the approximate location. - The Objects argument is only available in English. + The Objects argument is only available in English. Brands - detects + various brands within an image, including the approximate location. + The Brands argument is only available in English. :type visual_features: list[str or ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] :param details: A string indicating which domain-specific details to diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index d1e90a15c852..fa9bab8f5703 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -25,6 +25,7 @@ from .bounding_rect_py3 import BoundingRect from .object_hierarchy_py3 import ObjectHierarchy from .detected_object_py3 import DetectedObject + from .detected_brand_py3 import DetectedBrand from .image_metadata_py3 import ImageMetadata from .image_analysis_py3 import ImageAnalysis from .image_description_py3 import ImageDescription @@ -62,6 +63,7 @@ from .bounding_rect import BoundingRect from .object_hierarchy import ObjectHierarchy from .detected_object import DetectedObject + from .detected_brand import DetectedBrand from .image_metadata import ImageMetadata from .image_analysis import ImageAnalysis from .image_description import ImageDescription @@ -108,6 +110,7 @@ 'BoundingRect', 'ObjectHierarchy', 'DetectedObject', + 'DetectedBrand', 'ImageMetadata', 'ImageAnalysis', 'ImageDescription', diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index adb0ba54ef76..f72e74e483d6 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -67,6 +67,7 @@ class VisualFeatureTypes(str, Enum): tags = "Tags" description = "Description" objects = "Objects" + brands = "Brands" class TextRecognitionMode(str, Enum): diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand.py new file mode 100644 index 000000000000..d4e8163045be --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectedBrand(Model): + """A brand detected in an image. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Label for the brand. + :vartype name: str + :ivar confidence: Confidence score of having observed the brand in the + image, as a value ranging from 0 to 1. + :vartype confidence: float + :ivar rectangle: Approximate location of the detected brand. + :vartype rectangle: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + """ + + _validation = { + 'name': {'readonly': True}, + 'confidence': {'readonly': True}, + 'rectangle': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'}, + } + + def __init__(self, **kwargs): + super(DetectedBrand, self).__init__(**kwargs) + self.name = None + self.confidence = None + self.rectangle = None diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand_py3.py new file mode 100644 index 000000000000..6124c936d438 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/detected_brand_py3.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectedBrand(Model): + """A brand detected in an image. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Label for the brand. + :vartype name: str + :ivar confidence: Confidence score of having observed the brand in the + image, as a value ranging from 0 to 1. + :vartype confidence: float + :ivar rectangle: Approximate location of the detected brand. + :vartype rectangle: + ~azure.cognitiveservices.vision.computervision.models.BoundingRect + """ + + _validation = { + 'name': {'readonly': True}, + 'confidence': {'readonly': True}, + 'rectangle': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'}, + } + + def __init__(self, **kwargs) -> None: + super(DetectedBrand, self).__init__(**kwargs) + self.name = None + self.confidence = None + self.rectangle = None diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py index 3a721e498848..bbaf1591579e 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis.py @@ -44,6 +44,9 @@ class ImageAnalysis(Model): image. :type objects: list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param brands: Array of brands detected in the image. + :type brands: + list[~azure.cognitiveservices.vision.computervision.models.DetectedBrand] :param request_id: Id of the REST API request. :type request_id: str :param metadata: @@ -60,6 +63,7 @@ class ImageAnalysis(Model): 'description': {'key': 'description', 'type': 'ImageDescriptionDetails'}, 'faces': {'key': 'faces', 'type': '[FaceDescription]'}, 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, + 'brands': {'key': 'brands', 'type': '[DetectedBrand]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } @@ -74,5 +78,6 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) self.faces = kwargs.get('faces', None) self.objects = kwargs.get('objects', None) + self.brands = kwargs.get('brands', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py index 55d392077613..fa56a3362a03 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/image_analysis_py3.py @@ -44,6 +44,9 @@ class ImageAnalysis(Model): image. :type objects: list[~azure.cognitiveservices.vision.computervision.models.DetectedObject] + :param brands: Array of brands detected in the image. + :type brands: + list[~azure.cognitiveservices.vision.computervision.models.DetectedBrand] :param request_id: Id of the REST API request. :type request_id: str :param metadata: @@ -60,11 +63,12 @@ class ImageAnalysis(Model): 'description': {'key': 'description', 'type': 'ImageDescriptionDetails'}, 'faces': {'key': 'faces', 'type': '[FaceDescription]'}, 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, + 'brands': {'key': 'brands', 'type': '[DetectedBrand]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } - def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, brands=None, request_id: str=None, metadata=None, **kwargs) -> None: super(ImageAnalysis, self).__init__(**kwargs) self.categories = categories self.adult = adult @@ -74,5 +78,6 @@ def __init__(self, *, categories=None, adult=None, color=None, image_type=None, self.description = description self.faces = faces self.objects = objects + self.brands = brands self.request_id = request_id self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py index 3e682bbd5fb1..63f83465c874 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.3.0" +VERSION = "2.0" From b3bbca7de0697290b3ba19c853bfcce1d19ac103 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 5 Mar 2019 14:54:51 -0800 Subject: [PATCH 12/14] [AutoPR cognitiveservices/data-plane/ComputerVision] [Computer Vision] Add read to CV OCR API. (#4473) * Generated from cbcb8cc3c280c9725bca0f4e0feb4bfc57b677ec Add read to OCR API. * Packaging update of azure-cognitiveservices-vision-computervision * Generated from 51742b3e212c2e900ed5c24f7c351fa7f896d25e Mark asyncBatchAnalyze as long running operation. * Generated from b047a112a2c4cddaa54605d5de6a7bc3faab38c7 Update page property. --- .../MANIFEST.in | 1 + .../computervision/computer_vision_client.py | 185 ++++++++++++++++++ .../vision/computervision/models/__init__.py | 13 +- .../models/computer_vision_client_enums.py | 12 ++ .../vision/computervision/models/line.py | 8 +- .../vision/computervision/models/line_py3.py | 8 +- .../models/read_operation_result.py | 36 ++++ .../models/read_operation_result_py3.py | 36 ++++ .../models/recognition_result.py | 29 --- .../models/recognition_result_py3.py | 29 --- .../models/text_operation_result.py | 8 +- .../models/text_operation_result_py3.py | 8 +- .../models/text_recognition_result.py | 59 ++++++ .../models/text_recognition_result_py3.py | 59 ++++++ .../vision/computervision/models/word.py | 19 +- .../vision/computervision/models/word_py3.py | 21 +- 16 files changed, 447 insertions(+), 84 deletions(-) create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result_py3.py delete mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result.py delete mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result_py3.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result.py create mode 100644 azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result_py3.py diff --git a/azure-cognitiveservices-vision-computervision/MANIFEST.in b/azure-cognitiveservices-vision-computervision/MANIFEST.in index e437a6594c1b..c5ed7ee87be7 100644 --- a/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -1,3 +1,4 @@ +recursive-include tests *.py *.yaml include *.rst include azure/__init__.py include azure/cognitiveservices/__init__.py diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index 2a0ac5f895e0..c7fa2bd7fdaa 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -885,6 +885,125 @@ def get_text_operation_result( return deserialized get_text_operation_result.metadata = {'url': '/textOperations/{operationId}'} + def batch_read_file( + self, url, mode, 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 "Read Operation Result" operation to access OCR results.​. + + :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.batch_read_file.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 + batch_read_file.metadata = {'url': '/read/core/asyncBatchAnalyze'} + + def get_read_operation_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. + + :param operation_id: Id of read operation returned in the response of + the "Batch Read File" 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 + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReadOperationResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.computervision.models.ReadOperationResult + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ComputerVisionErrorException` + """ + # Construct URL + url = self.get_read_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('ReadOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_read_operation_result.metadata = {'url': '/read/operations/{operationId}'} + def analyze_image_in_stream( self, image, visual_features=None, details=None, language="en", custom_headers=None, raw=False, callback=None, **operation_config): """This operation extracts a rich set of visual features based on the @@ -1606,3 +1725,69 @@ def recognize_text_in_stream( }) return client_raw_response recognize_text_in_stream.metadata = {'url': '/recognizeText'} + + def batch_read_file_in_stream( + self, image, mode, 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.​. + + :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.batch_read_file_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 + batch_read_file_in_stream.metadata = {'url': '/read/core/asyncBatchAnalyze'} diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index fa9bab8f5703..149f84d6dc9e 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -45,8 +45,9 @@ from .celebrity_results_py3 import CelebrityResults from .word_py3 import Word from .line_py3 import Line - from .recognition_result_py3 import RecognitionResult + from .text_recognition_result_py3 import TextRecognitionResult from .text_operation_result_py3 import TextOperationResult + from .read_operation_result_py3 import ReadOperationResult except (SyntaxError, ImportError): from .face_rectangle import FaceRectangle from .celebrities_model import CelebritiesModel @@ -83,11 +84,14 @@ from .celebrity_results import CelebrityResults from .word import Word from .line import Line - from .recognition_result import RecognitionResult + from .text_recognition_result import TextRecognitionResult from .text_operation_result import TextOperationResult + from .read_operation_result import ReadOperationResult from .computer_vision_client_enums import ( Gender, TextOperationStatusCodes, + TextRecognitionResultDimensionUnit, + TextRecognitionResultConfidenceClass, OcrLanguages, VisualFeatureTypes, TextRecognitionMode, @@ -130,10 +134,13 @@ 'CelebrityResults', 'Word', 'Line', - 'RecognitionResult', + 'TextRecognitionResult', 'TextOperationResult', + 'ReadOperationResult', 'Gender', 'TextOperationStatusCodes', + 'TextRecognitionResultDimensionUnit', + 'TextRecognitionResultConfidenceClass', 'OcrLanguages', 'VisualFeatureTypes', 'TextRecognitionMode', diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index f72e74e483d6..1340a35f39e5 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -26,6 +26,18 @@ class TextOperationStatusCodes(str, Enum): succeeded = "Succeeded" +class TextRecognitionResultDimensionUnit(str, Enum): + + pixel = "pixel" + inch = "inch" + + +class TextRecognitionResultConfidenceClass(str, Enum): + + high = "High" + low = "Low" + + class OcrLanguages(str, Enum): unk = "unk" diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line.py index 3c6df06a5c12..9ab67b7f9ee3 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line.py @@ -13,13 +13,13 @@ class Line(Model): - """Line. + """Json object representing a recognized text line. - :param bounding_box: + :param bounding_box: Bounding box of a recognized line. :type bounding_box: list[int] - :param text: + :param text: The text content of the line. :type text: str - :param words: + :param words: List of words in the text line. :type words: list[~azure.cognitiveservices.vision.computervision.models.Word] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line_py3.py index eaa7b16fa07c..432ab12fb9a4 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/line_py3.py @@ -13,13 +13,13 @@ class Line(Model): - """Line. + """Json object representing a recognized text line. - :param bounding_box: + :param bounding_box: Bounding box of a recognized line. :type bounding_box: list[int] - :param text: + :param text: The text content of the line. :type text: str - :param words: + :param words: List of words in the text line. :type words: list[~azure.cognitiveservices.vision.computervision.models.Word] """ diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result.py new file mode 100644 index 000000000000..872986d0683b --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReadOperationResult(Model): + """OCR result of the read operation. + + :param status: Status of the read operation. Possible values include: 'Not + Started', 'Running', 'Failed', 'Succeeded' + :type status: str or + ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes + :param recognition_results: A array of text recognition result of the read + operation. + :type recognition_results: + list[~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult] + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, + 'recognition_results': {'key': 'recognitionResults', 'type': '[TextRecognitionResult]'}, + } + + def __init__(self, **kwargs): + super(ReadOperationResult, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.recognition_results = kwargs.get('recognition_results', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result_py3.py new file mode 100644 index 000000000000..bea44f9a29f2 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/read_operation_result_py3.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReadOperationResult(Model): + """OCR result of the read operation. + + :param status: Status of the read operation. Possible values include: 'Not + Started', 'Running', 'Failed', 'Succeeded' + :type status: str or + ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes + :param recognition_results: A array of text recognition result of the read + operation. + :type recognition_results: + list[~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult] + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, + 'recognition_results': {'key': 'recognitionResults', 'type': '[TextRecognitionResult]'}, + } + + def __init__(self, *, status=None, recognition_results=None, **kwargs) -> None: + super(ReadOperationResult, self).__init__(**kwargs) + self.status = status + self.recognition_results = recognition_results diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result.py deleted file mode 100644 index 628dde0dae9a..000000000000 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RecognitionResult(Model): - """RecognitionResult. - - :param lines: - :type lines: - list[~azure.cognitiveservices.vision.computervision.models.Line] - """ - - _attribute_map = { - 'lines': {'key': 'lines', 'type': '[Line]'}, - } - - def __init__(self, **kwargs): - super(RecognitionResult, self).__init__(**kwargs) - self.lines = kwargs.get('lines', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result_py3.py deleted file mode 100644 index c809646eac7b..000000000000 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/recognition_result_py3.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RecognitionResult(Model): - """RecognitionResult. - - :param lines: - :type lines: - list[~azure.cognitiveservices.vision.computervision.models.Line] - """ - - _attribute_map = { - 'lines': {'key': 'lines', 'type': '[Line]'}, - } - - def __init__(self, *, lines=None, **kwargs) -> None: - super(RecognitionResult, self).__init__(**kwargs) - self.lines = lines diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result.py index 301f07ab62dd..4571398b7523 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result.py @@ -13,20 +13,20 @@ class TextOperationResult(Model): - """TextOperationResult. + """Result of recognition text operation. :param status: Status of the text operation. Possible values include: 'Not Started', 'Running', 'Failed', 'Succeeded' :type status: str or ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_result: + :param recognition_result: Text recognition result of the text operation. :type recognition_result: - ~azure.cognitiveservices.vision.computervision.models.RecognitionResult + ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult """ _attribute_map = { 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_result': {'key': 'recognitionResult', 'type': 'RecognitionResult'}, + 'recognition_result': {'key': 'recognitionResult', 'type': 'TextRecognitionResult'}, } def __init__(self, **kwargs): diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result_py3.py index cd6adfb3d754..4bc756b809e4 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_operation_result_py3.py @@ -13,20 +13,20 @@ class TextOperationResult(Model): - """TextOperationResult. + """Result of recognition text operation. :param status: Status of the text operation. Possible values include: 'Not Started', 'Running', 'Failed', 'Succeeded' :type status: str or ~azure.cognitiveservices.vision.computervision.models.TextOperationStatusCodes - :param recognition_result: + :param recognition_result: Text recognition result of the text operation. :type recognition_result: - ~azure.cognitiveservices.vision.computervision.models.RecognitionResult + ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResult """ _attribute_map = { 'status': {'key': 'status', 'type': 'TextOperationStatusCodes'}, - 'recognition_result': {'key': 'recognitionResult', 'type': 'RecognitionResult'}, + 'recognition_result': {'key': 'recognitionResult', 'type': 'TextRecognitionResult'}, } def __init__(self, *, status=None, recognition_result=None, **kwargs) -> None: diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result.py new file mode 100644 index 000000000000..cb4340ef244c --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TextRecognitionResult(Model): + """Json object representing a recognized text region. + + All required parameters must be populated in order to send to Azure. + + :param page: 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. + :type width: float + :param height: 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' + :type unit: str or + ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultDimensionUnit + :param lines: Required. A list of recognized text lines. + :type lines: + list[~azure.cognitiveservices.vision.computervision.models.Line] + """ + + _validation = { + 'lines': {'required': True}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'clockwise_orientation': {'key': 'clockwiseOrientation', '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, **kwargs): + super(TextRecognitionResult, self).__init__(**kwargs) + self.page = kwargs.get('page', None) + self.clockwise_orientation = kwargs.get('clockwise_orientation', 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) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result_py3.py new file mode 100644 index 000000000000..eaa4c9b10ade --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/text_recognition_result_py3.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TextRecognitionResult(Model): + """Json object representing a recognized text region. + + All required parameters must be populated in order to send to Azure. + + :param page: 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. + :type width: float + :param height: 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' + :type unit: str or + ~azure.cognitiveservices.vision.computervision.models.TextRecognitionResultDimensionUnit + :param lines: Required. A list of recognized text lines. + :type lines: + list[~azure.cognitiveservices.vision.computervision.models.Line] + """ + + _validation = { + 'lines': {'required': True}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'clockwise_orientation': {'key': 'clockwiseOrientation', '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) + self.page = page + self.clockwise_orientation = clockwise_orientation + self.width = width + self.height = height + self.unit = unit + self.lines = lines diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word.py index af6015b9ed0d..dea2bcfc81a2 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word.py @@ -13,20 +13,33 @@ class Word(Model): - """Word. + """Json object representing a recognized word. - :param bounding_box: + All required parameters must be populated in order to send to Azure. + + :param bounding_box: Required. Bounding box of a recognized word. :type bounding_box: list[int] - :param text: + :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 """ + _validation = { + 'bounding_box': {'required': True}, + 'text': {'required': True}, + } + _attribute_map = { 'bounding_box': {'key': 'boundingBox', 'type': '[int]'}, 'text': {'key': 'text', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'TextRecognitionResultConfidenceClass'}, } def __init__(self, **kwargs): super(Word, self).__init__(**kwargs) self.bounding_box = kwargs.get('bounding_box', None) self.text = kwargs.get('text', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word_py3.py index ea3dc0845b3e..ff7e4f8c6380 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/word_py3.py @@ -13,20 +13,33 @@ class Word(Model): - """Word. + """Json object representing a recognized word. - :param bounding_box: + All required parameters must be populated in order to send to Azure. + + :param bounding_box: Required. Bounding box of a recognized word. :type bounding_box: list[int] - :param text: + :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 """ + _validation = { + 'bounding_box': {'required': True}, + 'text': {'required': True}, + } + _attribute_map = { 'bounding_box': {'key': 'boundingBox', 'type': '[int]'}, 'text': {'key': 'text', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'TextRecognitionResultConfidenceClass'}, } - def __init__(self, *, bounding_box=None, text: str=None, **kwargs) -> None: + def __init__(self, *, bounding_box, text: str, confidence=None, **kwargs) -> None: super(Word, self).__init__(**kwargs) self.bounding_box = bounding_box self.text = text + self.confidence = confidence From e24ea2b7e2fe416cee6e925b3f31751ab9864c98 Mon Sep 17 00:00:00 2001 From: azuresdkci Date: Tue, 5 Mar 2019 22:58:02 +0000 Subject: [PATCH 13/14] Packaging update of azure-cognitiveservices-vision-computervision --- azure-cognitiveservices-vision-computervision/README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-cognitiveservices-vision-computervision/README.rst b/azure-cognitiveservices-vision-computervision/README.rst index ecabe2887eb2..d151b7958689 100644 --- a/azure-cognitiveservices-vision-computervision/README.rst +++ b/azure-cognitiveservices-vision-computervision/README.rst @@ -22,3 +22,6 @@ Provide Feedback If you encounter any bugs or have suggestions, please file an issue in the `Issues `__ section of the project. + + +.. image:: https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-vision-computervision%2FREADME.png From 8e2b980068109dccf5bcc3d48c37db356b04503a Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Fri, 8 Mar 2019 16:50:51 -0800 Subject: [PATCH 14/14] 0.3.0 --- .../HISTORY.rst | 17 ++++++++++++++++- .../vision/computervision/version.py | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/azure-cognitiveservices-vision-computervision/HISTORY.rst b/azure-cognitiveservices-vision-computervision/HISTORY.rst index 399421196d94..3d74522f3401 100644 --- a/azure-cognitiveservices-vision-computervision/HISTORY.rst +++ b/azure-cognitiveservices-vision-computervision/HISTORY.rst @@ -3,6 +3,21 @@ Release History =============== +0.3.0 (2019-03-11) +++++++++++++++++++ + +**Features** + +- Model ImageAnalysis has a new parameter brands +- Model ImageAnalysis has a new parameter objects +- Model Word has a new parameter confidence + +**Breaking changes** + +- Client ComputerVisionAPI has been renamed ComputerVisionClient +- Parameter text of model Word is now required +- Parameter bounding_box of model Word is now required + 0.2.0 (2018-06-22) ++++++++++++++++++ @@ -38,7 +53,7 @@ This version uses a next-generation code generator that *might* introduce breaki - Return type changes from `msrestazure.azure_operation.AzureOperationPoller` to `msrest.polling.LROPoller`. External API is the same. - Return type is now **always** a `msrest.polling.LROPoller`, regardless of the optional parameters used. - - The behavior has changed when using `raw=True`. Instead of returning the initial call result as `ClientRawResponse`, + - The behavior has changed when using `raw=True`. Instead of returning the initial call result as `ClientRawResponse`, without polling, now this returns an LROPoller. After polling, the final resource will be returned as a `ClientRawResponse`. - New `polling` parameter. The default behavior is `Polling=True` which will poll using ARM algorithm. When `Polling=False`, the response of the initial call will be returned without polling. diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py index 63f83465c874..3e682bbd5fb1 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0" +VERSION = "0.3.0"