Last active
April 14, 2018 07:11
Star
You must be signed in to star a gist
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
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