//clear screen of skeleton data void clearScene() { viewer.Clear(); depthviewer.Clear(); AngleLeftElbow.Clear(); AngleLeftShoulder.Clear(); AngleRightElbow.Clear(); AngleRightShoulder.Clear(); }
/// <summary> /// kinect frame reader /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e) { var reference = e.FrameReference.AcquireFrame(); //color using (var frame = reference.ColorFrameReference.AcquireFrame()) { if (frame != null) { if (viewer.Visualization == Visualization.Color) { viewer.Image = frame.ToBitmap(); } } } //Body using (var frame = reference.BodyFrameReference.AcquireFrame()) { if (frame != null) { var bodies = frame.Bodies(); _playersController.Update(bodies); Body body = bodies.Closest(); if (body != null) { //define the joints after skeleton has been tracked Head = body.Joints[JTHead]; Neck = body.Joints[JTNeck]; SpineShoulder = body.Joints[JTSpineShoulder]; SpineMid = body.Joints[JTSpineMid]; SpineBase = body.Joints[JTSpineBase]; ShoulderLeft = body.Joints[JTShoulderLeft]; ElbowLeft = body.Joints[JTElbowLeft]; WristLeft = body.Joints[JTWristLeft]; HandLeft = body.Joints[JTHandLeft]; ShoulderRight = body.Joints[JTShoulderRight]; ElbowRight = body.Joints[JTElbowRight]; WristRight = body.Joints[JTWristRight]; HandRight = body.Joints[JTHandRight]; AnkleLeft = body.Joints[JTAnkleLeft]; AnkleRight = body.Joints[JTAnkleRight]; FootLeft = body.Joints[JTFootLeft]; FootRight = body.Joints[JTFootRight]; HandTipLeft = body.Joints[JTHandTipLeft]; HandTipRight = body.Joints[JTHandTipRight]; HipLeft = body.Joints[JTHipLeft]; HipRight = body.Joints[JTHipRight]; KneeLeft = body.Joints[JTKneeLeft]; KneeRight = body.Joints[JTKneeRight]; ThumbLeft = body.Joints[JTThumbLeft]; ThumbRight = body.Joints[JTThumbRight]; if (body.IsTracked) { viewer.DrawBody(body); //Draw body skeleton view //apply angles to skeleton body view AngleLeftElbow.Update(ShoulderLeft, ElbowLeft, WristLeft, 100); AngleLeftShoulder.Update(SpineShoulder, ShoulderLeft, ElbowLeft, 100); AngleRightElbow.Update(WristRight, ElbowRight, ShoulderRight, 100); AngleRightShoulder.Update(ElbowRight, ShoulderRight, SpineShoulder, 100); //if rec button is clicked if (RecBtnClick == true) { TotalFrameCount++; //keep record of frame count /* * Write joint data to file * 1. Head, 2. Neck, 3. Spine_Shoulder,4. Spine_Mid, 5. Spine_Base, * 6. Shoulder_left, 7. Elbow_left, 8. Wrist_Left, 9. Hand_Left, 10. Hand_Tip_Left, 11. Thumb_Left, * 12. Shoulder_right, 13. Elbow_Right, 14. Wrist_Right, 15. Hand_Right, 16. Hand_Tip_Left, 17. Thumb Right, * 18. Hip_Left, 19. Knee_Left, 20. Ankle_Left, 21. Foot_Left, * 22. Hip_Right, 23. Knee_Right, 24. Ankle_Right, 25. Foot_Right */ File.Write(TotalFrameCount + ","); GetPositionCood(Head, File); GetPositionCood(Neck, File); GetPositionCood(SpineShoulder, File); GetPositionCood(SpineMid, File); GetPositionCood(SpineBase, File); GetPositionCood(ShoulderLeft, File); GetPositionCood(ElbowLeft, File); GetPositionCood(WristLeft, File); GetPositionCood(HandLeft, File); GetPositionCood(HandTipLeft, File); GetPositionCood(ThumbLeft, File); GetPositionCood(ShoulderRight, File); GetPositionCood(ElbowRight, File); GetPositionCood(WristRight, File); GetPositionCood(HandRight, File); GetPositionCood(HandTipRight, File); GetPositionCood(ThumbRight, File); GetPositionCood(HipLeft, File); GetPositionCood(KneeLeft, File); GetPositionCood(AnkleLeft, File); GetPositionCood(FootLeft, File); GetPositionCood(HipRight, File); GetPositionCood(KneeRight, File); GetPositionCood(AnkleRight, File); GetPositionCood(FootRight, File); File.Write("\r\n"); } } } } } //Depth using (var depthframe = reference.DepthFrameReference.AcquireFrame()) { if (depthframe != null) { depthviewer.Image = depthframe.ToBitmap(); } } }