auduno / headtrackr

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

Inputting data from headTracking event into an array #25

Closed sean-wilk closed 10 years ago

sean-wilk commented 10 years ago

Hi,

Sorry if this is a stupid question, I am new to JavaScript and the like. I was wondering is there is a way to collect the data from an event (in this case I am trying to collect the z property from the headTracking event) and input it into an array?

I am trying to collect the data to work out the average of the heads z position over a given amount of time.

Let me know if anymore information is needed,

Cheers

Sean

auduno commented 10 years ago

I believe something like this should work:

var z_array = [];
document.addEventListener("headtrackingEvent", function( event ) {
  z_array.push(event.z);
});
sean-wilk commented 10 years ago

Thanks for the quick reply!

I had actually tried that already. Turns out after some digging I had made a stupid mistake elsewhere in my code, I'd just assumed I hadn't set the array up properly. Its all working fine now.

Also thank you for making such an amazing library.

auduno commented 10 years ago

Alright, cheers!