Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
691464f
computer vision quickstart
diberry Jan 28, 2019
0dfafdb
save thumbnail to file
diberry Jan 29, 2019
96646f4
edits
diberry Jan 29, 2019
b67018c
edits based on Marsh's feedback
diberry Jan 30, 2019
0acdadd
edits
diberry Jan 30, 2019
bfaa0de
edits
diberry Jan 30, 2019
e98d3cf
edits based on Anna's feedback
diberry Jan 30, 2019
e1817c5
edits based on feedback - some links fixed - tbd - read of links
diberry Feb 1, 2019
551da34
links should be fixed
diberry Feb 1, 2019
b8d56a3
remove unused links
diberry Feb 1, 2019
7d75a0d
fix spelling
diberry Feb 1, 2019
5396c0d
edits based on Marsh's feedback
diberry Feb 5, 2019
57a524a
added pip package reference into install section
diberry Feb 5, 2019
2e27f60
Larent and Johan's changes
diberry Feb 6, 2019
d9ae272
edit package link name
diberry Feb 6, 2019
28deacf
fixing reference for readme.md
diberry Feb 6, 2019
f84e0cb
changes based on azure-template/setup.py
diberry Feb 6, 2019
9c0d301
adding long description back
diberry Feb 6, 2019
1e15577
Merge branch 'master' into 0124-python-computervision
scbedd Feb 12, 2019
d1e8d3b
Merge branch 'master' into 0124-python-computervision
scbedd Feb 13, 2019
abb9acc
remove .RST file
diberry Feb 14, 2019
a4e1062
convert HISTORY to Markdown
mmacy Feb 28, 2019
eb72203
Merge pull request #1 from mmacy/4255-diberry
diberry Feb 28, 2019
7c3269d
remove *.rst file - fix merge conflict
diberry Mar 6, 2019
2936abb
autoupdate to auto_update
diberry Mar 6, 2019
f2927d3
Merge branch '0124-python-computervision' of https://github.com/diber…
diberry Mar 6, 2019
f03e0ee
merging master into cognitiveservices vision
scbedd Mar 11, 2020
370ed8a
returning mgmt-batch to what it should be
scbedd Mar 11, 2020
bffba83
Merge remote-tracking branch 'origin/master' into 0124-python-compute…
lmazuel Mar 11, 2020
72115e2
First pass fixing just reading the Readme
lmazuel Mar 11, 2020
2f37c50
Fix recognize_text sample
lmazuel Mar 11, 2020
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
Prev Previous commit
Next Next commit
First pass fixing just reading the Readme
  • Loading branch information
lmazuel committed Mar 11, 2020
commit 72115e2287f8feef30acfff8da1d0b3af44acd4f
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pip install azure-cognitiveservices-vision-computervision

Once you create your Computer Vision resource, you need its **region**, and one of its **account keys** to instantiate the client object.

Use these values when you create the instance of the [ComputerVisionAPI][ref_computervisionclient] client object.
Use these values when you create the instance of the [ComputerVisionClient][ref_computervisionclient] client object.

### Get credentials

