Skip to content

Commit 198eedc

Browse files
Merge pull request #190290 from PatrickFarley/comvis-updates
[cog svcs] Comvis updates
2 parents f12abcb + 30d10de commit 198eedc

19 files changed

+365
-1380
lines changed

articles/cognitive-services/Computer-vision/Vision-API-How-to-Topics/HowToCallVisionAPI.md

Lines changed: 159 additions & 19 deletions
Large diffs are not rendered by default.

articles/cognitive-services/Computer-vision/includes/curl-quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.custom: seodec18
1717
Use the Optical character recognition REST API to read printed and handwritten text.
1818

1919
> [!NOTE]
20-
> This quickstart uses cURL commands to call the REST API. You can also call the REST API using a programming language. See the GitHub samples for examples in [C#](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/dotnet/ComputerVision/REST), [Python](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/python/ComputerVision/REST), [Java](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/java/ComputerVision/REST), [JavaScript](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/javascript/ComputerVision/REST), and [Go](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/go/ComputerVision/REST).
20+
> This quickstart uses cURL commands to call the REST API. You can also call the REST API using a programming language. See the GitHub samples for examples in [C#](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/dotnet/ComputerVision/REST), [Python](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/python/ComputerVision/REST), [Java](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/java/ComputerVision/REST), and [JavaScript](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/javascript/ComputerVision/REST).
2121
2222
## Prerequisites
2323

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "Quickstart: Image Analysis REST API"
3+
titleSuffix: "Azure Cognitive Services"
4+
services: cognitive-services
5+
author: PatrickFarley
6+
manager: nitinme
7+
8+
ms.service: cognitive-services
9+
ms.subservice: computer-vision
10+
ms.topic: include
11+
ms.date: 03/23/2022
12+
ms.author: pafarley
13+
---
14+
15+
Go to the Azure portal. If the Computer Vision resource you created in the **Prerequisites** section deployed successfully, click the **Go to Resource** button under **Next Steps**. You can find your key and endpoint in the resource's **key and endpoint** page, under **resource management**.

articles/cognitive-services/Computer-vision/includes/image-analysis-curl-quickstart.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ Use the Image Analysis REST API to:
2020
* Generate a thumbnail with smart cropping
2121

2222
> [!NOTE]
23-
> This quickstart uses cURL commands to call the REST API. You can also call the REST API using a programming language. See the GitHub samples for examples in [C#](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/dotnet/ComputerVision/REST), [Python](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/python/ComputerVision/REST), [Java](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/java/ComputerVision/REST), [JavaScript](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/javascript/ComputerVision/REST), and [Go](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/go/ComputerVision/REST).
23+
> This quickstart uses cURL commands to call the REST API. You can also call the REST API using a programming language. See the GitHub samples for examples in [C#](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/dotnet/ComputerVision/REST), [Python](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/python/ComputerVision/REST), [Java](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/java/ComputerVision/REST), and [JavaScript](https://github.com/Azure-Samples/cognitive-services-quickstart-code/tree/master/javascript/ComputerVision/REST).
2424
2525
## Prerequisites
2626

2727
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
28-
* Once you have your Azure subscription, <a href="https://portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision" title="Create a Computer Vision resource" target="_blank">create a Computer Vision resource </a> in the Azure portal to get your key and endpoint. After it deploys, click **Go to resource**.
29-
* You will need the key and endpoint from the resource you create to connect your application to the Computer Vision service. You'll paste your key and endpoint into the code below later in the quickstart.
28+
* Once you have your Azure subscription, <a href="https://portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision" title="Create a Computer Vision resource" target="_blank">create a Computer Vision resource </a> in the Azure portal to get your key and endpoint. After it deploys, select **Go to resource**.
29+
* You'll need the key and endpoint from the resource you create to connect your application to the Computer Vision service. You'll paste your key and endpoint into the code below later in the quickstart.
3030
* You can use the free pricing tier (`F0`) to try the service, and upgrade later to a paid tier for production.
3131
* [cURL](https://curl.haxx.se/) installed
3232

3333
## Analyze an image
3434

35-
To analyze an image for a variety of visual features, do the following steps:
35+
To analyze an image for various visual features, do the following steps:
3636

3737
1. Copy the following command into a text editor.
3838
1. Make the following changes in the command where needed:
@@ -131,12 +131,12 @@ To create and run the sample, do the following steps:
131131

132132
### Examine the response
133133

134-
A successful response writes the thumbnail image to the file specified in `<thumbnailFile>`. If the request fails, the response contains an error code and a message to help determine what went wrong. If the request seems to succeed but the created thumbnail is not a valid image file, it might be that your subscription key is not valid.
134+
A successful response writes the thumbnail image to the file specified in `<thumbnailFile>`. If the request fails, the response contains an error code and a message to help determine what went wrong. If the request seems to succeed but the created thumbnail isn't a valid image file, it's possible that your subscription key is not valid.
135135

136136

137137
## Next steps
138138

139-
In this quickstart, you learned how to install make basic image analysis calls using the REST API. Next, learn more about the Analyze API features.
139+
In this quickstart, you learned how to make basic image analysis calls using the REST API. Next, learn more about the Analyze API features.
140140

141141
> [!div class="nextstepaction"]
142142
>[Call the Analyze API](../Vision-API-How-to-Topics/HowToCallVisionAPI.md)

articles/cognitive-services/Computer-vision/includes/quickstarts-sdk/csharp-sdk.md

Lines changed: 25 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: computer-vision
99
ms.topic: include
10-
ms.date: 12/15/2020
10+
ms.date: 03/02/2022
1111
ms.author: pafarley
1212
ms.custom: devx-track-csharp
1313
---
1414

1515
<a name="HOLTop"></a>
1616

17-
Use the OCR client library to read printed and handwritten text from an image.
17+
Use the OCR client library to read printed and handwritten text from a remote image. The OCR service can read visible text in an image and convert it to a character stream. For more information on text recognition, see the [Optical character recognition (OCR)](../../overview-ocr.md) overview. The code in this section uses the latest [Computer Vision SDK release for Read 3.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.ComputerVision/).
18+
19+
> [!TIP]
20+
> You can also extract text from a local image. See the [ComputerVisionClient](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.computervisionclient) methods, such as **ReadInStreamAsync**. Or, see the sample code on [GitHub](https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/dotnet/ComputerVision/ComputerVisionQuickstart.cs#162) for scenarios involving local images.
1821
1922
[Reference documentation](/dotnet/api/overview/azure/cognitiveservices/client/computervision) | [Library source code](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/cognitiveservices/Vision.ComputerVision) | [Package (NuGet)](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.ComputerVision/) | [Samples](https://azure.microsoft.com/resources/samples/?service=cognitive-services&term=vision&sort=0)
2023

@@ -72,101 +75,44 @@ dotnet add package Microsoft.Azure.CognitiveServices.Vision.ComputerVision --ver
7275

7376
---
7477

75-
> [!TIP]
76-
> Want to view the whole quickstart code file at once? You can find it on [GitHub](https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/dotnet/ComputerVision/ComputerVisionQuickstart.cs), which contains the code examples in this quickstart.
77-
78-
From the project directory, open the *Program.cs* file in your preferred editor or IDE.
79-
8078
### Find the subscription key and endpoint
8179

82-
Go to the Azure portal. If the Computer Vision resource you created in the **Prerequisites** section deployed successfully, click the **Go to Resource** button under **Next Steps**. You can find your subscription key and endpoint in the resource's **key and endpoint** page, under **resource management**.
83-
84-
In the application's **Program** class, create variables for your Computer Vision subscription key and endpoint. Paste your subscription key and endpoint into the following code where indicated. Your Computer Vision endpoint has the form `https://<your_computer_vision_resource_name>.cognitiveservices.azure.com/`.
85-
86-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_using_and_vars)]
87-
88-
> [!IMPORTANT]
89-
> Remember to remove the subscription key from your code when you're done, and never post it publicly. For production, consider using a secure way of storing and accessing your credentials. For example, [Azure key vault](../../../../key-vault/general/overview.md).
90-
91-
In the application's `Main` method, add calls for the methods used in this quickstart. You will create these later.
92-
93-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_main_calls)]
94-
95-
## Object model
96-
97-
The following classes and interfaces handle some of the major features of the OCR .NET SDK.
98-
99-
|Name|Description|
100-
|---|---|
101-
| [ComputerVisionClient](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.computervisionclient) | This class is needed for all Computer Vision functionality. You instantiate it with your subscription information, and you use it to do most image operations.|
102-
|[ComputerVisionClientExtensions](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.computervisionclientextensions)| This class contains additional methods for the **ComputerVisionClient**.|
103-
104-
## Code examples
105-
106-
These code snippets show you how to do the following tasks with the OCR client library for .NET:
107-
108-
* [Authenticate the client](#authenticate-the-client)
109-
* [Read printed and handwritten text](#read-printed-and-handwritten-text)
110-
111-
## Authenticate the client
80+
[!INCLUDE [find key and endpoint](../find-key.md)]
11281

113-
In a new method in the **Program** class, instantiate a client with your endpoint and subscription key. Create a **[ApiKeyServiceClientCredentials](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.apikeyserviceclientcredentials)** object with your subscription key, and use it with your endpoint to create a **[ComputerVisionClient](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.computervisionclient)** object.
114-
115-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_auth)]
11682

11783
## Read printed and handwritten text
11884

119-
The OCR service can read visible text in an image and convert it to a character stream. For more information on text recognition, see the [Optical character recognition (OCR)](../../overview-ocr.md) overview. The code in this section uses the [Computer Vision SDK release](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.ComputerVision/) and defines a method, `ReadFileUrl`, which uses the client object to detect and extract text in the image.
120-
121-
> [!TIP]
122-
> You can also extract text from a local image. See the [ComputerVisionClient](/dotnet/api/microsoft.azure.cognitiveservices.vision.computervision.computervisionclient) methods, such as **ReadInStreamAsync**. Or, see the sample code on [GitHub](https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/dotnet/ComputerVision/ComputerVisionQuickstart.cs#162) for scenarios involving local images.
123-
124-
### Set up test image
125-
126-
In your **Program** class, save a reference to the URL of the image you want to extract text from. This snippet includes sample images for both printed and handwritten text.
127-
128-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_readtext_url)]
129-
130-
### Call the Read API
131-
132-
Define the new method for reading text. Add the code below, which calls the **ReadAsync** method for the given image. This returns an operation ID and starts an asynchronous process to read the content of the image.
85+
1. From the project directory, open the *Program.cs* file in your preferred editor or IDE. Replace the contents of *Program.cs* with the following code.
13386

134-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_readfileurl_1)]
87+
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart-single.cs?name=snippet_single)]
13588

