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