Created
August 15, 2018 17:38
-
-
Save ghotz/ca18b61d1f3a03438e1c80f71db2e3ea to your computer and use it in GitHub Desktop.
Face detection by URL with Azure Cognitive Services Computer Vision API in PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ComputerVisionAPILocation = "westeurope"; | |
$ComputerVisionAPIURL = "https://$ComputerVisionAPILocation.api.cognitive.microsoft.com/face/v1.0"; | |
$ComputerVisionAPIKey = "YOUR_KEY_GOES_HERE"; | |
$ComputerVisionAPIAnalyzeTemplateURL = ($ComputerVisionAPIURL + "/detect?returnFaceId={0}&returnFaceLandmarks={1}&returnFaceAttributes={2}") | |
$returnFaceId = "true"; | |
$returnFaceLandmarks = "true"; | |
$returnFaceAttributes = "age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise"; | |
$Param = @{"url"="https://cloud.google.com/vision/images/rushmore.jpg"} | |
$Response = Invoke-WebRequest ` | |
-Uri ($ComputerVisionAPIAnalyzeTemplateURL -f $returnFaceId, $returnFaceLandmarks, $returnFaceAttributes) ` | |
-Headers @{'Ocp-Apim-Subscription-Key' = $ComputerVisionAPIKey} ` | |
-Body (ConvertTo-Json $Param) ` | |
-ContentType "application/json" ` | |
-Method "Post" ` | |
-ErrorAction Stop ` | |
-UseBasicParsing; | |
$Response.Content | Out-File "C:\Temp\cognitive\rushmore.face-detect.json" -Encoding UTF8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment