Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ReleasePR azure-cognitiveservices-vision-computervision] [Cognitive Service Computer Vision] Create CV v3.0 API version swagger #11464

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release History

## 0.6.0 (2020-05-18)

**Features**

- Model Line has a new parameter language
- Added operation ComputerVisionClientOperationsMixin.read
- Added operation ComputerVisionClientOperationsMixin.get_read_result
- Added operation ComputerVisionClientOperationsMixin.read_in_stream

**Breaking changes**

- Parameter words of model Line is now required
- Parameter bounding_box of model Line is now required
- Parameter text of model Line is now required
- Parameter confidence of model Word is now required
- Removed operation ComputerVisionClientOperationsMixin.get_text_operation_result
- Removed operation ComputerVisionClientOperationsMixin.get_read_operation_result
- Removed operation ComputerVisionClientOperationsMixin.recognize_text_in_stream
- Removed operation ComputerVisionClientOperationsMixin.recognize_text
- Removed operation ComputerVisionClientOperationsMixin.batch_read_file
- Removed operation ComputerVisionClientOperationsMixin.batch_read_file_in_stream
- Model ReadOperationResult has a new signature

## 0.5.0 (2019-10-01)

**Features**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,31 @@ for caption in analysis.captions:

### Get text from image

You can get any handwritten or printed text from an image. This requires two calls to the SDK: [`recognize_text`][ref_computervisionclient_recognize_text] and [`get_text_operation_result`][ref_computervisionclient_get_text_operation_result]. The call to recognize_text is asynchronous. In the results of the get_text_operation_result call, you need to check if the first call completed with [`TextOperationStatusCodes`][ref_computervision_model_textoperationstatuscodes] before extracting the text data. The results include the text as well as the bounding box coordinates for the text.
You can get any handwritten or printed text from an image. This requires two calls to the SDK: [`read`][ref_computervisionclient_read] and [`get_read_result`][ref_computervisionclient_get_read_result]. The call to read is asynchronous. In the results of the get_read_result call, you need to check if the first call completed with [`OperationStatusCodes`][ref_computervision_model_operationstatuscodes] before extracting the text data. The results include the text as well as the bounding box coordinates for the text.

```Python
# import models
from azure.cognitiveservices.vision.computervision.models import TextRecognitionMode
from azure.cognitiveservices.vision.computervision.models import TextOperationStatusCodes
from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes

url = "https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/raw/master/samples/vision/images/make_things_happen.jpg"
mode = TextRecognitionMode.printed
raw = True
custom_headers = None
numberOfCharsInOperationId = 36

# SDK call
rawHttpResponse = client.recognize_text(url, mode, custom_headers, raw)
rawHttpResponse = client.read(url, language="en", raw=True)

# Get ID from returned headers
operationLocation = rawHttpResponse.headers["Operation-Location"]
idLocation = len(operationLocation) - numberOfCharsInOperationId
operationId = operationLocation[idLocation:]

# SDK call
result = client.get_text_operation_result(operationId)
result = client.get_read_result(operationId)

# Get data
if result.status == TextOperationStatusCodes.succeeded:
if result.status == OperationStatusCodes.succeeded:

for line in result.recognition_result.lines:
for line in result.analyze_result.read_results[0].lines:
print(line.text)
print(line.bounding_box)
```
Expand Down Expand Up @@ -275,7 +272,7 @@ While working with the [ComputerVisionClient][ref_computervisionclient] client,

Several Computer Vision Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Computer Vision:

* [recognize_text][recognize-text]
* [See sample repo][recognize-text]

### Additional documentation

