Пример #1
0
        public static KinectFrame FromFrames(ColorImageFrame colorImageFrame, DepthImageFrame depthImageFrame, SkeletonFrame skeletonFrame, bool compress = true)
        {
            KinectFrame kf = new KinectFrame();
            kf.Compressed = compress;

            if (colorImageFrame != null)
            {
                if (kf.Compressed)
                {
                    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                    encoder.QualityLevel = 85;
                    BitmapSource image = colorImageFrame.ToBitmapSource();
                    MemoryStream imageBytes = new MemoryStream(200 * 1024);
                    encoder.Frames.Add(BitmapFrame.Create(image));
                    encoder.Save(imageBytes);
                    kf._colorPixelData = imageBytes.ToArray();
                    imageBytes.Close();
                }
                else
                {
                    kf._colorPixelData = new byte[colorImageFrame.PixelDataLength];
                    colorImageFrame.CopyPixelDataTo(kf._colorPixelData);
                }
                kf.ColorFormat = colorImageFrame.Format;
                kf.ColorFrameNumber = colorImageFrame.FrameNumber;
                kf.ColorTimestamp = colorImageFrame.Timestamp;
            }

            if (depthImageFrame != null)
            {
                kf._depthPixelData = new short[depthImageFrame.PixelDataLength];
                depthImageFrame.CopyPixelDataTo(kf._depthPixelData);
                kf.DepthFormat = depthImageFrame.Format;
                kf.DepthFrameNumber = depthImageFrame.FrameNumber;
                kf.DepthTimestamp = depthImageFrame.Timestamp;
            }

            if (skeletonFrame != null)
            {
                kf._skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                skeletonFrame.CopySkeletonDataTo(kf._skeletons);
            }

            return kf;
        }
 private void SerializeVideoDepthPair(KinectFrame vdp)
 {
     CurrentFile.Append(vdp);
 }