WebDevSimplified / Face-Detection-JavaScript

1k stars 1.39k forks source link

Webcam is loading, but canvas/face recognision isnt #46

Closed TetieWasTaken closed 2 years ago

TetieWasTaken commented 3 years ago

This is my directory: Schermafbeelding 2021-04-28 om 10 03 30

aspectxlol commented 3 years ago

in the script.js i changed the .then(startVideo) to .then(startVideo()) but the recognition ans stuff isnt showing up for me

ccdejene commented 3 years ago

check the positions of the elements, like the video and de canvas the append event has to be appending the canvas inside the video element

Shubbair commented 3 years ago

check the path of script or the spell of it

Daniel-Sogbey commented 2 years ago

var video = document.getElementById("video");

Promise.all([ faceapi.nets.tinyFaceDetector.loadFromUri("/models"), faceapi.nets.faceLandmark68Net.loadFromUri("/models"), faceapi.nets.faceRecognitionNet.loadFromUri("/models"), faceapi.nets.faceExpressionNet.loadFromUri("/models") ]).then(startVideo());

console.log(video); video.setAttribute("playsinline", ""); video.setAttribute("autoplay", ""); video.setAttribute("muted", ""); video.style.width = "200px"; video.style.height = "200px";

/ Setting up the constraint / var facingMode = "user"; // Can be 'user' or 'environment' to access back or front camera (NEAT!) var constraints = { audio: false, video: { facingMode: facingMode } };

/ Stream it to video element / const startVideo = () => { navigator.mediaDevices .getUserMedia(constraints) .then(function success(stream) { video.srcObject = stream; }); };