Skip to content

Commit

Permalink
wip, but got browserify example working
Browse files Browse the repository at this point in the history
  • Loading branch information
andyinabox committed Jan 24, 2016
1 parent 5024a6c commit c1d215c
Show file tree
Hide file tree
Showing 17 changed files with 5,152 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example-browserify/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var clmtrackr = require('../src/index.js');
var model = require('../models-json/model_pca_20_svm.json');
var videoGrabber = require('./videoGrabber.js');
var raf = require('raf');

var width = 600;
var height = 400;

var tracker = new clmtrackr.tracker();
var video = videoGrabber(width, height);
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var cc = canvas.getContext('2d');

function setup() {
video.play();

document.body.appendChild(canvas);

tracker.init(model);
tracker.start(video);
}

function update() {
raf(update);
cc.clearRect(0, 0, width, height);
cc.drawImage(video, 0, 0, width, height);
if(tracker.getCurrentPosition()) {
tracker.draw(canvas);
}
}



setup();
update();
29 changes: 29 additions & 0 deletions example-browserify/videoGrabber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var getUserMedia = require('getusermedia');

function videoGrabber(width, height) {
var v = document.createElement('video');
var constraints = {
audio: false
, video: {
width: { min: width, ideal: width }
, height: { min: height, ideal: height}
}
}

v.width = width;
v.height = height;


getUserMedia(constraints, function(err, stream) {
if(err) {
throw new Error(err);
}

// http://www.kirupa.com/html5/accessing_your_webcam_in_html5.htm
v.src = window.URL.createObjectURL(stream);
});

return v;
}

module.exports = videoGrabber;
1 change: 1 addition & 0 deletions filters/entire_face_filter.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filters/frontalface.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filters/left_eye_filter.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filters/nose_filter.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filters/right_eye_filter.json

Large diffs are not rendered by default.

623 changes: 623 additions & 0 deletions models-json/model_pca_20_svm.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"url": "https://github.com/auduno/clmtrackr.git"
},
"devDependencies": {
"getusermedia": "^1.3.5",
"grunt": "~0.4.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.7"
Expand Down
Loading

0 comments on commit c1d215c

Please sign in to comment.