• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Kinect.DepthImageFrame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Kinect.DepthImageFrame的典型用法代码示例。如果您正苦于以下问题:C# DepthImageFrame类的具体用法?C# DepthImageFrame怎么用?C# DepthImageFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DepthImageFrame类属于Microsoft.Kinect命名空间,在下文中一共展示了DepthImageFrame类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConvertDepthColor

        /// <summary>
        /// 距離データをカラー画像に変換する
        /// </summary>
        /// <param name="kinect"></param>
        /// <param name="depthFrame"></param>
        /// <returns></returns>
        private byte[] ConvertDepthColor( KinectSensor kinect, DepthImageFrame depthFrame )
        {
            ColorImageStream colorStream = kinect.ColorStream;
              DepthImageStream depthStream = kinect.DepthStream;

              // 距離カメラのピクセルごとのデータを取得する
              short[] depthPixel = new short[depthFrame.PixelDataLength];
              depthFrame.CopyPixelDataTo( depthPixel );

              // 距離カメラの座標に対応するRGBカメラの座標を取得する(座標合わせ)
              ColorImagePoint[] colorPoint = new ColorImagePoint[depthFrame.PixelDataLength];
              kinect.MapDepthFrameToColorFrame( depthStream.Format, depthPixel,
            colorStream.Format, colorPoint );

              byte[] depthColor = new byte[depthFrame.PixelDataLength * Bgr32BytesPerPixel];
              for ( int index = 0; index < depthPixel.Length; index++ ) {
            // 距離カメラのデータから、プレイヤーIDと距離を取得する
            int player = depthPixel[index] & DepthImageFrame.PlayerIndexBitmask;
            int distance = depthPixel[index] >> DepthImageFrame.PlayerIndexBitmaskWidth;

            // 変換した結果が、フレームサイズを超えることがあるため、小さいほうを使う
            int x = Math.Min( colorPoint[index].X, colorStream.FrameWidth - 1 );
            int y = Math.Min( colorPoint[index].Y, colorStream.FrameHeight - 1 );
            int colorIndex = ((y * depthFrame.Width) + x) * Bgr32BytesPerPixel;

            if ( player != 0 ) {
              depthColor[colorIndex] = 255;
              depthColor[colorIndex + 1] = 255;
              depthColor[colorIndex + 2] = 255;
            }
            else {
              // サポート外 0-40cm
              if ( distance == depthStream.UnknownDepth ) {
            depthColor[colorIndex] = 0;
            depthColor[colorIndex + 1] = 0;
            depthColor[colorIndex + 2] = 255;
              }
              // 近すぎ 40cm-80cm(default mode)
              else if ( distance == depthStream.TooNearDepth ) {
            depthColor[colorIndex] = 0;
            depthColor[colorIndex + 1] = 255;
            depthColor[colorIndex + 2] = 0;
              }
              // 遠すぎ 3m(Near),4m(Default)-8m
              else if ( distance == depthStream.TooFarDepth ) {
            depthColor[colorIndex] = 255;
            depthColor[colorIndex + 1] = 0;
            depthColor[colorIndex + 2] = 0;
              }
              // 有効な距離データ
              else {
            depthColor[colorIndex] = 0;
            depthColor[colorIndex + 1] = 255;
            depthColor[colorIndex + 2] = 255;
              }
            }
              }

              return depthColor;
        }
开发者ID:hatsunea,项目名称:KinectSDKBook4CS,代码行数:66,代码来源:MainWindow.xaml.cs


示例2: ConvertDepthToColor

        /// <summary>
        /// 距離データをカラー画像に変換する
        /// </summary>
        /// <param name="depthFrame"></param>
        /// <returns></returns>
        private static byte[] ConvertDepthToColor( DepthImageFrame depthFrame )
        {
            // 距離カメラのピクセルごとのデータを取得する
            short[] depthPixel = depthFrame.ToPixelData();

            // 画像化データを作成する
            byte[] depthColor = new byte[depthFrame.Width * depthFrame.Height * BytesPerPixel];

            // 画像化する
            for ( int i = 0; i < depthPixel.Length; i++ ) {
                // 距離カメラのデータから、距離とプレイヤーIDを取得する
                int distance = depthPixel[i] >> DepthImageFrame.PlayerIndexBitmaskWidth;
                int player = depthPixel[i] & DepthImageFrame.PlayerIndexBitmask;

                // バイトインデックスを計算する
                int index = i * BytesPerPixel;

                byte gray = (byte)~(byte)KinectUtility.ScaleTo( distance, 0x0FFF, 0xFF );
                depthColor[index + 0] = gray;
                depthColor[index + 1] = gray;
                depthColor[index + 2] = gray;
            }

            return depthColor;
        }
开发者ID:NaturalSoftwareJP,项目名称:NaturalSoftware.Kinect.CSharp,代码行数:30,代码来源:DepthImageFrameExtensions.cs


示例3: ReconhecerDistancia

        private void ReconhecerDistancia(DepthImageFrame quadro, byte[] bytesImagem, int maxDistancia)
        {
            if (quadro == null || bytesImagem == null)
                return;
            
                using (quadro)
                {
                    DepthImagePixel[] imagemProfundidade = new DepthImagePixel[quadro.PixelDataLength];
                    quadro.CopyDepthImagePixelDataTo(imagemProfundidade);

                    DepthImagePoint[] pontosImagemProfundidade = new DepthImagePoint[640 * 480];

                    Kinect.CoordinateMapper
                            .MapColorFrameToDepthFrame(Kinect.ColorStream.Format,
                                                       Kinect.DepthStream.Format, imagemProfundidade,
                                                       pontosImagemProfundidade);

                    for (int i = 0; i < pontosImagemProfundidade.Length; i++)
                    {
                        var point = pontosImagemProfundidade[i];
                        if (point.Depth < maxDistancia && KinectSensor.IsKnownPoint(point))
                        {
                            var pixelDataIndex = i * 4;
                            byte maiorValorCor =
                            Math.Max(bytesImagem[pixelDataIndex],
                            Math.Max(bytesImagem[pixelDataIndex + 1],
                            bytesImagem[pixelDataIndex + 2]));
                            bytesImagem[pixelDataIndex] = maiorValorCor;
                            bytesImagem[pixelDataIndex + 1] = maiorValorCor;
                            bytesImagem[pixelDataIndex + 2] = maiorValorCor;
                        }
                    }
                }
        }
开发者ID:jorgeLuizChaves,项目名称:MSKinect,代码行数:34,代码来源:MainWindow.xaml.cs


示例4: OnAllFramesReady

        public void OnAllFramesReady(ColorImageFrame colorImageFrame, DepthImageFrame depthImageFrame, SkeletonFrame skeletonFrame)
        {
            string stat = "";
            // Face tracking / timing stuff
            if (FaceList.Count > 0) {
                foreach (Face f in FaceList.toList()) {
                    stat += "    {" + f.Id + ", " + String.Format("{0:0.00}", f.Velocity) + "}";
                    if (f.TakePicture) {
                        int[] coordsExpanded = expandBy(f.Coords, 250, colorImageFrame.Width - 1, colorImageFrame.Height - 1);
                        if (coordsExpanded[2] == 0 || coordsExpanded[3] == 0) // width or height can't be 0
                            continue;
                        string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);
                        string path = "..\\..\\Images\\CroppedPics\\pic" + f.Id + "--" + time + ".jpg";
                        f.Path = path;
                        bool success = SaveImage(path, cropImage(colorImageFrame, coordsExpanded), ImageFormat.Jpeg);
                        if (success && USE_BETAFACE) {
                            bfw.enqueue(f);
                            f.ProcessingBetaface = true;

                        }
                    }

                }
            }
            FaceTracking.Status = stat;
            FaceTracking.Status = "";
        }
开发者ID:jkiske,项目名称:Senior-Design,代码行数:27,代码来源:FaceTracking.cs


