Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active April 14, 2018 07:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save conanak99/5f2c93434a2fc25f0a55fe3da7a510ff to your computer and use it in GitHub Desktop.
const rp = require('request-promise');
async function detectImage(source) {
const subscriptionKey = "[thay bằng key của bạn]";
const uri = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect";
const options = {
uri,
qs: {
returnFaceId: true,
returnFaceLandmarks: true, // Nhận diện các điểm trên khuôn mặt
},
method: 'POST',
headers: {
'Ocp-Apim-Subscription-Key': subscriptionKey
},
body: {
url: source
},
json: true
};
const result = await rp(options);
return result;
}
(async () => {
const imageUrl = 'https://pbs.twimg.com/media/DWr05hUXcAA9s8n.jpg'
const result = await detectImage(imageUrl);
console.log(JSON.stringify(result, null, 2));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment