Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0e28cb2
Start of ImageProcessing library and test app
CarlosP-MS Apr 4, 2017
a835fd6
Json serialization/deserialization
CarlosP-MS Apr 5, 2017
190f498
Showing cropped faces in the Faces filter, plus adding error handling…
CarlosP-MS Apr 5, 2017
7edc8ec
Sikipping images with errors during processing loop, plus couple of b…
CarlosP-MS Apr 5, 2017
b861f6a
Updating the file enumeration code in the test app, plus changes to l…
CarlosP-MS Apr 6, 2017
b8d7b4d
Merging from upstream
CarlosP-MS Apr 6, 2017
d5565de
- Removed ImageAnalyzer class and moved relevant code into ImageProce…
CarlosP-MS Apr 12, 2017
4f39546
Merge
CarlosP-MS Apr 12, 2017
450206b
Merge remote-tracking branch 'refs/remotes/upstream/master'
CarlosP-MS Apr 20, 2017
7ff70c8
Merge remote-tracking branch 'refs/remotes/upstream/separate-console-…
CarlosP-MS Apr 20, 2017
081cca7
Merge remote-tracking branch 'upstream/master'
CarlosP-MS May 3, 2017
cb1aa89
Update LabManual.md
CarlosP-MS May 3, 2017
83d005a
Updating TestApp to load keys from settings.json file, and adding ass…
CarlosP-MS May 3, 2017
a00c8b6
Merge branch 'master' of https://github.com/CarlosP-MS/CognitiveServi…
CarlosP-MS May 3, 2017
0d9c680
Update LabManual.md
CarlosP-MS May 3, 2017
a9ff164
Update LabManual.md
CarlosP-MS May 3, 2017
74d6396
Updating sample images to the high resolution versions (needed in ord…
CarlosP-MS May 3, 2017
3b0be49
Merge branch 'master' of https://github.com/CarlosP-MS/CognitiveServi…
CarlosP-MS May 3, 2017
49ca916
Update LabManual.md
CarlosP-MS May 3, 2017
aabd212
Adding support to enter the Azure region associated with the Face and…
CarlosP-MS May 24, 2017
814ac0c
Merge from upstream
CarlosP-MS May 24, 2017
719e03f
Fixing merge conflict
CarlosP-MS May 24, 2017
3916d31
Updating TestCLI settings.json
CarlosP-MS May 25, 2017
b0b63e6
Update LabManual.md
CarlosP-MS May 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,31 @@ public static string ApiKey
}
}

private static string apiKeyRegion;
public static string ApiKeyRegion
{
get { return apiKeyRegion; }
set
{
var changed = apiKeyRegion != value;
apiKeyRegion = value;
if (changed)
{
InitializeFaceServiceClient();
}
}
}

static FaceServiceHelper()
{
InitializeFaceServiceClient();
}

private static void InitializeFaceServiceClient()
{
faceClient = new FaceServiceClient(apiKey);
faceClient = !string.IsNullOrEmpty(ApiKeyRegion) ?
new FaceServiceClient(ApiKey, string.Format("https://{0}.api.cognitive.microsoft.com/face/v1.0", ApiKeyRegion)) :
new FaceServiceClient(ApiKey);
}

private static async Task<TResponse> RunTaskWithAutoRetryOnQuotaLimitExceededError<TResponse>(Func<Task<TResponse>> action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,26 @@ public static string ApiKey
}
}

private static string apiKeyRegion;
public static string ApiKeyRegion
{
get { return apiKeyRegion; }
set
{
var changed = apiKeyRegion != value;
apiKeyRegion = value;
if (changed)
{
InitializeVisionService();
}
}
}

private static void InitializeVisionService()
{
visionClient = new VisionServiceClient(apiKey);
visionClient = !string.IsNullOrEmpty(ApiKeyRegion) ?
new VisionServiceClient(ApiKey, string.Format("https://{0}.api.cognitive.microsoft.com/vision/v1.0", ApiKeyRegion)) :
new VisionServiceClient(ApiKey);
}

private static async Task<TResponse> RunTaskWithAutoRetryOnQuotaLimitExceededError<TResponse>(Func<Task<TResponse>> action)
Expand Down
2 changes: 2 additions & 0 deletions Finished/ImageProcessing/TestApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private static void InitializeServiceHelpers()
dynamic settings = new JsonSerializer().Deserialize(textReader);

FaceServiceHelper.ApiKey = settings.CognitiveServicesKeys.Face;
FaceServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.FaceRegion;
EmotionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Emotion;
VisionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Vision;
VisionServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.VisionRegion;
}
}

