Skip to content

Instantly share code, notes, and snippets.

@germanattanasio
Last active December 17, 2015 18:18
Show Gist options
  • Save germanattanasio/e32094c48e5ac837d848 to your computer and use it in GitHub Desktop.
Save germanattanasio/e32094c48e5ac837d848 to your computer and use it in GitHub Desktop.
Example of how to call the AlchemyVision with the watson-developer-cloud npm module
// face recognition with a URL
var params = {
knowledgeGraph: 1 // Include knowledge graph information in the the results.
url: 'https://upload.wikimedia.org/wikipedia/commons/0/00/Scarlett_Johansson_-_Captain_America_2_press_conference_%28retouched%29_2.jpg'
};
// UNCOMMENT THE CODE BELOW TO SEND AN IMAGE INSTEAD OF A URL
// face recognition with an image
// var params = {
// image: fs.createReadStream('resources/face.jpg')
// };
// UNCOMMENT THE CODE BELOW TO SEND AN IMAGE AS BASE64 ENCODED IMAGE
// face recognition with an image
// var params = {
// image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYQAAAImCAYAAABTgf2rAAA....'
// };
alchemy_vision.recognizeFaces(params, function (err, keywords) {
if (err)
console.log('error:', err);
else
console.log(JSON.stringify(keywords, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment