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

C# Kinect.DepthImageFrameReadyEventArgs类代码示例

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

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



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


示例16: DepthImageReady

        /// <summary>
        /// DepthImageReady:
        /// This function will be called every time a new depth frame is ready
        /// </summary>
        private void DepthImageReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            using (DepthImageFrame imageFrame = e.OpenDepthImageFrame())
            {
            	//We expect this to be always true since we are coming from a triggered event
                if (imageFrame != null)
                {
                    //Check if the format of the image has changed.
                    //This always happens when you run the program for the first time and every time you minimize the window
                    bool NewFormat = this.lastImageFormat != imageFrame.Format;

                    if (NewFormat)
                    {
                        //Update the image to the new format
                        this.pixelData = new short[imageFrame.PixelDataLength];
                        this.depthFrame32 = new byte[imageFrame.Width * imageFrame.Height * Bgr32BytesPerPixel];
                        
                        //Create the new Bitmap
                        this.outputBitmap = new WriteableBitmap(
                           imageFrame.Width,
                           imageFrame.Height,
                           96,  // DpiX
                           96,  // DpiY
                           PixelFormats.Bgr32,
                           null);

                        this.kinectDepthImage.Source = this.outputBitmap;
                    }

                    //Copy the stream to its short version
                    imageFrame.CopyPixelDataTo(this.pixelData);

                    //Convert the pixel data into its RGB Version.
                    //Here is where the magic happens
                    byte[] convertedDepthBits = this.ConvertDepthFrame(this.pixelData, ((KinectSensor)sender).DepthStream);
					
                    //Copy the RGB matrix to the bitmap to make it visible
					this.outputBitmap.WritePixels(
                        new Int32Rect(0, 0, imageFrame.Width, imageFrame.Height), 
                        convertedDepthBits,
                        imageFrame.Width * Bgr32BytesPerPixel,
                        0);

                    //Update the Format
                    this.lastImageFormat = imageFrame.Format;
                }

                //Since we are coming from a triggered event, we are not expecting anything here, at least for this short tutorial.
                else { }
            }
        }
开发者ID:SoarLin,项目名称:KinectProject,代码行数:55,代码来源:Window1.xaml.cs


示例17: Sensor_DepthFrameReady

 void Sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     using (var image = e.OpenDepthImageFrame()) {
         if (image != null) {
             if (this.data == null) {
                 this.data = new short[image.PixelDataLength];
             }
             image.CopyPixelDataTo(this.data);
             this.ConvertData(this.data);
             this.writeableBitmap.WritePixels(new Int32Rect(0, 0, image.Width, image.Height), this.depthFrame32, image.Width * 4, 0);
             this.OnNewDataAvailable();
         }
     }
 }
开发者ID:gnavvy,项目名称:ParaIF,代码行数:14,代码来源:SDKDepthImageDataSource.cs


示例18: SensorDepthFrameReady

 private void SensorDepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
 {
     using (DepthImageFrame dFrame = e.OpenDepthImageFrame())
     {
         if (dFrame != null)
         {
             dFrame.CopyPixelDataTo(myArray);
             myBitmap.WritePixels(
                 new Int32Rect(0, 0, myBitmap.PixelWidth, myBitmap.PixelHeight),
                 myArray,
                 myBitmap.PixelWidth * sizeof(short),
                 0);
         }
     }
 }
开发者ID:kinectNao,项目名称:bluenao,代码行数:15,代码来源:MainWindow.xaml.cs


示例19: sensor_DepthFrameReady

        void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            this.TEST.Content = this.sensor.DepthStream.TooNearDepth;
            using (DepthImageFrame depthimageframe = e.OpenDepthImageFrame())
            {
                if (depthimageframe == null)
                {
                    return;
                }

                short[] pixelData = new short[depthimageframe.PixelDataLength];
                int stride = depthimageframe.Width * 2;
                depthimageframe.CopyPixelDataTo(pixelData);
                this.DepthController.Source = BitmapSource.Create(depthimageframe.Width, depthimageframe.Height, 96, 96, PixelFormats.Gray16, null, pixelData, stride);
            }
        }
开发者ID:hh54188,项目名称:King,代码行数:16,代码来源:MainWindow.xaml.cs


示例20: Kinect_DepthFrameReady

		void Kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
		{
			if(ClientList.Count > 0)
			{
			    using(DepthImageFrame frame = e.OpenDepthImageFrame())
				{
					this.DepthImageFrame = frame;

					if(frame != null)
					{
						_memoryStream.SetLength(0);

						binaryWriter.Write(DepthImageFrame.PlayerIndexBitmask);
						binaryWriter.Write(DepthImageFrame.PlayerIndexBitmaskWidth);

						binaryWriter.Write(frame);
						binaryWriter.Write((int)frame.Format);

						if(_depth == null || _depth.Length != frame.PixelDataLength)
							_depth = new short[frame.PixelDataLength];
						frame.CopyPixelDataTo(_depth);

						if(_depthBytes == null || _depthBytes.Length != _depth.Length * 2)
							_depthBytes = new byte[_depth.Length * 2];

						Buffer.BlockCopy(_depth, 0, _depthBytes, 0, _depthBytes.Length);

						binaryWriter.Write(_depthBytes);

						_frameCount++;

						if(_fps == -1 || (_frameCount > 0 && (_frameCount % (GetFps(frame.Format) / _fps)) == 0))
						{
							Parallel.For(0, ClientList.Count, index =>
							{
								SocketClient sc = ClientList[index];
								byte[] data = _memoryStream.ToArray();

								sc.Send(BitConverter.GetBytes(data.Length));
								sc.Send(data);
							});
						}
						RemoveClients();
					}
				}
			}
		}
开发者ID:Cocotus,项目名称:kinect,代码行数:47,代码来源:DepthListener.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Kinect.Joint类代码示例发布时间:2022-05-26
下一篇:
C# Kinect.DepthImageFrame类代码示例发布时间: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