-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip, but got browserify example working
- Loading branch information
1 parent
5024a6c
commit c1d215c
Showing
17 changed files
with
5,152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.