Last active
August 11, 2018 22:09
-
-
Save ghotz/6fc282cad887e960deeef9a522d27b2d to your computer and use it in GitHub Desktop.
Analyze image 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
| # Analyze image by URL with Azure Cognitive Services Computer Vision API in PowerShell | |
| $ComputerVisionAPILocation = "westeurope"; | |
| $ComputerVisionAPIURL = "https://$ComputerVisionAPILocation.api.cognitive.microsoft.com/vision/v2.0"; | |
| $ComputerVisionAPIKey = "YOUR_KEY_GOES_HERE"; | |
| $ComputerVisionAPIAnalyzeTemplateURL = ($ComputerVisionAPIURL + "/analyze?visualFeatures={0}&details={1}&language={2}") | |
| $visualFeatures = "Categories,Tags,Description,Faces,ImageType,Color,Adult"; | |
| $details = "Celebrities,Landmarks"; | |
| $language = "en"; | |
| $Param = @{"url"="https://cloud.google.com/vision/images/rushmore.jpg"} | |
| $Response = Invoke-WebRequest ` | |
| -Uri ($ComputerVisionAPIAnalyzeTemplateURL -f $visualFeatures, $details, $language) ` | |
| -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.analyze.json" -Encoding UTF8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment