当前位置: 首页>>代码示例>>C#>>正文


C# Kinect.DepthImageFrameReadyEventArgs类代码示例

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


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

示例1: KinectOnDepthFrameReady

        private void KinectOnDepthFrameReady(object sender, DepthImageFrameReadyEventArgs depthImageFrameReadyEventArgs)
        {
            using (DepthImageFrame temp = depthImageFrameReadyEventArgs.OpenDepthImageFrame())
            {
                if (temp == null) return;

                short[] depthData = new short[640 * 480];
                byte[] depthColorData = new byte[640 * 480 * 4];

                temp.CopyPixelDataTo(depthData);

                for (int i = 0, i32 = 0; i < depthData.Length && i32 < depthColorData.Length; i++, i32 += 4)
                {
                    //深度情報のみ取得
                    int realDepth = depthData[i] >> DepthImageFrame.PlayerIndexBitmaskWidth;

                    //得られた深度を256段階のグレースケールに
                    byte intensity = (byte)(255 - (255 * realDepth / 4095));

                    depthColorData[i32] = intensity;
                    depthColorData[i32+1] = intensity;
                    depthColorData[i32+2] = intensity;
                }

                //深度情報の配列をBitmapにして表示
                this.pictureBox1.Image = ConvertToBitmap(depthColorData, 640, 480);
            }
        }
开发者ID:buchizo,项目名称:ITAP5,代码行数:28,代码来源:Form1.cs

示例2: SensorDepthFrameReady

        /// <summary>
        /// Event handler for Kinect sensor's DepthFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorDepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame != null)
                {
                    // Copy the pixel data from the image to a temporary array
                    depthFrame.CopyPixelDataTo(this.depthPixels);

                    // Convert the depth to RGB
                    int width = 480;
                    int height = 640;
                    int start = width * (height / 2 - 1); //start at the beginning of the middle line
                    for (int i = 0; i < 480; ++i)
                    {
                        // discard the portion of the depth that contains only the player index
                        short depth = (short)(this.depthPixels[i + start] >> DepthImageFrame.PlayerIndexBitmaskWidth);
                        //find the angle to the left (if negative) or right (if positive) of the depth. The kinect's fov is 58
                        //so we halve it because it's going to be either left or right
                        double angle = (i - 240) / 29 * Math.PI / 180;
                        double xFromRBot = Math.Sin(angle) * depth;
                        double yFromRBot = Math.Cos(angle) * depth;
                        Vector2D posFromRBot = new Vector2D(xFromRBot, yFromRBot);
                        posFromRBot.translate(rbotPos);
                        posFromRBot.rotate(rbotAngle);
                        Vector2D absolutePos = posFromRBot;
                    }
                }
            }
        }
开发者ID:janslow,项目名称:cs-a-group,代码行数:35,代码来源:MainWindow.xaml.cs

示例3: Sensor_DepthFrameReady

        void Sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (DepthImageFrame imageFrame = e.OpenDepthImageFrame())
            {
                if (imageFrame != null)
                {
                    depthMap = new Texture2D(Game.GraphicsDevice, imageFrame.Width, imageFrame.Height, false, SurfaceFormat.Color);

                    short[] data = new short[imageFrame.PixelDataLength];
                    Color[] depthData = new Color[imageFrame.Width * imageFrame.Height];

                    imageFrame.CopyPixelDataTo(data);

                    ConvertDepthFrame(data, Sensor.DepthStream, ref depthData);


                    depthMap.SetData<Color>(depthData);

                }
                else
                {
                    // imageFrame is null because the request did not arrive in time
                }
            }

        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:26,代码来源:KinectComponent.cs

示例4: sensor_DepthFrameReady

 void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     if (this.DepthFrameReady != null)
     {
         this.DepthFrameReady(this, e);
     }
 }
开发者ID:an83,项目名称:KinectTouch2,代码行数:7,代码来源:KinectSensorAdapter.cs

示例5: DepthFrameReady

        private void DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            DepthImageFrame frame = e.OpenDepthImageFrame();
            if (frame != null)
            {
                if (this.first || frame.Format != this.format)
                {
                    this.InitBuffers(frame);
                    this.DisposeTextures();
                }

                this.FInvalidate = true;
                this.frameindex = frame.FrameNumber;
                lock (m_lock)
                {
                    frame.CopyDepthImagePixelDataTo(this.depthpixels);
                    for (int i16 = 0; i16 < this.width * this.height; i16++)
                    {
                        this.rawdepth[i16] = this.depthpixels[i16].Depth;
                    }
                }

                frame.Dispose();
            }
        }
开发者ID:kopffarben,项目名称:dx11-vvvv,代码行数:25,代码来源:KinectDepthTextureNode.cs

示例6: sensor_DepthFrameReady

        unsafe void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (var image = e.OpenDepthImageFrame()) {
                if (image != null) {
                    var data = new short[image.PixelDataLength];
                    image.CopyPixelDataTo(data);
                    BitmapData bitmapData = this.CurrentValue.LockBits(new System.Drawing.Rectangle(0, 0, this.Width, this.Height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                    int pointer = 0;
                    int width = this.Width;
                    int height = this.Height;
                    for (int y = 0; y < height; y++) {
                        byte* pDest = (byte*)bitmapData.Scan0.ToPointer() + y * bitmapData.Stride;
                        for (int x = 0; x < width; x++, pointer++, pDest += 3) {
                            int realDepth = data[pointer] >> DepthImageFrame.PlayerIndexBitmaskWidth;
                            byte intensity = (byte)(~(realDepth >> 4));
                            pDest[0] = intensity;
                            pDest[1] = intensity;
                            pDest[2] = intensity;
                        }
                    }
                    this.CurrentValue.UnlockBits(bitmapData);
                    this.OnNewDataAvailable();
                }
            }
        }
开发者ID:gnavvy,项目名称:ParaIF,代码行数:26,代码来源:SDKDepthBitmapDataSource.cs

示例7: kinectSensor_DepthFrameReady

        void kinectSensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (var frame = e.OpenDepthImageFrame())
            {
                if (frame == null)
                    return;
               
                if (depthFrame32 == null)
                {
                    pixelData = new short[frame.PixelDataLength];
                    depthFrame32 = new byte[frame.Width * frame.Height * sizeof(int)];
                }

                frame.CopyPixelDataTo(pixelData);

                if (bitmap == null)
                {
                    bitmap = new WriteableBitmap(frame.Width, frame.Height, 96, 96, PixelFormats.Bgra32, null);
                    image.Source = bitmap;
                }

                ConvertDepthFrame(pixelData);

                int stride = bitmap.PixelWidth * sizeof(int);
                Int32Rect dirtyRect = new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight);
                bitmap.WritePixels(dirtyRect, depthFrame32, stride, 0);
            }
        }
开发者ID:Hitchhikrr,项目名称:harley,代码行数:28,代码来源:PresenceControl.xaml.cs

示例8: kinect_DepthFrameReady

 /// <summary>
 /// 距離カメラのフレーム更新イベント
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void kinect_DepthFrameReady( object sender, DepthImageFrameReadyEventArgs e )
 {
     using ( var depthFrame = e.OpenDepthImageFrame() ) {
         if ( depthFrame != null ) {
             imageDepthCamera.Source = depthFrame.ToBitmapSource();
         }
     }
 }
开发者ID:hatsunea,项目名称:KinectSDKBook4CS,代码行数:13,代码来源:MainWindow.xaml.cs

示例9: kinect_DepthFrameReady

 // 距離カメラのフレーム更新イベント
 void kinect_DepthFrameReady( object sender, DepthImageFrameReadyEventArgs e )
 {
     // Disposableなのでusingでくくる
     using ( DepthImageFrame depthFrame = e.OpenDepthImageFrame() ) {
         if ( depthFrame != null ) {
             imageDepthCamera.Source = depthFrame.ToBitmapSource();
         }
     }
 }
开发者ID:kaorun55,项目名称:KinectSdkIntroduction,代码行数:10,代码来源:MainWindow.xaml.cs

