headtrackr.js

Javascript library for headtracking via webcam and WebRTC/getUserMedia

View the Project on GitHub auduno/headtrackr

Library Reference

Flow

This is the rough process that will happen on regular intervals once headtrackr is started. On initialization we will also check whether getUserMedia is supported and if we are able to stream from a camera at all.

Events

Once started, headtrackr.js produces three types of events on the document. headtrackrStatus is triggered on any changes in status, such as when the face is detected, when tracking of the face is lost, and similar. facetrackingEvent is triggered every 20 ms (depending on detection interval), and gives us the position of the face on the canvas. headtrackingEvent is also triggered every 20 ms, and gives us the calculated position of the head relative to the camera. Note that these two events will first be triggered when the face is detected and tracked. Details of what properties each event passes along are below, and actions can be triggered by any of these events in the standard way:

document.addEventListener('headtrackrStatus', 
  function (event) {
    if (event.status == "getUserMedia") {
      alert("getUserMedia is supported!");
    }
  }
);

headtrackrStatus:

facetrackingEvent:

headtrackingEvent:

Parameters

When initializing the objects headtrackr.Tracker, headtrackr.facetracker.Tracker or headtrackr.camshift.Tracker, you can optionally specify some parameters, for instance:

var ht = new headtrackr.Tracker({ui : true, headPosition : false});

The optional parameters that can be passed along to headtrackr.Tracker are :

The optional parameters to headtrackr.facetrackr.Tracker :

Optional parameters to headtrackr.camshift.Tracker :

Functions

These are the functions that the headtrackr.Tracker object exposes:

Elements