示例#1
0
        public Recording(string mappingParamsPath, string timingPath, string depthPath, DepthFormat dFormat,
                         string colourPath, ColourFormat cFormat, string calibrationPath) : this()
        {
            // open mapping data
            var fMapping = new FileStream(mappingParamsPath, FileMode.Open);

            this.mappingParams = new byte[fMapping.Length];
            fMapping.Read(this.mappingParams, 0, this.mappingParams.Length);
            fMapping.Close();

            // get image file streams ready
            this.fDepth  = new FileStream(depthPath, FileMode.Open);
            this.fColour = new FileStream(colourPath, FileMode.Open);

            // deserialise calibration if required
            if (calibrationPath == null)
            {
                this.IsCalibratedRecording = false;
            }
            else
            {
                this.calibration           = Calibration.CreateFromFile(calibrationPath);
                this.IsCalibratedRecording = true;
            }


            // read and convert timing data to fractional seconds
            var fTiming      = new FileStream(timingPath, FileMode.Open);
            var timingReader = new BinaryReader(fTiming);

            this.Timestamps = new float[fTiming.Length / sizeof(Single)];
            for (int i = 0; i < this.Timestamps.Length; i++)
            {
                this.Timestamps[i] = timingReader.ReadSingle();
            }
            fTiming.Close();

            // set other recording properties
            this.cFrameSizeBytes  = FormatConvertor.ByteDataLength(cFormat);
            this.dFrameSizeShorts = FormatConvertor.PixelDataLength(dFormat);
            this.NumberOfFrames   = (int)this.fDepth.Length / FormatConvertor.ByteDataLength(dFormat);
        }