问题描述
刚刚发现了很棒的 face-api.js repo,我在使用面部表情 API 时玩得很开心。也许是因为我笑得太多了(为了测试)。
无论如何,在我的应用中,我想检查用户是否在微笑,但不在屏幕上显示相机视频。
目前,我可以非常准确地检查用户是否在微笑,但视频必须在我的屏幕上。
如何从屏幕上删除视频?
这里是js代码:
<video id="video" width="500" height="500" autoplay muted ></video>
async startVideo() {
let stream = null;
try {
stream = await navigator.mediaDevices.getUserMedia({
audio: false,video: { width: 1280,height: 720 },});
this.video.srcObject = stream;
} catch (e) {
console.log(e);
}
},this.video = document.getElementById('video');
Promise.all([
faceapi.nets.tinyFaceDetector.loadFromUri('/models'),faceapi.nets.faceExpressionNet.loadFromUri('/models'),]).then(this.startVideo);
this.video.addEventListener('play',() => {
console.log('video started');
setInterval(async () => {
const detections = await faceapi.detectAllFaces(
this.video,new faceapi.TinyFaceDetectorOptions(),).withFaceExpressions();
detections.forEach((detection) => {
if (detection.expressions.happy >= 0.7) {
this.isHappy = true;
} else {
this.isHappy = false;
}
});
},100);
});
应用在 vue.js 中,所以我只取了重要的部分。
非常感谢您的帮助。 干杯,
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)