Last active
March 20, 2019 04:02
-
-
Save andijakl/024ec9ed1fbe4da7eeae509b9e3f9c54 to your computer and use it in GitHub Desktop.
Simple JavaScript code to access the Azure Cognitive Services for Computer Vision
This file contains 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
// Basic JavaScript function to submit an image to the Microsoft Cognitive Services API. | |
// Note: to get this running, you need a valid subscription key. Also, make sure you | |
// adapt the URL of the service to match the region where you created it (see the TODO comment). | |
// | |
// Microsoft tutorial: | |
// https://docs.microsoft.com/en-us/azure/cognitive-services/computer-vision/tutorials/javascript-tutorial | |
function analyzeButtonClick() { | |
// Retrieve the user-entered value of the image URL | |
let sourceImageUrl = $("#inputImage").val(); | |
// Retrieve the user-entered value of the subscription key | |
let subscriptionKey = $("#subscriptionKey").val(); | |
// Call the processing function, passing the user entered values | |
// as well as a reference to the output text area element | |
AnalyzeImage(subscriptionKey, sourceImageUrl, $("#responseTextArea")); | |
} | |
function AnalyzeImage(subscriptionKey, sourceImageUrl, responseTextArea) { | |
// Request parameters | |
let params = { | |
// Choose categories to analyze - see the documentation for reference | |
"visualFeatures": "Categories,Tags,Description,Faces,ImageType,Color,Adult", | |
"details": "", | |
"language": "en", | |
}; | |
// ... AJAX call to the Azure Cognitive Service for Computer Vision goes here ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment