private void ReadSkeletonFile()
 {
     using (FileStream fs = File.Open(SkeletonFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     using (BufferedStream bs = new BufferedStream(fs))
     {
         KinectReplay reader = new KinectReplay(bs);
         reader.SkeletonFrameReady += parent.ReplayFrameReady;
         reader.Start();
     }
 }
 //The replay part of the application does the same thing—it retrieves a 
 //stream for the KinectReplay class and uses three intermediate events to reproduce the behavior of the original Kinect events:
 private void replayButton_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog openFileDialog = new OpenFileDialog { Title = "Select filename", Filter = "Replay files|*.replay" };
     if (openFileDialog.ShowDialog() == true)
     {
         if (replay != null)
         {
             replay.SkeletonFrameReady -= replay_SkeletonFrameReady;
             replay.ColorImageFrameReady -= replay_ColorImageFrameReady;
             replay.Stop();
         }
         Stream recordStream = File.OpenRead(openFileDialog.FileName);
         replay = new KinectReplay(recordStream);
         replay.SkeletonFrameReady += replay_SkeletonFrameReady;
         replay.ColorImageFrameReady += replay_ColorImageFrameReady;
         replay.DepthImageFrameReady += replay_DepthImageFrameReady;
         replay.Start();
     }
 }
        public void StartReplaying(string fileId)
        {
            StopRecording();

            if (null != kinectReplay && kinectReplay.Started)
            {
                kinectReplay.Dispose();
            }

            if (null != SkeletonEventListener)
            {
                foreach (EventHandler<ReplaySkeletonFrameReadyEventArgs> eventHandler
                    in SkeletonEventListener)
                {
                    kinectReplay.SkeletonFrameReady -= eventHandler;
                }
            }

            if (null != ColorEventListener)
            {
                foreach (EventHandler<ReplayColorImageFrameReadyEventArgs> eventHandler
                    in ColorEventListener)
                {
                    kinectReplay.ColorImageFrameReady -= eventHandler;
                }
            }

            replayStream = new FileStream(
                filesUsed[fileId],
                FileMode.Open,
                FileAccess.Read
            );

            kinectReplay = new KinectReplay(replayStream);

            if (null != SkeletonEventListener)
            {
                foreach (EventHandler<ReplaySkeletonFrameReadyEventArgs> eventHandler
                    in SkeletonEventListener)
                {
                    kinectReplay.SkeletonFrameReady += eventHandler;
                }
            }

            if (null != ColorEventListener)
            {
                foreach (EventHandler<ReplayColorImageFrameReadyEventArgs> eventHandler
                    in ColorEventListener)
                {
                    kinectReplay.ColorImageFrameReady += eventHandler;
                }
            }

            kinectReplay.Start();
            Status = Service.RecordingManagerStatus.Replaying;
        }
        public void Initialize()
        {
            string fakeFile = fileLocation + Guid.NewGuid().ToString();
            recordingStream = new FileStream(fakeFile, FileMode.OpenOrCreate);
            kinectRecorder = new KinectRecorder(0, recordingStream);

            replayStream = new FileStream(fakeFile + "1", FileMode.OpenOrCreate);
            kinectReplay = new KinectReplay(replayStream);
        }
Beispiel #5
0
        /// <summary>
        /// Start playing selected scene.
        /// </summary>
        private void Play()
        {
            if (this.KinectReplay == null)
            {
                if (this.ReplayStream == null)
                {
                    this.ReplayStream = new FileStream(this.Preferences.KinectDataFile, FileMode.Open);
                }

                this.KinectReplay = new KinectReplay(this.ReplayStream);
                this.KinectReplay.ColorImageFrameReady += new EventHandler<ReplayColorImageFrameReadyEventArgs>(this.ReplayColorImageFrameReady);
                this.KinectReplay.SkeletonFrameReady += new EventHandler<ReplaySkeletonFrameReadyEventArgs>(this.ReplaySkeletonFrameReady);

                this.KinectReplay.Start();
                this.Mode = ControlMode.Replay;
            }
        }