face-api.js icon indicating copy to clipboard operation
face-api.js copied to clipboard

Stop recognition once face is a known detected

Open xiaotingyeo11 opened this issue 5 years ago • 3 comments

Hi,

Is there a way to stop recognition once a known face is being recognized?

Example: if I have a couple of unknown user appearing on web cam, there is only 1 person which is detected to be 'Person A', can i pause / prompt the system that there is one person that is identified?

Do share your views how this can be done. Thank you in advance!

xiaotingyeo11 avatar May 03 '19 01:05 xiaotingyeo11

You can stop the face recognition at any time sure. That's not something that face-api.js handles, the library simply does predictions frame by frame. That's something you handle in your code.

justadudewhohacks avatar May 08 '19 07:05 justadudewhohacks

Hello, does somebody has found an answer to this?

I don't know how to handle this via code.

I have tried doing this: function stopStreamedVideo(videoElem) { let stream = videoElem.srcObject; let tracks = stream.getTracks();

tracks.forEach(function(track) { track.stop(); });

videoElem.srcObject = null; }

But, if after that, I try to resume again the tracking via: function run() { console.log("RUN"); var deviceId1 = "b39987e633d921f2cbe84fa9c9a9308631f8b7f48f675e05582548f2808cb8bf"; stream1 = await navigator.mediaDevices.getUserMedia({ video: {deviceId: {exact: deviceId1}} }); videoEl1 = document.getElementById('inputVideo1'); videoEl1.srcObject = stream1; }

But what I get is an increase of the console output everytime I call this function. The first time the console outputs "run" The second time outputs "run" twice. The third time outputs "run" three consecutive times. .... and so on

So in the 10th or more iterations, the App crashes and the video output goes away, also with the face recognition

andresrl avatar Jan 20 '20 13:01 andresrl

Hello Andresrl, did you find a solution to this? I have the same issue and I don't know either how to stop it via code

MathYom99 avatar Sep 18 '23 19:09 MathYom99