示例5: BasicDepthProcessing

        //基础景深数据处理
        public byte[] BasicDepthProcessing(byte[] result, short[] original, DepthImageFrame depthFrame, Int32 loThreashold, Int32 hiThreshold)
        {
            Int32 depth;
            Int32 gray;
            Int32 alpha;
            for (int i = 0, j = 0; i < original.Length; i++, j += bytePerPixel)
            {
                depth = original[i] >> DepthImageFrame.PlayerIndexBitmaskWidth;
                if (depth < loThreashold || depth > hiThreshold)
                {
                    //this gray must be larger than minColorByte
                    //so that can draw the line the whole background
                    gray = 40;
                    alpha = 255;

                }
                else
                {
                    int temp = (depth / 100) % 10 / 3;
                    gray = 255 - (temp * 50);
                    alpha = 255;
                }
                result[j] = (byte)gray;
                result[j + 1] = (byte)gray;
                result[j + 2] = (byte)gray;
                result[j + 3] = (byte)alpha;

            }
            return result;
        }
开发者ID:BillHuangg,项目名称:Kinect-Depth-Processing,代码行数:31,代码来源:DepthProcessManager.cs


示例6: Record

        public void Record(DepthImageFrame frame)
        {
            // Header
              writer.Write((int)KinectRecordOptions.Depth);

              // Data
              var time = DateTime.Now;
              TimeSpan timeSpan = time.Subtract(referenceTime);
              referenceTime = time;
              writer.Write((long)timeSpan.TotalMilliseconds);
              writer.Write(frame.BytesPerPixel);
              writer.Write((int)frame.Format);
              writer.Write(frame.Width);
              writer.Write(frame.Height);

              writer.Write(frame.FrameNumber);

              // Bytes
              short[] shorts = new short[frame.PixelDataLength];
              frame.CopyPixelDataTo(shorts);
              writer.Write(shorts.Length);
              foreach (short s in shorts) {
            writer.Write(s);
              }
        }
开发者ID:ushadow,项目名称:kinect_toolbox,代码行数:25,代码来源:DepthRecorder.cs


示例7: CreateBetterShadesOfGray

        private void CreateBetterShadesOfGray(DepthImageFrame depthFrame, short[] pixelData)
        {
            int depth;
            int gray;
            int bytesPerPixel = 4;
            byte[] enhPixelData = new byte[depthFrame.Width * depthFrame.Height * bytesPerPixel];

            for (int i = 0, j = 0; i < pixelData.Length; i++, j += bytesPerPixel)
            {
                depth = pixelData[i] >> DepthImageFrame.PlayerIndexBitmaskWidth;

                if (depth < LoDepthThreshold || depth > HiDepthThreshold)
                {
                    gray = 0xFF;
                }
                else
                {
                    gray = (255 * depth / 0xFFF);
                }

                enhPixelData[j] = (byte)gray;
                enhPixelData[j + 1] = (byte)gray;
                enhPixelData[j + 2] = (byte)gray;
            }

            this._DepthImage.WritePixels(this._DepthImageRect, enhPixelData, this._DepthImageStride, 0);
        }
开发者ID:kulturberikare,项目名称:RUNKinect,代码行数:27,代码来源:MainWindow.xaml.cs


示例8: GetHeight

        /// <summary>
        /// 获取身高
        /// </summary>
        /// <param name="depthFrame">深度图像数据</param>
        /// <returns></returns>
        public int GetHeight(DepthImageFrame depthFrame)
        {
            int height;
            short[] rawDepthData = new short[depthFrame.PixelDataLength];
            depthFrame.CopyPixelDataTo(rawDepthData);

            int Max = 0;
            int Min = 480;
            for (int depthIndex = 0; depthIndex < rawDepthData.Length; depthIndex++)
            {
                int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
                if (player > 0)
                {
                    int TempYdata = depthIndex / 640;
                    if (TempYdata > Max)
                    {
                        Max = TempYdata;
                    }
                    if (TempYdata < Min)
                    {
                        Min = TempYdata;
                    }
                }
            }

            height = Max - Min;
            return height;
        }
开发者ID:williamchai,项目名称:kinect-ipd,代码行数:33,代码来源:MainWindow.xaml.cs


