Name the state when there is no face
Hi!
I am using clmtrackr for a student project, thanks a lot @auduno for sharing your project here!!
I have a question concerning the state when the face-tracking cannot find any face: how can I name or adress this state in javascript-language? So far I am using the face-score-number to describe in the code when there is probably no face in front of the camera. But unfortunately the score-number continues to be over 0.55 sometimes when there is already no face anymore...
Sorry, for maybe asking a very trivial question! I am completely new with the programming thing, javascript, html…
Thanks for helping!
You can use the events that the tracker sends, in combination with the scoring. You can make an additional event when score is low, but in most cases then you'll get a "clmtrackrLost" event.
// before track event
document.addEventListener("clmtrackrBeforeTrack", function() {
});
// after succesful track event (face found)
document.addEventListener("clmtrackrIteration", function() {
var faceData = ctracker.getCurrentPosition();
var score = ctracker.getScore();
// do something
});
// when tracking lost (definitely no face)
document.addEventListener("clmtrackrLost", function() {
});
So, if I don't need to show the video, nor to draw the tracked features on the screen, I do not need to call requestAnimationFrame() and can instead just trap the "trackrIteration" and "trackLost" events?
clmtracker.start() uses requestAnimationFrame internally already so that's not needed.
But I think you can also manually trigger clmtracker.track() if that is what you are after.
I just need to take a video from the camera and detect a face in real-time on the video, without showing it on the web page. I need just to check whether a face is there or not.
You can always just hide the video or canvas you are writing at? It doesn't need to be visible to actually work.
this is what I'm doing at the moment, but wanted to better understand the library and see if there is a way to avoid adding a requestAnimationFrame loop, mainly because you said that one such a loop is already started by clmtracker.start().