Skip to content

Instantly share code, notes, and snippets.

@zenorocha
Created October 18, 2012 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenorocha/3909630 to your computer and use it in GitHub Desktop.
Save zenorocha/3909630 to your computer and use it in GitHub Desktop.
tracking.js - Single Controller Example
var videoCamera = new tracking.VideoCamera().hide().render().renderVideoCanvas();
var t1 = videoCamera.track(
{
type: 'color',
color: 'magenta',
onFound: function(track) {
var pixels = track.pixels;
for (var i = 0, len = pixels.length; i < len; i += 2) {
videoCamera.canvas.context.fillStyle = "rgb(255,0,255)";
videoCamera.canvas.context.fillRect(pixels[i], pixels[i+1], 2, 2);
}
videoCamera.canvas.context.fillStyle = "rgb(0,0,0)";
videoCamera.canvas.context.fillRect(track.x, track.y, 5, 5);
},
onNotFound: function() {
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment