Raj Shakya Raj Shakya - 6 months ago 32
Javascript Question

Unable to track eyes using tracking.js

I am creating a eye staring game. I have used meteorjs, trackingjs for tracking stuffs and peerjs for streaming. In the older version of trackingjs , eye detecting feature was already there but in the new version only the face detecting feature is available.
Here is the demo app which only tracks the face.
http://sushantbaj.meteor.com/
and this is my link to my github repo:
https://github.com/sushant12/eye-staring
In the docs of trackingjs, it is said that


In order to use object tracker, you need to instantiate the
constructor passing the classifier data to detect:


var objects = new tracking.ObjectTracker(['face', 'eye', 'mouth']);


So I passed 'eye' as a parameter but it did not track my eye.

var tracker = new tracking.ObjectTracker('eye');
tracker.setInitialScale(4);
tracker.setStepSize(2);
tracker.setEdgesDensity(0.1);

tracking.track('#video', tracker, { camera: true });

tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);

event.data.forEach(function(rect) {
context.strokeStyle = '#a64ceb';
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
context.font = '11px Helvetica';
context.fillStyle = "#fff";
context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);
context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);
});
});

Answer

The problem has been solved.

var tracker = new tracking.ObjectTracker('eye');
tracker.setStepSize(1.7);

tracking.track('#video', tracker, { camera: true });

tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);

event.data.forEach(function(rect) {
  context.strokeStyle = '#a64ceb';
  context.strokeRect(rect.x, rect.y, rect.width, rect.height);

});
});