clmtrackr icon indicating copy to clipboard operation
clmtrackr copied to clipboard

Name the state when there is no face

Open HelloJsWorld opened this issue 8 years ago • 6 comments

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!

HelloJsWorld avatar Oct 05 '17 09:10 HelloJsWorld

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() {

});

markknol avatar Jan 08 '18 14:01 markknol

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?

ianni67 avatar Jan 11 '18 14:01 ianni67

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.

markknol avatar Jan 11 '18 14:01 markknol

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.

ianni67 avatar Jan 11 '18 14:01 ianni67

You can always just hide the video or canvas you are writing at? It doesn't need to be visible to actually work.

markknol avatar Jan 11 '18 16:01 markknol

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().

ianni67 avatar Jan 11 '18 16:01 ianni67