Skip to content

Commit 206d4ac

Browse files
committed
fixing merge conflict
2 parents a516337 + 2476e75 commit 206d4ac

File tree

58 files changed

+283
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+283
-299
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- csharp
5+
- html
6+
- java
7+
- javascript
8+
- swift
9+
- python
10+
products:
11+
- azure
12+
description: "This repo provides code samples for cognitive services APIs."
13+
urlFragment: cognitive-services-REST-api-samples
14+
---
15+
116
# Samples for REST APIs in Cognitive Services
217

318
This repo provides code samples for cognitive services APIs. There are sections for Language, Search, and Vision APIs using various progamming languages. Note that these are just simple wrappers to the APIs. For SDKs and SDK samples there are separate repos. You can check out all cognitive services APIs here: https://azure.microsoft.com/en-us/services/cognitive-services/. You can check out detailed documentation of these APIs here: https://docs.microsoft.com/en-us/azure/#pivot=products&panel=cognitive.

dotnet/ComputerVision/AnalyzeImage/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.AnalyzeImage
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1617
static void Main(string[] args)
1718
{
1819
AnalyzeImageSample.RunAsync(endpoint, subscriptionKey).Wait(6000);
@@ -26,8 +27,8 @@ public class AnalyzeImageSample
2627
public static async Task RunAsync(string endpoint, string key)
2728
{
2829
Console.WriteLine("Images being analyzed:");
29-
30-
string imageFilePath = @"Images\faces.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any image on your machine.
30+
// See this repo's readme.md for info on how to get these images. Or, set the path to any image on your machine.
31+
string imageFilePath = @"Images\faces.jpg";
3132
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/landmark.jpg";
3233

3334
await AnalyzeFromUrlAsync(remoteImageUrl, endpoint, key);

dotnet/ComputerVision/BatchReadFile/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.BatchReadFile
1111

1212
public class Program
1313
{
14-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
15-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
14+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
15+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
16+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
1617

1718
static void Main(string[] args)
1819
{
@@ -28,8 +29,8 @@ public class BatchReadFileSample
2829
public static async Task RunAsync(string endpoint, string key)
2930
{
3031
Console.WriteLine("Extracting text from the images:");
31-
32-
string imageFilePath = @"Images\handwritten_text.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
32+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
33+
string imageFilePath = @"Images\handwritten_text.jpg";
3334
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/printed_text.jpg";
3435

3536
await BatchReadFileFromStreamAsync(imageFilePath, endpoint, key);

dotnet/ComputerVision/DescribeImage/Program.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.DescribeImage
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1617
static void Main(string[] args)
1718
{
1819
DescribeImageSample.RunAsync(endpoint, subscriptionKey).Wait(5000);
19-
20+
2021
Console.WriteLine("\nPress ENTER to exit.");
2122
Console.ReadLine();
2223
}
@@ -27,8 +28,8 @@ public class DescribeImageSample
2728
public static async Task RunAsync(string endpoint, string key)
2829
{
2930
Console.WriteLine("Describe an image:");
30-
31-
string imageFilePath = @"Images\objects.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
31+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
32+
string imageFilePath = @"Images\objects.jpg";
3233
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/celebrities.jpg";
3334

3435
await DescribeImageFromStreamAsync(imageFilePath, endpoint, key);

dotnet/ComputerVision/DetectObjects/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.DetectObjects
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
1516

1617
static void Main(string[] args)
1718
{

dotnet/ComputerVision/GetAreaOfInterest/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.GetAreaOfInte
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1617
static void Main(string[] args)
1718
{
1819
GetAreaOfInterestSample.RunAsync(endpoint, subscriptionKey).Wait(5000);
@@ -27,8 +28,8 @@ public class GetAreaOfInterestSample
2728
public static async Task RunAsync(string endpoint, string key)
2829
{
2930
Console.WriteLine("Get area of interests in images:");
30-
31-
string imageFilePath = @"Images\objects.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
31+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
32+
string imageFilePath = @"Images\objects.jpg";
3233
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/celebrities.jpg";
3334

3435
await GetAreaOfInterestFromStreamAsync(imageFilePath, endpoint, key);

dotnet/ComputerVision/GetThumbnail/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.GetThumbnail
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1617
static void Main(string[] args)
1718
{
1819
GetThumbnailSample.RunAsync(endpoint, subscriptionKey).Wait(5000);

dotnet/ComputerVision/OCR/Program.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.OCR
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1617
static void Main(string[] args)
1718
{
1819
OCRSample.RunAsync(endpoint, subscriptionKey).Wait(5000);
@@ -27,10 +28,10 @@ public class OCRSample
2728
public static async Task RunAsync(string endpoint, string key)
2829
{
2930
Console.WriteLine("Performing OCR on the images:");
30-
31-
string imageFilePath = @"Images\printed_text.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
31+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
32+
string imageFilePath = @"Images\printed_text.jpg";
3233
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/printed_text.jpg";
33-
//OCR works poorly for non-printed text. Look at the ExtractText sample for using the read operation that can work for both handwritten and printed text
34+
// OCR works poorly for non-printed text. Look at the ExtractText sample for using the read operation that can work for both handwritten and printed text
3435
await OCRFromStreamAsync(imageFilePath, endpoint, key);
3536
await OCRFromUrlAsync(remoteImageUrl, endpoint, key);
3637
}

dotnet/ComputerVision/RecognizeDomainSpecificContent/Program.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.RecognizeDoma
1010

1111
class Program
1212
{
13-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
14-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
15-
13+
14+
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
15+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
16+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
17+
1618
static void Main(string[] args)
1719
{
1820
RecognizeDomainSpecificContentSample.RunAsync(endpoint, subscriptionKey).Wait(5000);
@@ -27,8 +29,8 @@ public class RecognizeDomainSpecificContentSample
2729
public static async Task RunAsync(string endpoint, string key)
2830
{
2931
Console.WriteLine("Recognize domain specific content (celebrities/landmarks) in images:");
30-
31-
string imageFilePath = @"Images\landmark.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
32+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
33+
string imageFilePath = @"Images\landmark.jpg";
3234
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/celebrities.jpg";
3335

3436
await RecognizeDomainSpecificContentFromUrlAsync(remoteImageUrl, endpoint, key, "celebrities");

dotnet/ComputerVision/RecognizeText/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace Microsoft.Azure.CognitiveServices.Samples.ComputerVision.RecognizeText
1111

1212
public class Program
1313
{
14-
public const string subscriptionKey = "<your training key here>"; //Insert your Cognitive Services subscription key here
15-
public const string endpoint = "https://westus.api.cognitive.microsoft.com"; // You must use the same Azure region that you generated your subscription keys for. Free trial subscription keys are generated in the westus region.
16-
14+
public const string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
15+
public const string endpoint = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
16+
1717
static void Main(string[] args)
1818
{
1919
RecognizeTextSample.RunAsync(endpoint, subscriptionKey).Wait(5000);
@@ -28,8 +28,8 @@ public class RecognizeTextSample
2828
public static async Task RunAsync(string endpoint, string key)
2929
{
3030
Console.WriteLine("Recognizing text from the images:");
31-
32-
string imageFilePath = @"Images\handwritten_text.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
31+
// See this repo's readme.md for info on how to get these images. Or, set the path to any appropriate image on your machine.
32+
string imageFilePath = @"Images\handwritten_text.jpg";
3333
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/printed_text.jpg";
3434

3535
await RecognizeTextFromStreamAsync(imageFilePath, endpoint, key, "Handwritten"); //the last parameter is whether the text that has to be extracted is printed or handwritten

0 commit comments

Comments
 (0)