Open icaromh opened 9 years ago
found the solutions yet?
@sushant12, I did tracking.stopUserMedia() #128 but it isn't merged yet
Here: https://github.com/icaromh/tracking.js/blob/turn-off-camera/build/tracking.js#L84
@icaromh Your solution is working? how to call you function.? Thanks
@M-Husein I've abandoned the project that has used this lib. But you can look here
@icaromh Thanks for reply, I see that. But I don't know how to use or call your function? :)
Please help me.
@M-Husein, I think that is something like:
window.onload = function() {
// as tracking is a global variable, you can just call it anytime after initialize
window.setTimeout(function(){
tracking.stopUserMedia();
}, 1000 * 10)
var video = document.getElementById('video');
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var tracker = new tracking.ObjectTracker('face');
tracker.setInitialScale(4);
tracker.setStepSize(2);
tracker.setEdgesDensity(0.1);
// You initialize UserMedia here
tracking.track('#video', tracker, { camera: true });
tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);
event.data.forEach(function(rect) {
context.strokeStyle = '#a64ceb';
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
context.font = '11px Helvetica';
context.fillStyle = "#fff";
context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);
context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);
});
});
var gui = new dat.GUI();
gui.add(tracker, 'edgesDensity', 0.1, 0.5).step(0.01);
gui.add(tracker, 'initialScale', 1.0, 10.0).step(0.1);
gui.add(tracker, 'stepSize', 1, 5).step(0.1);
};
I've not tested this
Thanks for reply again :) I have try your guide, but not success & I get error in console like this:
I almost gave up, please help me :(
Now, I can stop video & stream, working good. ;) @icaromh, Thanks Dude
tracking.stopUserMedia = function(){
if(tracking.localStream){
tracking.localStream.stop();
}
};
is deprecated and should be changed as
tracking.stopUserMedia = function(){
if(tracking.localStream){
tracking.localStream.getVideoTracks()[0].stop();
}
};
With the latest version available, only this helped me:
setTimeout(function () { trackingTask.stop(); video.pause(); video.srcObject.getVideoTracks()[0].stop(); }, 100);
The following works for me in newest Chrome and the master branch. Find the video element that was referenced in tracking.track and call elm.srcObject.getTracks()[0].stop();
Hello, Is there any solution for this issue?
I also tried all solutions above but seem they didn't work. I cannot stop tracking.js on accessing my webcam.
I have tried videoElement.srcObject.getTracks()[0].stop()
but it doesn't work, the video element doesn't have 'srcObject' attribute in latest version.
So i modified the source code of tracking.js like this:
then i can call tracking.stream.getTracks()[0].stop();
to turn off camera, it works well.
you can also add a srcObject
attribute for video element, then call videoElement.srcObject.getTracks()[0].stop()
Hi :dancer:
There is no way to turn off the camera? I tried with de trackerTask.stop(), but this just stopped the tracker and not the streaming.
Looking at the code in initUserMedia_() the stream var isn't referenced.
Maybe if insert a stopUserMedia() or something like that.