Skip to content

Commit d87fc48

Browse files
authored
Update CSharp-analyze.md
1 parent 0b6db20 commit d87fc48

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

articles/cognitive-services/Computer-vision/QuickStarts/CSharp-analyze.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2828

2929
To create the sample in Visual Studio, do the following steps:
3030

31-
1. Create a new Visual Studio solution in Visual Studio, using the Visual C# Console App (.NET Framework) template.
31+
1. Create a new Visual Studio solution/project in Visual Studio, using the Visual C# Console App (.NET Core Framework) template.
3232
1. Install the Newtonsoft.Json NuGet package.
3333
1. On the menu, click **Tools**, select **NuGet Package Manager**, then **Manage NuGet Packages for Solution**.
34-
1. Click the **Browse** tab, and in the **Search** box type "Newtonsoft.Json".
35-
1. Select **Newtonsoft.Json** when it displays, then click the checkbox next to your project name, and **Install**.
34+
1. Click the **Browse** tab, and in the **Search** box type "Newtonsoft.Json" (if it is not already displayed).
35+
1. Select **Newtonsoft.Json**, then click the checkbox next to your project name, and **Install**.
36+
1. Copy/paste the sample code snippet below, into your Program.cs file. Adjust the namespace name if it's different from the one you created.
37+
1. Add an image of your choosing to your bin/debug/netcoreappX.X folder, then add the image name (with extension) to the 'imageFilePath' variable.
3638
1. Run the program.
37-
1. At the prompt, enter the path to a local image.
3839

3940
```csharp
4041
using Newtonsoft.Json.Linq;
@@ -54,26 +55,18 @@ namespace CSHttpClientSample
5455
static string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
5556

5657
// the Analyze method endpoint
57-
static string uriBase = endpoint + "vision/v2.1/analyze";
58+
static string uriBase = endpoint + "vision/v3.0/analyze";
5859

59-
static async Task Main()
60+
// Image you want analyzed (add to your bin/debug/netcoreappX.X folder)
61+
// For sample images, download one from here (png or jpg):
62+
// https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images
63+
static string imageFilePath = @"my-sample-image";
64+
65+
public static void Main()
6066
{
61-
// Get the path and filename to process from the user.
62-
Console.WriteLine("Analyze an image:");
63-
Console.Write(
64-
"Enter the path to the image you wish to analyze: ");
65-
string imageFilePath = Console.ReadLine();
67+
// Call the API
68+
MakeAnalysisRequest(imageFilePath).Wait();
6669

67-
if (File.Exists(imageFilePath))
68-
{
69-
// Call the REST API method.
70-
Console.WriteLine("\nWait for the results to appear.\n");
71-
await MakeAnalysisRequest(imageFilePath);
72-
}
73-
else
74-
{
75-
Console.WriteLine("\nInvalid file path");
76-
}
7770
Console.WriteLine("\nPress Enter to exit...");
7871
Console.ReadLine();
7972
}
@@ -162,7 +155,7 @@ namespace CSHttpClientSample
162155

163156
## Examine the response
164157

165-
A successful response is returned in JSON. The sample application parses and displays a successful response in the console window, similar to the following example:
158+
A successful response is returned in JSON (based on your own image used) in the console window, similar to the following example:
166159

167160
```json
168161
{

0 commit comments

Comments
 (0)