Skip to content

Instantly share code, notes, and snippets.

@andijakl andijakl/imageAnalysis.js
Last active Mar 20, 2019

Embed
What would you like to do?
Simple JavaScript code to access the Azure Cognitive Services for Computer Vision
// 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
You can’t perform that action at this time.