Expand All @@ -85,10 +85,10 @@ export ACCOUNT_KEY=$(az cognitiveservices account keys list \

### Create client

Once you've populated the `ACCOUNT_REGION` and `ACCOUNT_KEY` environment variables, you can create the [ComputerVisionAPI][ref_computervisionclient] client object.
Once you've populated the `ACCOUNT_REGION` and `ACCOUNT_KEY` environment variables, you can create the [ComputerVisionClient][ref_computervisionclient] client object.

```Python
from azure.cognitiveservices.vision.computervision import ComputerVisionAPI
from azure.cognitiveservices.vision.computervision import ComputerVisionClient
from azure.cognitiveservices.vision.computervision.models import VisualFeatureTypes
from msrest.authentication import CognitiveServicesCredentials

Expand All @@ -97,12 +97,15 @@ region = os.environ['ACCOUNT_REGION']
key = os.environ['ACCOUNT_KEY']

credentials = CognitiveServicesCredentials(key)
client = ComputerVisionAPI(region, credentials)
client = ComputerVisionClient(
endpoint="https://" + region + ".api.cognitive.microsoft.com/",
credentials=credentials
)
```

## Usage

Once you've initialized a [ComputerVisionAPI][ref_computervisionclient] client object, you can:
Once you've initialized a [ComputerVisionClient][ref_computervisionclient] client object, you can:

* Analyze an image: You can analyze an image for certain features such as faces, colors, tags.
* Generate thumbnails: Create a custom JPEG image to use as a thumbnail of the original image.
Expand Down Expand Up @@ -238,7 +241,7 @@ image.save('thumbnail.jpg')

### General

When you interact with the [ComputerVisionAPI][ref_computervisionclient] client object using the Python SDK, the [`ComputerVisionErrorException`][ref_computervision_computervisionerrorexception] class is used to return errors. Errors returned by the service correspond to the same HTTP status codes returned for REST API requests.
When you interact with the [ComputerVisionClient][ref_computervisionclient] client object using the Python SDK, the [`ComputerVisionErrorException`][ref_computervision_computervisionerrorexception] class is used to return errors. Errors returned by the service correspond to the same HTTP status codes returned for REST API requests.

For example, if you try to analyze an image with an invalid key, a `401` error is returned. In the following snippet, the [error][ref_httpfailure] is handled gracefully by catching the exception and displaying additional information about the error.

Expand All @@ -264,7 +267,7 @@ except HTTPFailure as e:

### Handle transient errors with retries

While working with the [ComputerVisionAPI][ref_computervisionclient] client, you might encounter transient failures caused by [rate limits][computervision_request_units] enforced by the service, or other transient problems like network outages. For information about handling these types of failures, see [Retry pattern][azure_pattern_retry] in the Cloud Design Patterns guide, and the related [Circuit Breaker pattern][azure_pattern_circuit_breaker].
While working with the [ComputerVisionClient][ref_computervisionclient] client, you might encounter transient failures caused by [rate limits][computervision_request_units] enforced by the service, or other transient problems like network outages. For information about handling these types of failures, see [Retry pattern][azure_pattern_retry] in the Cloud Design Patterns guide, and the related [Circuit Breaker pattern][azure_pattern_circuit_breaker].

## Next steps

Expand Down Expand Up @@ -293,7 +296,7 @@ For more extensive documentation on the Computer Vision service, see the [Azure
[venv]: https://docs.python.org/3/library/venv.html
[virtualenv]: https://virtualenv.pypa.io

[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/azure-cognitiveservices-vision-computervision
[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision

[pypi_computervision]:https://pypi.org/project/azure-cognitiveservices-vision-computervision/
[pypi_pillow]:https://pypi.org/project/Pillow/
Expand All @@ -307,16 +310,16 @@ For more extensive documentation on the Computer Vision service, see the [Azure

[computervision_docs]: https://docs.microsoft.com/azure/cognitive-services/computer-vision/home

[ref_computervisionclient]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionapi?view=azure-python
[ref_computervisionclient]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python


[ref_computervisionclient_analyze_image]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionapi?view=azure-python#analyze-image-url--visual-features-none--details-none--language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_list_models]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionapi?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.computervisionapi?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.computervisionapi?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.computervisionapi?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.computervisionapi?view=azure-python#get-text-operation-result-operation-id--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_generate_thumbnail]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionapi?view=azure-python#generate-thumbnail-width--height--url--smart-cropping-false--custom-headers-none--raw-false--callback-none----operation-config-
[ref_computervisionclient_analyze_image]: https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-url--visual-features-none--details-none--language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_list_models]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#list-models-custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_analyze_image_by_domain]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#analyze-image-by-domain-model--url--language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_describe_image]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#describe-image-url--max-candidates--1---language--en---custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_recognize_text]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#recognize-text-url--mode--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_get_text_operation_result]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#get-text-operation-result-operation-id--custom-headers-none--raw-false----operation-config-
[ref_computervisionclient_generate_thumbnail]:https://docs.microsoft.com/python/api/azure-cognitiveservices-vision-computervision/azure.cognitiveservices.vision.computervision.computervisionclient?view=azure-python#generate-thumbnail-width--height--url--smart-cropping-false--custom-headers-none--raw-false--callback-none----operation-config-


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