eduardolundgren / tracking.js

A modern approach for Computer Vision on the web
http://trackingjs.com
Other
9.44k stars 1.45k forks source link

Perf Guidelines #96

Closed transitive-bullshit closed 10 years ago

transitive-bullshit commented 10 years ago

I'm trying to use tracking.js with getUserMedia and a face object tracker and am experiencing unusable framerates.

The source video is 640x480, and I'm using the following tracker options:

      tracker.setInitialScale(4)
      tracker.setStepSize(2)
      tracker.setEdgesDensity(0.1)

My question is: can any of the tracker options be used to affect perf vs accuracy, or is the largest factor affecting perf the size of the source video?

eduardolundgren commented 10 years ago

Those options can improve performance, specially the step size and initial scale. ViolaJones is a good object detection algorithm, although for large images 640x480 it can reach low frame rates.

Two features from our roadmap that will speed up performance for cases like that: 1- Create some sort of ThreadableTracker abstract class that splits process into different Workers. 2- Use optical flow to predict the movement in order to not require processing every frame using ViolaJones.

A workaround for now is to write the 640x480 video into a smaller hidden canvas, and this canvas is the element being track, when track event fires with rectangles you can proportionally projects the coordinates into the larger visible video.

transitive-bullshit commented 10 years ago

Thanks for the quick response. For now, I'm going with the intermediate canvas approach :+1:

eduardolundgren commented 10 years ago

Sounds good, closing this for now.

eduardolundgren commented 10 years ago

Relates to #99.