View on GitHub

Eyeplayer

Control stuff with your webcam using Javascript

Blink Detection

About this demonstration

This is an example of detecting a user blinking with a webcam.

It uses the following approach:

View the eyePlayer.js source on Github to see how the code works.

Usage example

<div id="videoContainer">
  <video id="inputVideo" autoplay></video>
  <canvas id="overlay"></canvas>
</div>

<script data-main="javascripts/eyePlayer.min.js" src="javascripts/require.js"></script>
<script type="text/javascript">
  var videoInput = document.getElementById('inputVideo');
  var canvasOutput = document.getElementById('overlay');

  require(['eyePlayer'], function(eyePlayer) {
    eyeplayer = new eyePlayer();
    eyeplayer.init(videoInput, canvasOutput);
    eyeplayer.start();
  });

  document.addEventListener('blinkEvent', function() {
    /* DO SOMETHING FUN WHEN THE USER BLINKS */
  });
  document.addEventListener('eyeTrackedEvent', function(event) {
    /* DO SOMETHING FUN WHEN THE USER'S HEAD IS FOUND */
    console.log(event.face);
    console.log(event.eyes);
  });
</script>

View source of this page to see a more complete example.