void myBodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e) { if (this.IsPaused) { return; } PreposeGesturesFrame retFrame = null; PreposeGesturesFrameArrivedEventArgs upArgs = new PreposeGesturesFrameArrivedEventArgs(); using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame()) { if (bodyFrame != null) { // Perform the gesture matching on this frame var z3body = new Z3Body(); bodyFrame.GetAndRefreshBodyData(this.bodies); foreach (var body in this.bodies) { if (body.TrackingId == this.mySource.TrackingId) { // We are at the correct body - go ahead and feed it to the BodyMatcher IReadOnlyDictionary <Microsoft.Kinect.JointType, Joint> joints = body.Joints; z3body = Z3KinectConverter.CreateZ3Body(joints); var result = this.PreposeGesturesFrameSource.myMatcher.TestBody(z3body); // Fill in the gesture results for this frame retFrame = new PreposeGesturesFrame(); retFrame.results = result; break; } } } } // TODO: revisit the way the PreposeGesturesFrameReference is implemented to avoid keeping around massive amounts of frames PreposeGesturesFrameReference retFrameReference = new PreposeGesturesFrameReference(retFrame); upArgs.FrameReference = retFrameReference; // Signal that we have a new PreposeGesturesFrame arrived FrameArrived(this, upArgs); }
public PreposeGesturesFrameReference(PreposeGesturesFrame frame) { myFrame = frame; }
void myBodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e) { if (this.IsPaused) return; PreposeGesturesFrame retFrame = null; PreposeGesturesFrameArrivedEventArgs upArgs = new PreposeGesturesFrameArrivedEventArgs(); using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame()) { if (bodyFrame != null) { // Perform the gesture matching on this frame var z3body = new Z3Body(); bodyFrame.GetAndRefreshBodyData(this.bodies); foreach (var body in this.bodies) { if (body.TrackingId == this.mySource.TrackingId) { // We are at the correct body - go ahead and feed it to the BodyMatcher IReadOnlyDictionary<Microsoft.Kinect.JointType, Joint> joints = body.Joints; z3body = Z3KinectConverter.CreateZ3Body(joints); var result = this.PreposeGesturesFrameSource.myMatcher.TestBody(z3body); // Fill in the gesture results for this frame retFrame = new PreposeGesturesFrame(result, this.mySource, body.TrackingId, bodyFrame.RelativeTime); break; } } } } // TODO: revisit the way the PreposeGesturesFrameReference is implemented to avoid keeping around massive amounts of frames PreposeGesturesFrameReference retFrameReference = new PreposeGesturesFrameReference(retFrame); upArgs.FrameReference = retFrameReference; // Signal that we have a new PreposeGesturesFrame arrived FrameArrived(this, upArgs); }