auduno / headtrackr

Javascript library for headtracking via webcam and WebRTC/getUserMedia
3.69k stars 504 forks source link

Overriding mediaStream Using altVideo #35

Closed abaziz closed 9 years ago

abaziz commented 9 years ago

I have tried the altVideo parameter by pointing it to an arbitrary MP4 video. Currently its purpose seems to be to supply an alternative video with directions if webcam fails.

Our need is to run the headtracker as it would normally run with a mediaStream, but using a pre-recorded video where a person has captured her head movements. We need to do this to run some test cases on headtracker. Is this something that can be achieved using the altVideo parameter or another option in headtracker js?

auduno commented 9 years ago

Yes, you can simply pass the video in as regular video element to clmtrackr. Clmtrackr will use whatever video element is passed to it for tracking, and whether the video is from webcamera or from file doesn't make any difference. The altVideo parameter is just for setting up a fallback video in cases where webcamera is not available, so you shouldn't use that.

MuhammadIkram commented 9 years ago

Can you please give me some examples to get Headtracking by using pre-recorded video. We spent time on this but could not able to get Headtracking with video.

MuhammadIkram commented 9 years ago

We need to do this task urgently. Please let's know about it. I shall be very thankful to you.

auduno commented 9 years ago

Hi, in my last response I seemed to have mixed up clmtrackr and headtrackr, however, you can use headtrackr with pre-recorded video as well, you just have to set the parameter "setupVideo" to false when initializing headtrackr. So an example with pre-recorded video would look like this:

<canvas id="inputCanvas" width="320" height="240" style="display:none"></canvas>
<video id="inputVideo" src="./someVideo.mp4" autoplay loop></video>
<script type="text/javascript">
  var videoInput = document.getElementById('inputVideo');
  var canvasInput = document.getElementById('inputCanvas');

  var htracker = new headtrackr.Tracker();
  htracker.init(videoInput, canvasInput, false);
  htracker.start();
</script>

Let me know if that works!

abaziz commented 9 years ago

@auduno unfortunately this hasn't worked at our end. Is there a sample available which we can look at?