Open pciazynski opened 7 years ago
Very interesting, thanks for posting this - you've saved me hours of nerves :D . I was also calling stop method with no effect and continual tracking caused real performance drop of my website so it was very important for me to solve it... I assume that its bug, considering the fact that on official documentation page (https://trackingjs.com/docs.html#trackers) there's example for stopping of the tracker without timeout. What is more, even timeout of 1ms works for me so it is very strange.
I know this is over a year old, but I'm using trackingJS for a project, calling trackerTask.stop();
does nothing for me. Furthermore, trying the timeout hack mentioned above yields no different results.
Just to make sure... are you assigning reference to tracking.track
method into trackerTask
variable during initialization of tracking?
Thanks for the response, here's a snippet of the code @kudlohlavec
const tracker = new tracking.ObjectTracker('eye');
tracker.setInitialScale(4);
tracker.setStepSize(0.5);
tracker.setEdgesDensity(0);
const trackingTask = tracking.track('#video', tracker, { camera: true });
trackingTask.run();
// on tracker start, if we found eyes (event.data)
tracker.on('track', function(event) {
if (debug) console.log(event);
setTimeout(() => {
trackingTask.stop();
}, 5500);
});
Everything works except trackingTask.stop()
.
Ive tried your snippet and stop
method works as it should be. However I was trying it with 'face' object tracker.
Try if the stop method is not working also in the face tracker for you. If it will be working it tells that the workaround does not work for eye tracker, otherwise there will be something wrong with the version of tracking.js that you are using (i was doing some changes to it but i dont recall that it was something crucial, also diff against official version from trackingjs.com does not yield anything regarding the stop method)
thanks for looking into this @kudlohlavec i'll be sure to look into that later day when I have the time.
From what I can see here:
tracker.on('track', ... // This line itself will never allow the timeout to initialise once. Because on every 'track' event the setTimeout is instantiated.
It is possible to stop tracking in track event without timeout? I use colour tracker to control web application. When I move color over button I want to stop tracking, but unfortunately tracking.js is still running even when trackerTask.inRunning() shows false. When I add 100 ms timeout everything works fine and tracking.js stops tracking.
Tracker doesn't stop:
Work as expected - tracker successfully stops:
It is a bug? Is there a better solution than adding timeout? Any help appreciated :)