Closed auduno closed 9 years ago
+1 for this. Is it also possible to maybe add Addy Osmani's GetUserMedia shim (https://github.com/addyosmani/getUserMedia.js) ?
I don't think I'll add the shim in headtrackr, but I was thinking of creating an option for providing your own videoElement "as is", i.e. without setting up getUserMedia, so you could then set up video with the getUserMedia shim first and provide the videoelement to headtrackr. I'll have to look at the complications wrt the rest of the code of doing this, though.
Fair enough. It might even be a better idea. thanks!
Alright, I've now added a function to stop the mediastream, so you can now call
htracker.stopStream()
on your instance of headtrackr to stop streaming from the webcam. You can also get the mediastream object from the htracker.stream property. I've also added the boolean parameter setupVideo to init(), so you have the possibility to use the videoElement "as is" by calling:
htracker.init(videoElement, canvasElement, false)
In the case you try to use the getUserMedia shim mentioned, and it's falling back to flash, I think you have to copy the video from the flash element onto a canvas (every 1/24 second or so) and pass that on to init() as the video element instead.
brilliant. thanks.
Do you stop the headtracker (i.e. call htracker.stop() ) as well when you stop the stream? Or do you just call htracker.stopStream() ?
huh, that's weird. It works for me. Do you see any error messages in console?
I can't reproduce this. Could you share the code you're using or a mockup on dropbox or somewhere?
@auduno this is working fine at our end now, the error in the previous message by Raees ("Cannot read property 'getTrackingObject' of undefined") was due to some issue in our code. Many thanks for adding this functionality.
It is not possible to close the getUserMedia mediastream opened by headtrackr on init(), since the mediastream pointer is discarded after initialization. The solution is to not discard the pointer and possibly add a method to close/stop the stream.