Count Number Of Faces Using Javascript
Is there a way that I can count the number of faces in a live camera. For example I've three persons in front of a webcam and I'm having 2 pages say, Success.html and error .html a
Solution 1:
From the documentation:
myTracker.on('track', function(event) {
if (event.data.length === 0) {
// No targets were detected in this frame.
} else {
event.data.forEach(function(data) {
// Plots the detected targets here.
});
}
});
It seems to be event.data.length
that gives you the number of tracked elements.
Solution 2:
Fom the docs at https://trackingjs.com/docs.html#trackers
myTracker.on('track', function(event) {
if (event.data.length === 0) {
// No targets were detected in this frame.
} else {
event.data.forEach(function(data) {
// Plots the detected targets here.
});
}
});
Use event.data.length
to count the amount of faces.
On your piece of code :
tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);
// console log amount of elements foundconsole.log(event.data.length);
event.data.forEach(function(rect) {
console.log('face detected');
});
});
Post a Comment for "Count Number Of Faces Using Javascript"