Expand Down Expand Up @@ -317,14 +314,14 @@ For more extensive documentation on the Computer Vision service, see the [Azure
[ref_computervisionclient_list_models]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#list-models-custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_analyze_image_by_domain]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-by-domain-model--url--language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_describe_image]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#describe-image-url--max-candidates--1---language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_recognize_text]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#recognize-text-url--mode--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_get_text_operation_result]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#get-text-operation-result-operation-id--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_read]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#read-url--mode--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_get_read_result]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#get-read-result-operation-id--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_generate_thumbnail]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#generate-thumbnail-width--height--url--smart-cropping-false--custom-headers-none--raw-false--callback-none----operation-config-


[ref_computervision_model_visualfeatures]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.visualfeaturetypes?view=azure-python

[ref_computervision_model_textoperationstatuscodes]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.textoperationstatuscodes?view=azure-python
[ref_computervision_model_operationstatuscodes]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.models.operationstatuscodes?view=azure-python

[computervision_request_units]:https://azure.microsoft.com/pricing/details/cognitive-services/computer-vision/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
super(ComputerVisionClient, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2.1'
self.api_version = '3.0'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
raise ValueError("Parameter 'endpoint' must not be None.")
if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
base_url = '{Endpoint}/vision/v2.1'
base_url = '{Endpoint}/vision/v3.0'

super(ComputerVisionClientConfiguration, self).__init__(base_url)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

try:
from ._models_py3 import AdultInfo
from ._models_py3 import AnalyzeResults
from ._models_py3 import AreaOfInterestResult
from ._models_py3 import BoundingRect
from ._models_py3 import Category
Expand Down Expand Up @@ -44,12 +45,12 @@
from ._models_py3 import OcrResult
from ._models_py3 import OcrWord
from ._models_py3 import ReadOperationResult
from ._models_py3 import ReadResult
from ._models_py3 import TagResult
from ._models_py3 import TextOperationResult
from ._models_py3 import TextRecognitionResult
from ._models_py3 import Word
except (SyntaxError, ImportError):
from ._models import AdultInfo
from ._models import AnalyzeResults
from ._models import AreaOfInterestResult
from ._models import BoundingRect
from ._models import Category
Expand Down Expand Up @@ -83,24 +84,23 @@
from ._models import OcrResult
from ._models import OcrWord
from ._models import ReadOperationResult
from ._models import ReadResult
from ._models import TagResult
from ._models import TextOperationResult
from ._models import TextRecognitionResult
from ._models import Word
from ._computer_vision_client_enums import (
DescriptionExclude,
Details,
Gender,
OcrDetectionLanguage,
OcrLanguages,
TextOperationStatusCodes,
TextRecognitionMode,
TextRecognitionResultConfidenceClass,
OperationStatusCodes,
TextRecognitionResultDimensionUnit,
VisualFeatureTypes,
)

__all__ = [
'AdultInfo',
'AnalyzeResults',
'AreaOfInterestResult',
'BoundingRect',
'Category',
Expand Down Expand Up @@ -134,17 +134,15 @@
'OcrResult',
'OcrWord',
'ReadOperationResult',
'ReadResult',
'TagResult',
'TextOperationResult',
'TextRecognitionResult',
'Word',
'Gender',
'TextOperationStatusCodes',
'OperationStatusCodes',
'TextRecognitionResultDimensionUnit',
'TextRecognitionResultConfidenceClass',
'DescriptionExclude',
'OcrLanguages',
'VisualFeatureTypes',
'TextRecognitionMode',
'OcrDetectionLanguage',
'Details',
]
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class Gender(str, Enum):
female = "Female"


class TextOperationStatusCodes(str, Enum):
class OperationStatusCodes(str, Enum):

not_started = "NotStarted"
running = "Running"
failed = "Failed"
succeeded = "Succeeded"
not_started = "notStarted"
running = "running"
failed = "failed"
succeeded = "succeeded"


class TextRecognitionResultDimensionUnit(str, Enum):
Expand All @@ -32,12 +32,6 @@ class TextRecognitionResultDimensionUnit(str, Enum):
inch = "inch"


class TextRecognitionResultConfidenceClass(str, Enum):

high = "High"
low = "Low"


class DescriptionExclude(str, Enum):

celebrities = "Celebrities"
Expand Down Expand Up @@ -88,10 +82,15 @@ class VisualFeatureTypes(str, Enum):
brands = "Brands"


class TextRecognitionMode(str, Enum):
class OcrDetectionLanguage(str, Enum):

handwritten = "Handwritten"
printed = "Printed"
en = "en"
es = "es"
fr = "fr"
de = "de"
it = "it"
nl = "nl"
pt = "pt"


class Details(str, Enum):
Expand Down
Loading