Skip to content

Commit 05587b0

Browse files
authored
Merge pull request #115013 from v-jaswel/patch-8
[DO NOT MERGE UNTIL BUILD] Update CSharp-hand-text.md, java-hand-text.md, javascript-hand-text.md
2 parents dfc8a25 + 6dadab4 commit 05587b0

File tree

3 files changed

+30
-99
lines changed

3 files changed

+30
-99
lines changed

articles/cognitive-services/Computer-vision/QuickStarts/CSharp-hand-text.md

Lines changed: 22 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Quickstart: Computer Vision 2.0 and 2.1 - Extract printed and handwritten text - REST, C#"
2+
title: "Quickstart: Computer Vision 2.1, and 3.0 - Extract printed and handwritten text - REST, C#"
33
titleSuffix: "Azure Cognitive Services"
44
description: In this quickstart, you extract printed and handwritten text from an image using the Computer Vision API with C#.
55
services: cognitive-services
@@ -13,11 +13,11 @@ ms.date: 04/14/2020
1313
ms.author: pafarley
1414
ms.custom: seodec18
1515
---
16-
# Quickstart: Extract printed and handwritten text using the Computer Vision 2.0 and 2.1 REST API and C#
16+
# Quickstart: Extract printed and handwritten text using the Computer Vision 2.1 and 3.0 REST API and C#
1717

1818
In this quickstart, you'll extract printed and/or handwritten text from an image using the Computer Vision REST API. With the [Batch Read](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/2afb498089f74080d7ef85eb) and [Read Operation Result](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/5be108e7498a4f9ed20bf96d) methods, you can detect text in an image and extract recognized characters into a machine-readable character stream. The API will determine which recognition model to use for each line of text, so it supports images with both printed and handwritten text.
1919

20-
Compared to Computer Vision 2.0 and 2.1, the Computer Vision 3.0 Public Preview provides:
20+
Compared to Computer Vision 2.1 and 3.0, the Computer Vision 3.0 Public Preview provides:
2121

2222
* even better accuracy
2323
* a changed output format
@@ -29,7 +29,7 @@ Compared to Computer Vision 2.0 and 2.1, the Computer Vision 3.0 Public Preview
2929
> [!IMPORTANT]
3030
> The [Batch Read](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/2afb498089f74080d7ef85eb) method runs asynchronously. This method does not return any information in the body of a successful response. Instead, the Batch Read method returns a URI in the value of the `Operation-Location` response header field. You can then call this URI, which represents the [Read Operation Result](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/5be108e7498a4f9ed20bf96d) API, to both check the status and return the results of the Batch Read method call.
3131
32-
#### [Version 3 (Public preview)](#tab/version-3)
32+
#### [Version 3](#tab/version-3)
3333

