Beispiel #1
0
        public void Record(SkeletonFrame frame)
        {
            // Header
            writer.Write((int)KinectRecordOptions.Skeletons);

            // Data
            var      time     = DateTime.Now;
            TimeSpan timeSpan = time.Subtract(referenceTime);

            referenceTime = time;
            writer.Write((long)timeSpan.TotalMilliseconds);
            writer.Write((int)frame.TrackingMode);
            writer.Write(frame.FloorClipPlane.Item1);
            writer.Write(frame.FloorClipPlane.Item2);
            writer.Write(frame.FloorClipPlane.Item3);
            writer.Write(frame.FloorClipPlane.Item4);

            writer.Write(frame.FrameNumber);

            // Skeletons
            Skeleton[] skeletons = frame.GetSkeletons();
            frame.CopySkeletonDataTo(skeletons);

            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(writer.BaseStream, skeletons);
        }
Beispiel #2
0
        void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (replay != null && !replay.IsFinished)
            {
                return;
            }

            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame == null)
                {
                    return;
                }

                if (recorder != null && ((recorder.Options & KinectRecordOptions.Skeletons) != 0))
                {
                    recorder.Record(frame);
                }


                Skeleton[] skeletons = frame.GetSkeletons();
                //frame.CopySkeletonDataTo(skeletons);


                if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                {
                    return;
                }
                //Debug.WriteLine("SKELETON TEST");
                //ProcessFrame(frame);
            }
        }
        void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (replay != null && !replay.IsFinished)
            {
                return;
            }

            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame == null)
                {
                    return;
                }

                if (recorder != null && ((recorder.Options & KinectRecordOptions.Skeletons) != 0))
                {
                    recorder.Record(frame);
                }

                frame.GetSkeletons(ref skeletons);

                if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                {
                    return;
                }

                ProcessFrame(frame);
            }
        }
 public ReplaySkeletonFrame(SkeletonFrame frame)
 {
     FloorClipPlane = frame.FloorClipPlane;
     FrameNumber    = frame.FrameNumber;
     TimeStamp      = frame.Timestamp;
     Skeletons      = frame.GetSkeletons();
     TrackingMode   = frame.TrackingMode;
 }
Beispiel #5
0
        void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame == null)
                {
                    return;
                }

                frame.GetSkeletons(ref skeletons);

                if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                {
                    return;
                }
            }
        }
Beispiel #6
0
        private void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame == null)
                {
                    return;
                }

                frame.GetSkeletons(ref skeletons);

                if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                {
                    return;
                }

                foreach (var skeleton in skeletons)
                {
                    if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                    {
                        continue;
                    }

                    foreach (Joint joint in skeleton.Joints)
                    {
                        if (joint.TrackingState != JointTrackingState.Tracked)
                        {
                            continue;
                        }

                        if (joint.JointType == JointType.HandRight)
                        {
                            MouseControllerAction action = MouseController.Current.SetHandPosition(kinectSensor, joint, skeleton);
                            BroadcastManager.GetBroadcastEngine().ScheduleForBroadcasting(action);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        void OnAllFramesReady(object sender, AllFramesReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                using (var colorFrame = e.OpenColorImageFrame())
                {
                    using (var depthFrame = e.OpenDepthImageFrame())
                    {
                        if (skeletonFrame == null)
                        {
                            return;
                        }

                        skeletonFrame.GetSkeletons(ref skeletons);

                        if (!skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                        {
                            ProcessFrame(colorFrame, depthFrame, skeletonFrame);
                        }
                    }
                }
            }
        }
        public void Record(SkeletonFrame frame)
        {
            writer.Write((int)FrameType.Skeletons);

            var timeSpan = DateTime.Now.Subtract(referenceTime);

            referenceTime = DateTime.Now;
            writer.Write((long)timeSpan.TotalMilliseconds);
            writer.Write((int)frame.TrackingMode);
            writer.Write(frame.FloorClipPlane.Item1);
            writer.Write(frame.FloorClipPlane.Item2);
            writer.Write(frame.FloorClipPlane.Item3);
            writer.Write(frame.FloorClipPlane.Item4);

            writer.Write(frame.FrameNumber);

            var skeletons = frame.GetSkeletons();

            frame.CopySkeletonDataTo(skeletons);

            var formatter = new BinaryFormatter();

            formatter.Serialize(writer.BaseStream, skeletons);
        }
        void KinectRuntimeSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (replay != null && !replay.IsFinished)
            {
                return;
            }


            if (fpsEnd == 1)
            {
                using (SkeletonFrame frame = e.OpenSkeletonFrame())
                {
                    if (frame == null)
                    {
                        return;
                    }

                    fpsEnd = SelectFPS();

                    Skeleton[] skeletons = new Skeleton[frame.SkeletonArrayLength];
                    frame.GetSkeletons(ref skeletons);
                    if (skeletons.Length != 0)
                    {
                        foreach (Skeleton skel in skeletons)
                        {
                            if (skel.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                if (BVHFile != null)
                                {
                                    if (BVHFile.IsRecording == true && BVHFile.IsInitializing == true)
                                    {
                                        BVHFile.Entry(skel);

                                        if (BVHFile.intializingCounter > initFrames)
                                        {
                                            BVHFile.StartWritingEntry();
                                        }
                                    }

                                    if (BVHFile.IsRecording == true && BVHFile.IsInitializing == false)
                                    {
                                        BVHFile.Motion(skel);
                                        Controls.ConsoleControl.LogEntries.Add(new LogEntry(DateTime.Now, "Recording..."));
                                    }
                                }
                            }
                        }
                    }


                    if (recorder != null && ((recorder.Options & KinectRecordOptions.Skeletons) != 0))
                    {
                        recorder.Record(frame);
                    }

                    if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
                    {
                        return;
                    }

                    ProcessFrame(frame);
                }
            }
            else
            {
                fpsEnd -= 1;
            }
        }