Example #1
0
 private void BodyFrameReaderOnFrameArrived(object sender, KinectV2::Microsoft.Kinect.BodyFrameArrivedEventArgs bodyFrameArrivedEventArgs)
 {
     if (ReadBodyFrame(bodyFrameArrivedEventArgs))
     {
         UpdateSkeletons();
     }
 }
Example #2
0
 private void UpdateSkeleton(KinectV2::Microsoft.Kinect.Body body, ISkeleton newSkeleton)
 {
     foreach (KeyValuePair<JointType, KinectV2::Microsoft.Kinect.JointType> jointMapping in mapping)
     {
         var joint = new OrientedJoint
         {
             JointType = jointMapping.Key,
             Point = ToVec3(body.Joints[jointMapping.Value].Position),
             Orientation = ToVec4(body.JointOrientations[jointMapping.Value].Orientation),
             Valid = body.Joints[jointMapping.Value].TrackingState == KinectV2::Microsoft.Kinect.TrackingState.Tracked
         };
         newSkeleton.UpdateSkeleton(joint.JointType, joint);
     }
 }
Example #3
0
        private ISkeleton CreateSkeleton(KinectV2::Microsoft.Kinect.Body body)
        {
            var newSkeleton = new InMapSkeleton { ID = (uint) body.TrackingId };

            UpdateSkeleton(body, newSkeleton);

            return newSkeleton;
        }
Example #4
0
 /// <summary>
 /// Tos the vec4.
 /// </summary>
 /// <returns>The vec4.</returns>
 /// <param name="v">V.</param>
 private static Vector4 ToVec4(KinectV2::Microsoft.Kinect.Vector4 v)
 {
     return new Vector4(v.X, v.Y, v.Z, v.W);
 }
Example #5
0
 /// <summary>
 /// Absolutes to relative.
 /// </summary>
 /// <returns>The to relative.</returns>
 /// <param name="point">point.</param>
 private static Vector3 ToVec3(KinectV2::Microsoft.Kinect.CameraSpacePoint point)
 {
     return new Vector3(point.X, point.Y, point.Z) * 1000;
 }
Example #6
0
 private void KinectSensorOnIsAvailableChanged(object sender, KinectV2::Microsoft.Kinect.IsAvailableChangedEventArgs isAvailableChangedEventArgs)
 {
     Console.WriteLine("Kinect availability status changed to {0}." , isAvailableChangedEventArgs.IsAvailable);
 }
Example #7
0
        /// <summary>
        /// Tries to read the new frame and returns wether actual data was read.
        /// </summary>
        /// <param name="bodyFrameArrivedEventArgs"></param>
        /// <returns></returns>
        private bool ReadBodyFrame(KinectV2::Microsoft.Kinect.BodyFrameArrivedEventArgs bodyFrameArrivedEventArgs)
        {
            using (KinectV2::Microsoft.Kinect.BodyFrame bodyFrame = bodyFrameArrivedEventArgs.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (_bodyDataBuffer == null || _bodyDataBuffer.Length != bodyFrame.BodyCount)
                    {
                        _bodyDataBuffer = new KinectV2::Microsoft.Kinect.Body[bodyFrame.BodyCount];
                    }
                    
                    bodyFrame.GetAndRefreshBodyData(_bodyDataBuffer);
                    return true;
                }
            }

            return false;
        }