face-api.js:在瀏覽器中進行人臉識別的JavaScript接口

const maxDistance = 0.6

results.forEach(result => {

faceapi.drawDetection(canvas, result.detection, { withScore: false })

const text = `${result.distance < maxDistance ? result.className : 'unkown'} (${result.distance})`

const { x, y, height: boxHeight } = detection.getBox()

faceapi.drawText(

canvas.getContext('2d'),

x,

y + boxHeight,

text

)

})

face-api.js:在瀏覽器中進行人臉識別的JavaScript接口

至此,我希望你對如何使用這個 API 有了一個初步的認識。同時,我也建議你看看文中給出的代碼倉庫中的其它示例。好好地把這個程序包玩個痛快吧!


分享到:


相關文章: