Ejemplo n.º 1
0
        public KinectReplay(Stream stream)
        {
            this.stream            = stream; reader = new BinaryReader(stream);
            synchronizationContext = SynchronizationContext.Current;
            KinectRecordOptions options = (KinectRecordOptions)reader.ReadInt32();

            if ((options & KinectRecordOptions.Color) != 0)
            {
                colorReplay = new ReplaySystem <ReplayColorImageFrame>();
            }
            if ((options & KinectRecordOptions.Depth) != 0)
            {
                depthReplay = new ReplaySystem <ReplayDepthImageFrame>();
            }
            if ((options & KinectRecordOptions.Skeletons) != 0)
            {
                skeletonReplay = new ReplaySystem <ReplaySkeletonFrame>();
            }
            while (reader.BaseStream.Position != reader.BaseStream.Length)
            {
                KinectRecordOptions header = (KinectRecordOptions)reader.ReadInt32(); switch (header)
                {
                case KinectRecordOptions.Color:                     colorReplay.AddFrame(reader); break;

                case KinectRecordOptions.Depth:                     depthReplay.AddFrame(reader); break;

                case KinectRecordOptions.Skeletons:                     skeletonReplay.AddFrame(reader); break;
                }
            }
        }
Ejemplo n.º 2
0
        public KinectRecorder(KinectRecordOptions options, string targetFileName, KinectSensor sensor)
        {
            Options        = options;
            recordFileName = targetFileName;
            _sensor        = sensor;
            var stream = File.Create(targetFileName);

            recordStream = stream;
            writer       = new BinaryWriter(recordStream);

            writer.Write((int)Options);
            var colorToDepthRelationalParameters = sensor.CoordinateMapper.ColorToDepthRelationalParameters.ToArray();

            writer.Write(colorToDepthRelationalParameters.Length);
            writer.Write(colorToDepthRelationalParameters);

            if ((Options & KinectRecordOptions.Frames) != 0)
            {
                colorRecoder     = new ColorRecorder(writer);
                depthRecorder    = new DepthRecorder(writer);
                skeletonRecorder = new SkeletonRecorder(writer);
            }

            if ((Options & KinectRecordOptions.Audio) != 0)
            {
                audioRecorder = new AudioRecorder();
            }

            previousFlushDate = DateTime.Now;
        }
Ejemplo n.º 3
0
        // Ctr
        public KinectRecorder(KinectRecordOptions options, CoordinateMapper mapper,
        float colorFocalLength, float depthFocalLength, Stream stream)
        {
            Options = options;

              recordStream = stream;
              writer = new BinaryWriter(recordStream);

              var coordParams = mapper.ColorToDepthRelationalParameters;
              int count = coordParams.Count;
              byte[] array = new byte[count];
              coordParams.CopyTo(array, 0);
              writer.Write(count);
              writer.Write(array);
              writer.Write(colorFocalLength);
              writer.Write(depthFocalLength);

              writer.Write((int)Options);

              if ((Options & KinectRecordOptions.Color) != 0) {
            colorRecoder = new ColorRecorder(writer);
              }
              if ((Options & KinectRecordOptions.Depth) != 0) {
            depthRecorder = new DepthRecorder(writer);
              }
              if ((Options & KinectRecordOptions.Skeletons) != 0) {
            skeletonRecorder = new SkeletonRecorder(writer);
              }

              previousFlushDate = DateTime.Now;
        }
Ejemplo n.º 4
0
        public KinectRecord(KinectRecordOptions options, Stream stream)
        {
            Options = options;

            recordStream = stream;

            writer = new BinaryWriter(recordStream);

            writer.Write((int)Options);

            if ((Options & KinectRecordOptions.Color) != 0)
            {
                colorRecoder = new ColorRecorder(writer);
            }

            if ((Options & KinectRecordOptions.Depth) != 0)
            {
                depthRecorder = new DepthRecorder(writer);
            }

            if ((Options & KinectRecordOptions.Skeletons) != 0)
            {
                skeletonRecorder = new SkeletonRecorder(writer);
            }
        }
Ejemplo n.º 5
0
        // Ctr
        public KinectRecorder(KinectRecordOptions options, CoordinateMapper mapper,
                              float colorFocalLength, float depthFocalLength, Stream stream)
        {
            Options = options;

            recordStream = stream;
            writer       = new BinaryWriter(recordStream);

            var coordParams = mapper.ColorToDepthRelationalParameters;
            int count       = coordParams.Count;

            byte[] array = new byte[count];
            coordParams.CopyTo(array, 0);
            writer.Write(count);
            writer.Write(array);
            writer.Write(colorFocalLength);
            writer.Write(depthFocalLength);

            writer.Write((int)Options);

            if ((Options & KinectRecordOptions.Color) != 0)
            {
                colorRecoder = new ColorRecorder(writer);
            }
            if ((Options & KinectRecordOptions.Depth) != 0)
            {
                depthRecorder = new DepthRecorder(writer);
            }
            if ((Options & KinectRecordOptions.Skeletons) != 0)
            {
                skeletonRecorder = new SkeletonRecorder(writer);
            }

            previousFlushDate = DateTime.Now;
        }
        public KinectReplay(Stream stream)
        {
            this.stream = stream;
            reader      = new BinaryReader(stream);

            synchronizationContext = SynchronizationContext.Current;

            KinectRecordOptions options = (KinectRecordOptions)reader.ReadInt32();

            if ((options & KinectRecordOptions.Color) != 0)
            {
                colorReplay = new ReplaySystem <ReplayColorImageFrame>();
            }
            //if ((options & KinectRecordOptions.Depth) != 0)
            //{
            //    depthReplay = new ReplaySystem<ReplayDepthImageFrame>();
            //}
            //if ((options & KinectRecordOptions.Skeletons) != 0)
            //{
            //    skeletonReplay = new ReplaySystem<ReplaySkeletonFrame>();
            //}

            while (reader.BaseStream.Position + 4 < reader.BaseStream.Length)
            {
                if (reader.BaseStream.Position > 67580000)
                {
                    Console.WriteLine("Position: " + reader.BaseStream.Position + " of " + reader.BaseStream.Length);
                }

                KinectRecordOptions header = (KinectRecordOptions)reader.ReadInt32();
                switch (header)
                {
                case KinectRecordOptions.Color:
                    colorReplay.AddFrame(reader);
                    break;
                    //case KinectRecordOptions.Depth:
                    //    depthReplay.AddFrame(reader);
                    //    break;
                    //case KinectRecordOptions.Skeletons:
                    //    skeletonReplay.AddFrame(reader);
                    //    break;
                }
            }
        }
Ejemplo n.º 7
0
        public static List <Skeleton> FromStream(Stream stream)
        {
            List <Skeleton> skeletonList = new List <Skeleton>();

            // Start reading the stream.
            BinaryReader reader = new BinaryReader(stream);

            // Check if the stream contains skeletons.
            KinectRecordOptions options = (KinectRecordOptions)reader.ReadInt32();

            if ((options & KinectRecordOptions.Skeletons) == 0)
            {
                throw new System.ArgumentException("The stream does not contain skeleton frames.");
            }

            while (reader.BaseStream.Position != reader.BaseStream.Length)
            {
                KinectRecordOptions header = (KinectRecordOptions)reader.ReadInt32();

                if (header != KinectRecordOptions.Skeletons)
                {
                    continue;
                }

                // Unneeded information for the converter cause.
                long timeStamp = reader.ReadInt64();
                SkeletonTrackingMode trackingMode = (SkeletonTrackingMode)reader.ReadInt32();
                Tuple <float, float, float, float> floorClipPlane = new Tuple <float, float, float, float>(
                    reader.ReadSingle(), reader.ReadSingle(),
                    reader.ReadSingle(), reader.ReadSingle()
                    );
                int frameNumber = reader.ReadInt32();

                BinaryFormatter formatter = new BinaryFormatter();
                Skeleton[]      skeletons = (Skeleton[])formatter.Deserialize(reader.BaseStream);

                // Append all skeletons to the list.
                skeletonList.AddRange(skeletons);
            }

            return(skeletonList);
        }
Ejemplo n.º 8
0
        // Constructor
        public KinectRecorder(KinectRecordOptions options, Stream stream)
        {
            Options = options;
                recordStream = stream;
                writer = new BinaryWriter(recordStream);
                writer.Write((int)Options);

                if ((Options & KinectRecordOptions.Color) != 0)
                {
                    colorRecoder = new ColorRecorder(writer);
                }

                if ((Options & KinectRecordOptions.Skeletons) != 0)
                {
                    skeletonRecorder = new SkeletonRecorder(writer);
                }

                if ((Options & KinectRecordOptions.ReplayFrame) != 0)
                {
                    replayrecorder = new ReplayFrameRecorder(writer);
                }
        }
Ejemplo n.º 9
0
        private void StartRecording(KinectRecordOptions options)
        {
            StopReplaying();
            StopRecording();

            string fileId = Guid.NewGuid().ToString();

            FilesUsed.Add(fileId, _fileLocation + fileId);

            if (null != KinectRecorder && KinectRecorder.IsRecording)
            {
                KinectRecorder.Stop();
            }

            _recordingStream = new FileStream(
                FilesUsed[fileId],
                FileMode.OpenOrCreate
                );

            if (null != DataRecorder && DataRecorder.IsRecording)
            {
                DataRecorder.Stop();
            }

            _dataOutStream = new FileStream(
                FilesUsed[fileId] + "_data",
                FileMode.OpenOrCreate
                );

            KinectRecorder = new KinectRecorder(options, _recordingStream);
            KinectRecorder.Start();

            DataRecorder = new PostProcessedRecorder(_dataOutStream);
            DataRecorder.Start();

            Status = Service.RecordingManagerStatus.Recording;
            OnRecordingStatusChanged(new RecordingStatusChangedEventArg(fileId));
        }
Ejemplo n.º 10
0
        internal override void CreateFromReader(BinaryReader reader)
        {
            for (Int32 i = 0; i < 3; i++)
            {
                KinectRecordOptions header = (KinectRecordOptions)reader.ReadInt32();
                switch (header)
                {
                case KinectRecordOptions.Skeletons:
                    SkeletonFrame.CreateFromReader(reader);
                    break;

                case KinectRecordOptions.Depth:
                    DepthImageFrame.CreateFromReader(reader);
                    TimeStamp   = DepthImageFrame.TimeStamp;
                    FrameNumber = DepthImageFrame.FrameNumber;
                    break;

                case KinectRecordOptions.Color:
                    ColorImageFrame.CreateFromReader(reader);
                    return;
                }
            }
        }
Ejemplo n.º 11
0
        // Ctr
        public KinectRecorder(KinectRecordOptions options, Stream stream)
        {
            Options = options;

            recordStream = stream;
            writer = new BinaryWriter(recordStream);

            writer.Write((int)Options);

            if ((Options & KinectRecordOptions.Color) != 0)
            {
                colorRecoder = new ColorRecorder(writer);
            }
            if ((Options & KinectRecordOptions.Depth) != 0)
            {
                depthRecorder = new DepthRecorder(writer);
            }
            if ((Options & KinectRecordOptions.Skeletons) != 0)
            {
                skeletonRecorder = new SkeletonRecorder(writer);
            }

            previousFlushDate = DateTime.Now;
        }
Ejemplo n.º 12
0
        private void StartRecording(KinectRecordOptions options)
        {
            StopReplaying();
            StopRecording();

            string fileId = Guid.NewGuid().ToString();
            filesUsed.Add(fileId, fileLocation + fileId);

            if (null != kinectRecorder && kinectRecorder.IsRecording)
            {
                kinectRecorder.Stop();
            }

            recordingStream = new FileStream(
                filesUsed[fileId],
                FileMode.OpenOrCreate
            );

            kinectRecorder = new KinectRecorder(options, recordingStream);
            kinectRecorder.Start();
            Status = Service.RecordingManagerStatus.Recording;
            OnRecordingStatusChanged(new RecordingStatusChangedEventArg(fileId));
        }
Ejemplo n.º 13
0
 bool IsValidOptions(KinectRecordOptions options)
 {
     return options.Equals(KinectRecordOptions.Color | KinectRecordOptions.Depth |
                     KinectRecordOptions.Skeletons);
 }
Ejemplo n.º 14
0
 bool IsValidOptions(KinectRecordOptions options)
 {
     return(options.Equals(KinectRecordOptions.Color | KinectRecordOptions.Depth |
                           KinectRecordOptions.Skeletons));
 }