示例9: GenerateColoredBytes

        private byte[] GenerateColoredBytes(DepthImageFrame depthFrame)
        {
            short[] rawDepthData = new short[depthFrame.PixelDataLength];
            depthFrame.CopyPixelDataTo(rawDepthData);

            Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4];

            const int BlueIndex = 0;
            const int GreenIndex = 1;
            const int RedIndex = 2;
            const int alpha = 3;

            for (int depthIndex = 0, colorIndex = 0;
                depthIndex < rawDepthData.Length && colorIndex < pixels.Length;
                depthIndex++, colorIndex += 4)
            {
                int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
                int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;


                if (depth <= 900)
                {
                    pixels[colorIndex + BlueIndex] = 255; //closest objects blue
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 0;
                    pixels[colorIndex + alpha] = 255;

                }
                else if (depth < 2000)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 255; //medium depth is green
                    pixels[colorIndex + RedIndex] = 0;
                    pixels[colorIndex + alpha] = 255;

                }
                else
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 255; //farthest is red
                    pixels[colorIndex + alpha] = 255;

                }

                if (player > 0)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 255;
                    pixels[colorIndex + RedIndex] = 255;
                    pixels[colorIndex + alpha] = 255;
                    
                }

            }

            return pixels;

        }
开发者ID:guozanhua,项目名称:Kinect-Tennis,代码行数:59,代码来源:MainWindow.xaml.cs


示例10: Record

        public void Record(DepthImageFrame frame)
        {
            if (writer == null)
                throw new Exception("This recorder is stopped");

            if (depthRecorder == null)
                throw new Exception("Depth recording is not actived on this KinectRecorder");

            depthRecorder.Record(frame);
            Flush();
        }
开发者ID:Hitchhikrr,项目名称:harley,代码行数:11,代码来源:KinectRecorder.cs


示例11: ReplayDepthImageFrame

        public ReplayDepthImageFrame(DepthImageFrame frame)
        {
            Format = frame.Format;
              BytesPerPixel = frame.BytesPerPixel;
              FrameNumber = frame.FrameNumber;
              TimeStamp = frame.Timestamp;
              Width = frame.Width;
              Height = frame.Height;

              PixelDataLength = frame.PixelDataLength;
              internalFrame = frame;
        }
开发者ID:ushadow,项目名称:kinect_toolbox,代码行数:12,代码来源:ReplayDepthImageFrame.cs


示例12: GenerateColoredBytes

        private byte[] GenerateColoredBytes(DepthImageFrame depthFrame)
        {
            //get raw data from kinect
            short[] rawDepthData = new short[depthFrame.PixelDataLength];
            depthFrame.CopyPixelDataTo(rawDepthData);
            Byte[] pixels = new byte[depthFrame.Width * depthFrame.Height * 4];

            //constants
            const int BlueIndex = 0;
            const int GreenIndex = 1;
            const int RedIndex = 2;

            //loop through distances
            for (int depthIndex = 0, colorIndex = 0; depthIndex < rawDepthData.Length && colorIndex < pixels.Length;
                 depthIndex++, colorIndex += 4)
            {
                //get player
                int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
                //get depth value
                int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;
                //.9M or 2.95'
                if (depth <= 900)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 255;
                }
                //.9M - 2M or 2.95' - 6.26'
                else if (depth > 900 && depth < 2000)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 255;
                    pixels[colorIndex + RedIndex] = 0;
                }
                //2M+ or 6.26'+
                else if (depth > 2000)
                {
                    pixels[colorIndex + BlueIndex] = 255;
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 0;
                }
                //byte intensity = CalculateIntensityFromDepth(depth);
                //pixels[colorIndex + BlueIndex] = intensity;
                //pixels[colorIndex + GreenIndex] = intensity;
                //pixels[colorIndex + RedIndex] = intensity;

            }

            return pixels;
        }
开发者ID:nayak16,项目名称:Kinect-Experimentation-,代码行数:50,代码来源:MainWindow.xaml.cs


