问题描述
我想在 Vincent Muhler 提供的face-api.js中使用mtcnn实现实时人脸检测,但是出现 mtcnnResults.map不是函数的错误。 。请看一下代码并给我建议。 预先感谢。
<div style="position: relative" class="margin">
<video onplay="onPlay(this)" id="inputVideo" autoplay muted></video>
<canvas id="overlay" />
</div>
$(document).ready(function() {
run()
})
async function run() {
// load the models
await faceapi.loadMtcnnModel('/model2')
await faceapi.loadFaceRecognitionModel('/model2')
const videoEl = document.getElementById('inputVideo')
navigator.getUserMedia(
{ video: {} },stream => videoEl.srcObject = stream,err => console.error(err)
)
}
const mtcnnForwardParams = {
maxNumScales: 10,scaleFactor: 0.709,scoreThresholds: [0.6,0.7,0.7],minFaceSize: 200
}
const mtcnnResults = faceapi.mtcnn(document.getElementById('inputVideo'),mtcnnForwardParams)
faceapi.drawDetection('overlay',mtcnnResults.map(res => res.faceDetection),{ withScore: false })
faceapi.drawLandmarks('overlay',mtcnnResults.map(res => res.faceLandmarks),{ lineWidth: 4,color: 'red' })
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)