1

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);
        });
      });
Zeno Rocha
  • 3,226
  • 1
  • 23
  • 27
Raaz
  • 1,669
  • 2
  • 24
  • 48

1 Answers1

2

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);

});
});
Raaz
  • 1,669
  • 2
  • 24
  • 48
  • I know this is an old answer, but I'm curious - following along with this code just makes the rectangle to highlight the eyes shoved off to the side. Am i missing something here? – Stephen Tetreault Mar 02 '18 at 23:17