示例13: ApplyDistanceFilter

        //distance given in inches
        public BitmapSource ApplyDistanceFilter(DepthImageFrame frame, int dist)
        {
            double depthDist = dist * 25.4;
            short[] depthArray = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(depthArray);
            depthArray = applyPixelFilter(depthArray, frame.Width, frame.Height);
              //  depthArray = applyWeightedAverageFilter(depthArray, frame.Width, frame.Height);
            byte[] colorFrame = new byte[frame.Width * frame.Height * 4];

            Parallel.For(0, frame.Height, i =>
            {
                // Process each pixel in the row
                for (int j = 0; j < frame.Width; j++)
                {
                    var distanceIndex = j + (i * frame.Width);
                    var index = distanceIndex * 4;
                    double depth = depthArray[distanceIndex]>> DepthImageFrame.PlayerIndexBitmaskWidth;

                    // Map the distance to an intesity that can be represented in RGB

                    if (depth < depthDist && depth > 0)
                    {
                        var intensity = CalculateIntensityFromDistance(depthArray[distanceIndex]);

                        colorFrame[index + BlueIndex] = intensity;
                        colorFrame[index + GreenIndex] = intensity;
                        colorFrame[index + RedIndex] = intensity;
                        colorFrame[index + AlphaIndex] = 250;

                    }
                    else
                    {
                        colorFrame[index + BlueIndex] = 112;
                        colorFrame[index + GreenIndex] = 25;
                        colorFrame[index + RedIndex] = 25;
                        colorFrame[index + AlphaIndex] = 200;

                    }

                }

            });

            //rgba
            BitmapSource bmps = BitmapSource.Create(frame.Width, frame.Height, 96, 96, PixelFormats.Bgra32, null, colorFrame, frame.Width * PixelFormats.Bgr32.BitsPerPixel / 8);

            //rgb
            //BitmapSource bmps = BitmapSource.Create(frame.Width, frame.Height, 96, 96, PixelFormats.Bgr32, null, colorFrame, frame.Width * PixelFormats.Bgr32.BitsPerPixel / 8);
            return bmps;
        }
开发者ID:kuninagakura,项目名称:FlowMap,代码行数:51,代码来源:Methods.cs


示例14: synchronize

        public void synchronize(
            DepthImageFrame depthFrame,
            ColorImageFrame colorFrame,
            SkeletonFrame skletonFrame,
            Boolean isPauseMode
            )
        {
            IsPauseMode = isPauseMode;
            colorFrame.CopyPixelDataTo(_colorByte);

            //Console.WriteLine("max depth: "+depthFrame.MaxDepth);
            depthFrame.CopyDepthImagePixelDataTo(_depthPixels);

            _sensor.CoordinateMapper.MapColorFrameToDepthFrame(
                ColorImageFormat.RgbResolution640x480Fps30,
                DepthImageFormat.Resolution640x480Fps30,
                _depthPixels,
                _depthPoint
                );

            for (int i = 0; i < _pixelDepthDataLength; i++)
            {
                _depthShort[i] = (short)_depthPoint[i].Depth;
                _depthByte[i] = (byte)(_depthPoint[i].Depth*0.064-1);
            }

            skletonFrame.CopySkeletonDataTo(totalSkeleton);
            Skeleton firstSkeleton = (from trackskeleton in totalSkeleton
                                      where trackskeleton.TrackingState == SkeletonTrackingState.
                                      Tracked
                                      select trackskeleton).FirstOrDefault();

            _isCreation = true;
            if (firstSkeleton != null)
            {
                if (firstSkeleton.Joints[JointType.Spine].TrackingState == JointTrackingState.Tracked)
                {
                    IsSkeletonDetected = true;
                    UserSkeleton[SkeletonDataType.RIGHT_HAND] =
                        ScalePosition(firstSkeleton.Joints[JointType.HandRight].Position);
                    UserSkeleton[SkeletonDataType.LEFT_HAND] =
                        ScalePosition(firstSkeleton.Joints[JointType.HandLeft].Position);
                    UserSkeleton[SkeletonDataType.SPINE] =
                        ScalePosition(firstSkeleton.Joints[JointType.Spine].Position);
                    return;
                }
            }
            IsSkeletonDetected = false;
            _isCreation = false;
        }
开发者ID:darekf77,项目名称:KinectWrapper,代码行数:50,代码来源:KinectFrameCreation.cs


示例15: GetColoredBytes

        byte[] GetColoredBytes(DepthImageFrame frame)
        {
            var depthData = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(depthData);

            //4 (Red, Green, Blue, empty byte)
            var pixels = new byte[frame.Height * frame.Width * 4];

            const int blueIndex = 0;
            const int greenIndex = 1;
            const int redIndex = 2;

            //pick a RGB color based on distance
            for (int depthIndex = 0, colorIndex = 0;
                 depthIndex < depthData.Length && colorIndex < pixels.Length;
                 depthIndex++, colorIndex += 4)
            {
                var player = depthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
                var depth = depthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;

                if (depth <= 900)
                {
                    pixels[colorIndex + blueIndex] = 255;
                    pixels[colorIndex + greenIndex] = 0;
                    pixels[colorIndex + redIndex] = 0;

                }
                else if (depth > 900 && depth < 2000)
                {
                    pixels[colorIndex + blueIndex] = 0;
                    pixels[colorIndex + greenIndex] = 255;
                    pixels[colorIndex + redIndex] = 0;
                }
                else if (depth > 2000)
                {
                    pixels[colorIndex + blueIndex] = 0;
                    pixels[colorIndex + greenIndex] = 0;
                    pixels[colorIndex + redIndex] = 255;
                }

                if (player > 0)
                {
                    pixels[colorIndex + blueIndex] = Colors.Gold.B;
                    pixels[colorIndex + greenIndex] = Colors.Gold.G;
                    pixels[colorIndex + redIndex] = Colors.Gold.R;
                }
            }
            return pixels;
        }
开发者ID:latish,项目名称:Kinect_Demo,代码行数:49,代码来源:MainWindow.DepthStream.cs


示例16: GenerateColoredBytes

        private static Byte[] GenerateColoredBytes(DepthImageFrame depthFrame, int minRange, int maxRange)
        {
            //get the raw data from kinect with the depth for every pixel
            short[] rawDepthData = new short[depthFrame.PixelDataLength];
            depthFrame.CopyPixelDataTo(rawDepthData);

            //use depthFrame to create the image to display on-screen
            //depthFrame contains color information for all pixels in image
            //Height x Width x 4 (Red, Green, Blue, empty byte)
            Byte[] pixels = new Byte[depthFrame.Height * depthFrame.Width * 4];

            //Bgr32  - Blue, Green, Red, empty byte
            //Bgra32 - Blue, Green, Red, transparency
            //You must set transparency for Bgra as .NET defaults a byte to 0 = fully transparent

            //hardcoded locations to Blue, Green, Red (BGR) index positions
            const int BlueIndex = 0;
            const int GreenIndex = 1;
            const int RedIndex = 2;

            //loop through all distances
            //pick a RGB color based on distance
            for (int depthIndex = 0, colorIndex = 0; depthIndex < rawDepthData.Length && colorIndex < pixels.Length; depthIndex++, colorIndex += 4)
            {

                int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;

                if (depth < 850 || depth > 4000)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 0;
                }
                else if (depth <= minRange || depth > maxRange)
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 0;
                    pixels[colorIndex + RedIndex] = 0;
                }
                else
                {
                    pixels[colorIndex + BlueIndex] = 0;
                    pixels[colorIndex + GreenIndex] = 255;
                    pixels[colorIndex + RedIndex] = 0;
                }
            }

            return pixels;
        }
开发者ID:pvishal,项目名称:kinect-hands,代码行数:49,代码来源:MainWindow.xaml.cs