示例10: kinectRuntime_DepthFrameReady

        void kinectRuntime_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            var frame = e.OpenDepthImageFrame();

            if (frame == null)
                return;

            depthStreamManager.Update(frame);
        }
开发者ID:asprowlfuller,项目名称:Sabre,代码行数:9,代码来源:MainWindow.xaml.cs

示例11: kinect_DepthFrameReady

 void kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     ad++;
     if (kinect != null && !depthFramyBusy)
     {
         var ts = new ThreadStart(delegate { depthFrameSetUp(e.OpenDepthImageFrame(), depthPixels, depthArray, depthTarget); });
         new Thread(ts).Start();
         
     }
 }
开发者ID:RIT-Tool-Time,项目名称:Cascade,代码行数:10,代码来源:Game1.cs

示例12: SensorDepthFrameReady

        public void SensorDepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame != null)
                {
                    // Copy the pixel data from the image to a temporary array
                    depthFrame.CopyDepthImagePixelDataTo(this.DepthPixels);

                    // Get the min and max reliable depth for the current frame
                    int minDepth = depthFrame.MinDepth;
                    int maxDepth = depthFrame.MaxDepth;

                    // Convert the depth to RGB
                    int colorPixelIndex = 0;
                    for (int i = 0; i < this.DepthPixels.Length; ++i)
                    {
                        // Get the depth for this pixel
                        short depth = DepthPixels[i].Depth;

                        // To convert to a byte, we're discarding the most-significant
                        // rather than least-significant bits.
                        // We're preserving detail, although the intensity will "wrap."
                        // Values outside the reliable depth range are mapped to 0 (black).

                        // Note: Using conditionals in this loop could degrade performance.
                        // Consider using a lookup table instead when writing production code.
                        // See the KinectDepthViewer class used by the KinectExplorer sample
                        // for a lookup table example.
                        byte intensity = (byte)(depth >= minDepth && depth <= maxDepth ? depth : 0);

                        // Write out blue byte
                        this.ColorPixels[colorPixelIndex++] = intensity;

                        // Write out green byte
                        this.ColorPixels[colorPixelIndex++] = intensity;

                        // Write out red byte
                        this.ColorPixels[colorPixelIndex++] = intensity;

                        // We're outputting BGR, the last byte in the 32 bits is unused so skip it
                        // If we were outputting BGRA, we would write alpha here.
                        ++colorPixelIndex;
                    }

                    // Write the pixel data into our bitmap
                    this.ColorBitmap.WritePixels(
                        new Int32Rect(0, 0, this.ColorBitmap.PixelWidth, this.ColorBitmap.PixelHeight),
                        this.ColorPixels,
                        this.ColorBitmap.PixelWidth * sizeof(int),
                        0);
                }
            }
        }
开发者ID:saharki,项目名称:KinectRaD,代码行数:54,代码来源:DepthRecorder.cs

示例13: sensor_DepthFrameReady

 static void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     using (var depthFrame=e.OpenDepthImageFrame())
     {
     if (depthFrame == null) return;
     short[] bits = new short[depthFrame.PixelDataLength];
     depthFrame.CopyPixelDataTo(bits);
     foreach (var bit in bits)
     Console.Write(bit);
     }
 }
开发者ID:ShipuW,项目名称:CSharp-study,代码行数:11,代码来源:Program.cs

示例14: Sensor_DepthFrameReady

 void Sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     using (var frame = e.OpenDepthImageFrame())
     {
         if (frame != null)
         {
             if (_mode == Mode.Depth)
             {
                 camera.Source = frame.ToBitmap();
             }
         }
     }
 }
开发者ID:etrigger,项目名称:Vitruvius,代码行数:13,代码来源:MainWindow.xaml.cs

示例15: sensor_DepthFrameReady

        void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (DepthImageFrame depthImageFrame = e.OpenDepthImageFrame())
            {
                if (depthImageFrame == null)
                {
                    return;
                }

                this.Camera.Source = ImageFrameExtensions.ToBitmapSource(depthImageFrame);
            }
            return;
        }
开发者ID:hh54188,项目名称:King,代码行数:13,代码来源:MainWindow.xaml.cs


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