Expand Down
4 changes: 3 additions & 1 deletion Finished/ImageProcessing/TestApp/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"CognitiveServicesKeys": {
"Face": "",
"FaceRegion": "",
"Emotion": "",
"Vision": ""
"Vision": "",
"VisionRegion": ""
},
"AzureStorage": {
"ConnectionString": "",
Expand Down
2 changes: 2 additions & 0 deletions Finished/ImageProcessing/TestCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ private static async Task InitializeAsync(string settingsFile = null)
dynamic settings = new JsonSerializer().Deserialize(textReader);

FaceServiceHelper.ApiKey = settings.CognitiveServicesKeys.Face;
FaceServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.FaceRegion;
EmotionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Emotion;
VisionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Vision;
VisionServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.VisionRegion;

BlobStorageHelper.ConnectionString = settings.AzureStorage.ConnectionString;
BlobStorageHelper.ContainerName = settings.AzureStorage.BlobContainer;
Expand Down
4 changes: 3 additions & 1 deletion Finished/ImageProcessing/TestCLI/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"CognitiveServicesKeys": {
"Face": "",
"FaceRegion": "",
"Emotion": "",
"Vision": ""
"Vision": "",
"VisionRegion": ""
},
"AzureStorage": {
"ConnectionString": "",
Expand Down
4 changes: 3 additions & 1 deletion LabManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ Once you have created your new API subscription, you can grab the keys from the

![Cognitive API Key](./assets/cognitive-keys.PNG)

We'll also be using other APIs within the Computer Vision family, so take this opportunity to create API keys for the _Emotion_ and _Face_ APIs as well. They are created in the same fashion as above, and should re-use the same Resource Group you've created. _Pin to Dashboard_, and then add those keys to your `settings.json` files.
We'll also be using other APIs within the Computer Vision family, so take this opportunity to create API keys for the _Emotion_ and _Face_ APIs as well. They are created in the same fashion as above, and should re-use the same Resource Group you've created. _Pin to Dashboard_, and then add those keys to your `settings.json` files.

As you will notice in the previous steps, the _Face_ and _Vision_ APIs have support for multiple Azure Regions. Since each region has a different end point, once you select the region for your keys you will need to enter the region in the `settings.json` files as well. The region value should go in the _FaceRegion_ and _VisionRegion_ fields in the `settings.json` file (the possible values are "eastus2", "southeastasia", "westcentralus", "westeurope" and "westus").

Since we'll be using [LUIS](https://www.microsoft.com/cognitive-services/en-us/language-understanding-intelligent-service-luis) later in the tutorial, let's take this opportunity to create our LUIS subscription here as well. It's created in the exact same fashion as above, but choose Language Understanding Intelligent Service from the API drop-down, and re-use the same Resource Group you created above. Once again, _Pin to Dashboard_ so once we get to that stage of the tutorial you'll find it easy to get access.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,31 @@ public static string ApiKey
}
}

private static string apiKeyRegion;
public static string ApiKeyRegion
{
get { return apiKeyRegion; }
set
{
var changed = apiKeyRegion != value;
apiKeyRegion = value;
if (changed)
{
InitializeFaceServiceClient();
}
}
}

static FaceServiceHelper()
{
InitializeFaceServiceClient();
}

private static void InitializeFaceServiceClient()
{
faceClient = new FaceServiceClient(apiKey);
faceClient = !string.IsNullOrEmpty(ApiKeyRegion) ?
new FaceServiceClient(ApiKey, string.Format("https://{0}.api.cognitive.microsoft.com/face/v1.0", ApiKeyRegion)) :
new FaceServiceClient(ApiKey);
}

private static async Task<TResponse> RunTaskWithAutoRetryOnQuotaLimitExceededError<TResponse>(Func<Task<TResponse>> action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,26 @@ public static string ApiKey
}
}

private static string apiKeyRegion;
public static string ApiKeyRegion
{
get { return apiKeyRegion; }
set
{
var changed = apiKeyRegion != value;
apiKeyRegion = value;
if (changed)
{
InitializeVisionService();
}
}
}

private static void InitializeVisionService()
{
visionClient = new VisionServiceClient(apiKey);
visionClient = !string.IsNullOrEmpty(ApiKeyRegion) ?
new VisionServiceClient(ApiKey, string.Format("https://{0}.api.cognitive.microsoft.com/vision/v1.0", ApiKeyRegion)) :
new VisionServiceClient(ApiKey);
}

private static async Task<TResponse> RunTaskWithAutoRetryOnQuotaLimitExceededError<TResponse>(Func<Task<TResponse>> action)
Expand Down
2 changes: 2 additions & 0 deletions Starting/ImageProcessing/TestApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private static void InitializeServiceHelpers()
dynamic settings = new JsonSerializer().Deserialize(textReader);

FaceServiceHelper.ApiKey = settings.CognitiveServicesKeys.Face;
FaceServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.FaceRegion;
EmotionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Emotion;
VisionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Vision;
VisionServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.VisionRegion;
}
}
private async void ProcessImagesClicked(object sender, RoutedEventArgs e)
Expand Down
4 changes: 3 additions & 1 deletion Starting/ImageProcessing/TestApp/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"CognitiveServicesKeys": {
"Face": "",
"FaceRegion": "",
"Emotion": "",
"Vision": ""
"Vision": "",
"VisionRegion": ""
},
"AzureStorage": {
"ConnectionString": "",
Expand Down
2 changes: 2 additions & 0 deletions Starting/ImageProcessing/TestCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ private static async Task InitializeAsync(string settingsFile = null)
dynamic settings = new JsonSerializer().Deserialize(textReader);

FaceServiceHelper.ApiKey = settings.CognitiveServicesKeys.Face;
FaceServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.FaceRegion;
EmotionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Emotion;
VisionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Vision;
VisionServiceHelper.ApiKeyRegion = settings.CognitiveServicesKeys.VisionRegion;

BlobStorageHelper.ConnectionString = settings.AzureStorage.ConnectionString;
BlobStorageHelper.ContainerName = settings.AzureStorage.BlobContainer;
Expand Down
4 changes: 3 additions & 1 deletion Starting/ImageProcessing/TestCLI/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"CognitiveServicesKeys": {
"Face": "",
"FaceRegion": "",
"Emotion": "",
"Vision": ""
"Vision": "",
"VisionRegion": ""
},
"AzureStorage": {
"ConnectionString": "",
Expand Down