示例17: ConvertDepthToColorImage

        /// <summary>
        /// 距離データをカラー画像に変換する
        /// </summary>
        /// <param name="kinect"></param>
        /// <param name="depthFrame"></param>
        /// <returns></returns>
        private byte[] ConvertDepthToColorImage(KinectSensor kinect, DepthImageFrame depthFrame)
        {
            DepthImageStream depthStream = kinect.DepthStream;

            // 距離カメラのピクセルごとのデータを取得する
            short[] depthPixel = new short[depthFrame.PixelDataLength];
            depthFrame.CopyPixelDataTo(depthPixel);

            byte[] depthColor = new byte[depthFrame.PixelDataLength * Bgr32BytesPerPixel];
            for (int index = 0; index < depthPixel.Length; index++)
            {
                // 距離カメラのデータから、距離を取得する
                int distance = depthPixel[index] >> DepthImageFrame.PlayerIndexBitmaskWidth;
                int colorIndex = index * Bgr32BytesPerPixel;

                // 赤:サポート外 0-40cm, 8m-
                if (distance == depthStream.UnknownDepth)
                {
                    depthColor[colorIndex] = 0;
                    depthColor[colorIndex + 1] = 0;
                    depthColor[colorIndex + 2] = 255;
                }
                // 緑:近すぎ 40cm-80cm(default mode)
                else if (distance == depthStream.TooNearDepth)
                {
                    depthColor[colorIndex] = 0;
                    depthColor[colorIndex + 1] = 255;
                    depthColor[colorIndex + 2] = 0;
                }
                // 青:遠すぎ 3m(Near),4m(Default)-8m
                else if (distance == depthStream.TooFarDepth)
                {
                    depthColor[colorIndex] = 255;
                    depthColor[colorIndex + 1] = 0;
                    depthColor[colorIndex + 2] = 0;
                }
                // 有効な距離データ
                else
                {
                    byte color = (byte)(255 * distance / depthStream.TooFarDepth);

                    depthColor[colorIndex] = 0;
                    depthColor[colorIndex + 1] = color;
                    depthColor[colorIndex + 2] = color;
                }
            }

            return depthColor;
        }
开发者ID:geis,项目名称:KinectForWindowsSampleCode,代码行数:55,代码来源:MainWindow.xaml.cs


示例18: Context_AllFramesUpdated

        void Context_AllFramesUpdated(KinectSensor sensor, ColorImageFrame cf, DepthImageFrame df, SkeletonFrame sf)
        {
            this.sensor = sensor;
            if (colorImage == null)
            {
                colorImage = new byte[cf.PixelDataLength];
                depthImage = new short[df.PixelDataLength];
                skeletonData = new Skeleton[sf.SkeletonArrayLength];
            }

            cf.CopyPixelDataTo(colorImage);
            df.CopyPixelDataTo(depthImage);
            sf.CopySkeletonDataTo(skeletonData);

            TrackFace();
        }
开发者ID:sakapon,项目名称:Samples-2014,代码行数:16,代码来源:SkeletonFaceTracker.cs


示例19: FromDepthImageFrame

        public static ReplayDepthImageFrame FromDepthImageFrame(DepthImageFrame frame)
        {
            short[] pixelData = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixelData);

            return new ReplayDepthImageFrame()
            {
                FrameNumber = frame.FrameNumber,
                BytesPerPixel = frame.BytesPerPixel,
                PixelDataLength = frame.PixelDataLength,
                Width = frame.Width,
                Height = frame.Height,
                Timestamp = frame.Timestamp,
                PixelData = pixelData
            };
        }
开发者ID:marcobaldo,项目名称:kinect-replay,代码行数:16,代码来源:ReplayDepthImageFrame.cs


示例20: FaceTracking

        /// <summary>
        /// 顔を追跡する
        /// </summary>
        /// <param name="colorFrame"></param>
        /// <param name="depthFrame"></param>
        /// <param name="skeleton"></param>
        private void FaceTracking( ColorImageFrame colorFrame, DepthImageFrame depthFrame, Skeleton skeleton )
        {
            var faceFrame = faceTracker.Track( colorFrame.Format, colorFrame.ToPixelData(),
                depthFrame.Format, depthFrame.ToPixelData(), skeleton );
            if ( faceFrame.TrackSuccessful ) {
                // 四角を移動させる
                rectFace.Margin = new Thickness( faceFrame.FaceRect.Left, faceFrame.FaceRect.Top, 0, 0 );
                rectFace.Width = faceFrame.FaceRect.Width;
                rectFace.Height = faceFrame.FaceRect.Height;

                rectFace.Visibility = System.Windows.Visibility.Visible;
            }
            else {
                rectFace.Visibility = System.Windows.Visibility.Hidden;
            }
        }
开发者ID:kaorun55,项目名称:KinectSdkIntroduction,代码行数:22,代码来源:MainWindow.xaml.cs



注:本文中的Microsoft.Kinect.DepthImageFrame类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Kinect.DepthImageFrameReadyEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Kinect.ColorImageFrameReadyEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap