Skip to content

Commit a1af7e9

Browse files
authored
Merge pull request #115036 from v-jaswel/patch-11
[DO NOT MERGE UNTIL BUILD] Update CSharp-analyze.md, python-disk.md
2 parents 30ff7eb + 18b88db commit a1af7e9

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
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
{

articles/cognitive-services/Computer-vision/QuickStarts/python-disk.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
3737
To create and run the sample, do the following steps:
3838

3939
1. Copy the following code into a text editor.
40-
1. Optionally, replace the value of `image_path` with the path and file name of a different image that you want to analyze.
40+
1. Replace the value of `image_path` with the path and file name of a different image that you want to analyze.
4141
1. Save the code as a file with an `.py` extension. For example, `analyze-local-image.py`.
4242
1. Open a command prompt window.
4343
1. At the prompt, use the `python` command to run the sample. For example, `python analyze-local-image.py`.
@@ -62,9 +62,11 @@ else:
6262
if 'COMPUTER_VISION_ENDPOINT' in os.environ:
6363
endpoint = os.environ['COMPUTER_VISION_ENDPOINT']
6464

65-
analyze_url = endpoint + "vision/v2.1/analyze"
65+
analyze_url = endpoint + "vision/v3.0/analyze"
6666

6767
# Set image_path to the local path of an image that you want to analyze.
68+
# Sample images are here, if needed:
69+
# https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images
6870
image_path = "C:/Documents/ImageToAnalyze.jpg"
6971

7072
# Read the image into a byte array

0 commit comments

Comments
 (0)