136-
As an optional step, see [How to specify the model version](../../Vision-API-How-to-Topics/call-read-api.md#determine-how-to-process-the-data-optional) for the model version parameter values you can use. The most recent model includes any enhancements to the previous GA and preview models. For example, to use the model-version=`2022-01-30-preview` parameter, edit the ReadAsync call as shown:
89+
1. Paste your subscription key and endpoint into the code where indicated. Your Computer Vision endpoint has the form `https://<your_computer_vision_resource_name>.cognitiveservices.azure.com/`.
13790

138-
```csharp
139-
// Read text from URL with a specific model version
140-
var textHeaders = await client.ReadAsync(urlFile,null,null,"2022-01-30-preview");
141-
```
142-
143-
### Get Read results
91+
> [!IMPORTANT]
92+
> Remember to remove the subscription key from your code when you're done, and never post it publicly. For production, consider using a secure way of storing and accessing your credentials. For example, [Azure key vault](../../../../key-vault/general/overview.md).
14493
145-
Next, get the operation ID returned from the **ReadAsync** call, and use it to query the service for operation results. The following code checks the operation until the results are returned. It then prints the extracted text data to the console.
94+
1. As an optional step, see [How to specify the model version](../../Vision-API-How-to-Topics/call-read-api.md#determine-how-to-process-the-data-optional) for the model version parameter values you can use. The most recent model includes any enhancements to the previous GA and preview models. For example, to use the model-version=`2022-01-30-preview` parameter, edit the ReadAsync call as shown:
14695

147-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_readfileurl_2)]
96+
```csharp
97+
// Read text from URL with a specific model version
98+
var textHeaders = await client.ReadAsync(urlFile,null,null,"2022-01-30-preview");
99+
```
148100

149-
### Display Read results
101+
1. Run the application.
150102

151-
Add the following code to parse and display the retrieved text data, and finish the method definition.
103+
#### [Visual Studio IDE](#tab/visual-studio)
152104

153-
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/ComputerVision/ComputerVisionQuickstart.cs?name=snippet_readfileurl_3)]
105+
Click the **Debug** button at the top of the IDE window.
154106

155-
## Run the application
107+
#### [CLI](#tab/cli)
156108

157-
#### [Visual Studio IDE](#tab/visual-studio)
109+
Use the `dotnet run` command in your project directory.
158110

159-
Run the application by clicking the **Debug** button at the top of the IDE window.
160-
161-
#### [CLI](#tab/cli)
111+
```dotnet
112+
dotnet run
113+
```
162114

163-
Run the application from your application directory with the `dotnet run` command.
164-
165-
```dotnet
166-
dotnet run
167-
```
168-
169-
---
115+
---
170116

171117
## Clean up resources
172118

0 commit comments

Comments
 (0)