auduno / headtrackr

Javascript library for headtracking via webcam and WebRTC/getUserMedia
3.69k stars 504 forks source link

canvas inputs #9

Open forresto opened 11 years ago

forresto commented 11 years ago

My project has a camera module already, so I wanted to us that canvas instead of the video. To headtrackr.js I added:

this.customStart = function(canvas, context) {
    canvasElement = canvas;
    canvasContext = context;

    // create ui if needed
    if (params.ui) {
        ui = new headtrackr.Ui();
    }

    // create smoother if enabled
    smoother = new headtrackr.Smoother(0.35, params.detectionInterval+15);

    this.initialized = true;
    run = false;

}
this.customTrack = function(canvas){
    videoElement = canvas;
    track();
}

and in my app:

// on receive canvas from other module
this._htracker.customTrack(canvas);

I also made some hacks around not sending an image before getting a response for the previous one. It could be useful to have a less-hacky way of bypassing the built-in getUserMedia handling.

Here is my demo: http://meemoo.org/iframework/#gist/5005786 Vid: http://vine.co/v/b6PntIHlaj6

auduno commented 11 years ago

Yes, I think it makes sense to add support for providing just a canvas as input. I'll look at adding it.

Meemoo looks very cool, by the way!

forresto commented 11 years ago

Thanks! And thanks for the great library... I knew that it was just a matter of time before somebody made a good one. Meemoo is all about tying these libraries together for quick experimentation and prototyping.