none
Obtaining and Saving Head Tracking Data RRS feed

  • Question

  • I am currently trying to modify the skeletal viewer application provided in the SDK to save only the head joint data to a file. The documentation in the SDK doesn't go into enough depth for me to understand how to accomplish this goal.  I can't quite figure out how to just get the head x-y-z data. I want to get the head tracking data after it has been filtered. 

    The main point of the project is to compare this data to the data from virtual reality glasses I have.

    I'm new to c++/c# so any insight into how I could go about extracting this data would be very helpful. 

     

     

    Wednesday, February 1, 2012 1:37 AM

Answers

  • A few refinements:

                if (_skeletons == null || _skeletons.Length != _sensor.SkeletonStream.FrameSkeletonArrayLength)
                {
                    _skeletons = new Skeleton[_sensor.SkeletonStream.FrameSkeletonArrayLength];
                }
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    skeletonFrame.CopySkeletonDataTo(_skeletons);
                    foreach (Skeleton skeleton in _skeletons)
                    {
                        if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                        {
                            Joint head = skeleton.Joints[JointType.Head];
                            if (head.TrackingState == JointTrackingState.Tracked)
                            {
                                //head.Position.X
                                //head.Position.Y
                                //head.Position.Z
                            }
                        }
                    }
                }
    

    John
    K4W Dev

     

    Thursday, February 2, 2012 10:32 PM

All replies

  • If you use the event model, during the AllFramesReady or SkeletonFrameReady, the returned arg(e) you can get the position using the following...

    using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
    {
        foreach (Skeleton data in skeletonData)
        {
            if (data.TrackingState == SkeletonTrackingState.Tracked)
            {
                foreach (Joint joint in data.Joints)
                {
                    switch (joint.JointType)
                    {
                        case JointType.Head:
                            //joint.Position.X
                            //joint.Position.Y
                            //joint.Position.Z
                            break;
                    }

                }
            }
        }
    }

     

    Wednesday, February 1, 2012 11:29 PM
  • A few refinements:

                if (_skeletons == null || _skeletons.Length != _sensor.SkeletonStream.FrameSkeletonArrayLength)
                {
                    _skeletons = new Skeleton[_sensor.SkeletonStream.FrameSkeletonArrayLength];
                }
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    skeletonFrame.CopySkeletonDataTo(_skeletons);
                    foreach (Skeleton skeleton in _skeletons)
                    {
                        if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                        {
                            Joint head = skeleton.Joints[JointType.Head];
                            if (head.TrackingState == JointTrackingState.Tracked)
                            {
                                //head.Position.X
                                //head.Position.Y
                                //head.Position.Z
                            }
                        }
                    }
                }
    

    John
    K4W Dev

     

    Thursday, February 2, 2012 10:32 PM
  • Thank you for the replies,

    I have been able to obtain the data for the head. I was wondering though what kind of data acquisition rates I should be seeing. I'm saving the original position and saving the change from that position. The save function occurs each time a skeletalreadyframe, or whatever the event is called, is fired. I'm also displaying a relative head tracking, i.e. with circles like sdk examples. I don't know if that's effecting my FPS or not.

    On average the program is saving 20 data points per second. I was wondering if that was normal or if I should be seeing a little higher around 30.

    Thank you

    Thursday, February 23, 2012 9:38 PM
  • If you're writing more than 10 MB/s then that might slow you down, but you're likely writing no more than about 1 KB/s. So it shouldn't slow you don't, but that doesn't mean it isn't. If you're doing something like opening and closing the file every pass then that's a lot of overhead and that could slow you down. If you're just opening and closing it once, writing data each pass and not flushing the buffers to disk then it shouldn't be an issue.

    Saturday, February 25, 2012 11:54 PM
  • I am just opening it and closing it once, writing it each time a skeleton event is fired, but I do not know what flushing the buffers to disk means. Would saving the data points into an linked list and then writing to the file after the data acquisition has stopped help acquisition rates?
    Wednesday, February 29, 2012 2:00 AM