eduardolundgren / tracking.js

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

limiting object tracking scan to selected area? #360

Closed BhavitChhatralia closed 5 years ago

BhavitChhatralia commented 5 years ago

Trying to limit the area of object tracking tracker so the select tracker only scans in a specified place e.g. a persons mouth.

A place holder is put in place for the person to place their face within a selected area, once within this place holder i want the object tracker to only scan a predefined area to limit the hardware stress, and prevent fps from dropping, as currently using custom haar data the fps is at 1-2.

BhavitChhatralia commented 5 years ago

addtionally is it possible to select the object size for the object tracker?

BhavitChhatralia commented 5 years ago

Alternatively is there a way to crop the camera stream, send this to the object tracker, track objects on the cropped stream and then place rects on the canvas of the camera stream?

BhavitChhatralia commented 5 years ago

okay so have limitied tracking to a selected area, however now i'm having a issue with getting the violajones rect array return drawn in the correct position.

BhavitChhatralia commented 5 years ago

tracking.trackCanvasInternal_ = function(element, tracker) { var width = element.width; var height = element.height; var context = element.getContext('2d'); if(tracker.classifiers[0].length===33871){ var imageData = context.getImageData((canvas.width/2 - (500/2)), (canvas.height/2 - (600/2)), 500, 600); tracker.track(imageData.data,500,600);//(canvas.width/2 - (500/2)),(canvas.height/2 - (600/2))); //tracker.track(imageData.data,width,height); } var imageData = context.getImageData((canvas.width/2 - (300/2)), 500, 300, 120); //0, 0, width, height tracker.track(imageData.data, 300, 120);//300,120 deafult is width,height }; For anyone that's wondering how, this is the modified code in the tracking.js line 187 to 198

BhavitChhatralia commented 5 years ago

SOLVED!