3434
> [!IMPORTANT]
3535
> The [Batch Read](https://westus2.dev.cognitive.microsoft.com/docs/services/5d98695995feb7853f67d6a6/operations/5d986960601faab4bf452005) method runs asynchronously. This method does not return any information in the body of a successful response. Instead, the Batch Read method returns a URI in the value of the `Operation-Location` response header field. You can then call this URI, which represents the [Read Operation Result](https://westus2.dev.cognitive.microsoft.com/docs/services/5d98695995feb7853f67d6a6/operations/5d9869604be85dee480c8750) API, to both check the status and return the results of the Batch Read method call.
@@ -75,29 +75,20 @@ namespace CSHttpClientSample
7575
static string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
7676

7777
static string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
78-
78+
7979
// the Batch Read method endpoint
8080
static string uriBase = endpoint + "vision/v2.1/read/core/asyncBatchAnalyze";
81+
// Add your own local image with text (png or jpg OK)
82+
static string imageFilePath = @"my-image.png";
8183

82-
static async Task Main()
84+
static void Main()
8385
{
84-
// Get the path and filename to process from the user.
85-
Console.WriteLine("Text Recognition:");
86-
Console.Write(
87-
"Enter the path to an image with text you wish to read: ");
88-
string imageFilePath = Console.ReadLine();
8986

90-
if (File.Exists(imageFilePath))
91-
{
92-
// Call the REST API method.
93-
Console.WriteLine("\nWait a moment for the results to appear.\n");
94-
await ReadText(imageFilePath);
95-
}
96-
else
97-
{
98-
Console.WriteLine("\nInvalid file path");
99-
}
100-
Console.WriteLine("\nPress Enter to exit...");
87+
// Call the REST API method.
88+
Console.WriteLine("\nExtracting text...\n");
89+
ReadText(imageFilePath).Wait();
90+
91+
Console.WriteLine("\nPress Enter to exit.");
10192
Console.ReadLine();
10293
}
10394

@@ -252,70 +243,20 @@ namespace CSHttpClientSample
252243
static string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
253244

254245
// the Batch Read method endpoint
255-
static string uriBase = endpoint + "/vision/v3.0-preview/read/analyze";
246+
static string uriBase = endpoint + "/vision/v3.0-preview//read/analyze";
247+
248+
// Add a local image with text here (png or jpg is OK)
249+
static string imageFilePath = @"my-image.png";
250+
// Add a language, either "en" or "es"
251+
static string language = "en";
256252

257-
static void PrintUsage()
258-
{
259-
// Get the path and filename to process from the user.
260-
Console.WriteLine("Cognitive Service Batch Read File Sample");
261-
Console.WriteLine("Usage: ");
262-
Console.WriteLine(" From Azure Cogntivie Service, retrieve your endpoint and subscription key.");
263-
Console.WriteLine(" Set environment variable COMPUTER_VISION_ENDPOINT, such as \"https://westus2.api.cognitive.microsoft.com\"");
264-
Console.WriteLine(" Set environment variable COMPUTER_VISION_SUBSCRIPTION_KEY, such as \"1234567890abcdef1234567890abcdef\"\n");
265-
Console.WriteLine(" Run the program without argument to enter a file name and a language manually.");
266-
Console.WriteLine(" Or run the program with a file name for an image file (bmp/jpg/png/tiff) or a PDF file, plus the language. The language can be \"en\" or \"es\".");
267-
Console.WriteLine(" For example: dotnet Program.dll sample.jpg en");
268-
Console.WriteLine();
269-
}
270253

271254
static void Main(string[] args)
272255
{
273-
PrintUsage();
256+
// Call the REST API method.
257+
Console.WriteLine("\nExtracting text...\n");
258+
ReadText(imageFilePath, language).Wait();
274259

275-
if (string.IsNullOrEmpty(subscriptionKey) || string.IsNullOrEmpty(endpoint))
276-
{
277-
Console.Error.WriteLine("Please set environment variables COMPUTER_VISION_ENDPOINT and COMPUTER_VISION_SUBSCRIPTION_KEY.");
278-
return;
279-
}
280-
281-
string imageFilePath;
282-
string language;
283-
if (args.Length == 0)
284-
{
285-
Console.Write(
286-
"Enter the path to an image (bmp/jpg/png/tiff) or PDF with text you wish to read: ");
287-
imageFilePath = Console.ReadLine();
288-
}
289-
else
290-
{
291-
imageFilePath = args[0];
292-
}
293-
294-
if (args.Length <= 1)
295-
{
296-
Console.Write(
297-
"Enter the language to read: \"en\" or \"es\": ");
298-
language = Console.ReadLine();
299-
}
300-
else
301-
{
302-
language = args[1];
303-
}
304-
305-
Console.WriteLine($"Endpoint: [{endpoint}]");
306-
Console.WriteLine($"Subscription: [{subscriptionKey}]");
307-
Console.WriteLine($"URL: [{uriBase}]");
308-
309-
if (File.Exists(imageFilePath))
310-
{
311-
// Call the REST API method.
312-
Console.WriteLine("\nWait a moment for the results to appear.\n");
313-
ReadText(imageFilePath, language).Wait();
314-
}
315-
else
316-
{
317-
Console.WriteLine("\nInvalid file path");
318-
}
319260
Console.WriteLine("\nPress Enter to exit...");
320261
Console.ReadLine();
321262
}

articles/cognitive-services/Computer-vision/QuickStarts/java-hand-text.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Quickstart: Computer Vision 2.0 and 2.1 - Extract printed and handwritten text - REST, Java"
2+
title: "Quickstart: Computer Vision 2.1 and 3.0 - Extract printed and handwritten text - REST, Java"
33
titleSuffix: "Azure Cognitive Services"
44
description: In this quickstart, you extract printed and handwritten text from an image using the Computer Vision API with Java.
55
services: cognitive-services
@@ -80,14 +80,10 @@ To create and run the sample, do the following steps:
8080

8181
```java
8282
public class Main {
83-
// **********************************************
84-
// *** Update or verify the following values. ***
85-
// **********************************************
86-
8783
// Add your Computer Vision subscription key and endpoint to your environment variables.
8884
// After setting, close and then re-open your command shell or project for the changes to take effect.
89-
String subscriptionKey = System.getenv("COMPUTER_VISION_SUBSCRIPTION_KEY");
90-
String endpoint = ("COMPUTER_VISION_ENDPOINT");
85+
private static String subscriptionKey = System.getenv("COMPUTER_VISION_SUBSCRIPTION_KEY");
86+
private static String endpoint = System.getenv("COMPUTER_VISION_ENDPOINT");
9187

9288
private static final String uriBase = endpoint +
9389
"vision/v2.1/read/core/asyncBatchAnalyze";
@@ -224,20 +220,17 @@ To create and run the sample, do the following steps:
224220
```java
225221

226222
public class Main {
227-
// **********************************************
228-
// *** Update or verify the following values. ***
229-
// **********************************************
230223

231224
// Add your Computer Vision subscription key and endpoint to your environment variables.
232225
// After setting, close and then re-open your command shell or project for the changes to take effect.
233226
private static String subscriptionKey = System.getenv("COMPUTER_VISION_SUBSCRIPTION_KEY");
234227
private static String endpoint = System.getenv("COMPUTER_VISION_ENDPOINT");
235228

236229
// Set the language that you want to recognize
237-
private static String language = "en"; // Accepted values are "en" for English, or "es" for Spanish
230+
// Accepted values are "en" for English, or "es" for Spanish
231+
private static String language = "en";
238232

239-
private static String uriBase = endpoint +
240-
"/vision/v3.0-preview/read/analyze";
233+
private static String uriBase = endpoint + "/vision/v3.0-preview/read/analyze";
241234

242235
private static String imageToAnalyze =
243236
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/" +

articles/cognitive-services/Computer-vision/QuickStarts/javascript-hand-text.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ To create and run the sample, do the following steps:
6868

6969
<script type="text/javascript">
7070
function processImage() {
71-
// **********************************************
72-
// *** Update or verify the following values. ***
73-
// **********************************************
74-
71+
// Fetch your Computer Vision key and endpoint for this sample.
7572
var subscriptionKey = document.getElementById("subscriptionKey").value;
7673
var endpoint = document.getElementById("endpointUrl").value;
7774
@@ -786,4 +783,4 @@ Explore a JavaScript application that uses Computer Vision to perform optical ch
786783
> [!div class="nextstepaction"]
787784
> [Computer Vision API JavaScript Tutorial](../Tutorials/javascript-tutorial.md)
788785
789-
* To rapidly experiment with the Computer Vision API, try the [Open API testing console](https://westcentralus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fa/console).
786+
* To rapidly experiment with the Computer Vision API, try the [Open API testing console](https://westcentralus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fa/console).

0 commit comments

Comments
 (0)