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

C# Kinect.ColorImageFrameReadyEventArgs类代码示例

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

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



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

示例1: KinectColorFrameReady

        /// <summary>
        /// Sets the data of ColorVideo.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="colorImageFrame"></param>
        public void KinectColorFrameReady(object sender, ColorImageFrameReadyEventArgs colorImageFrame)
        {
            //Get raw image
            ColorVideoFrame = colorImageFrame.OpenColorImageFrame();

            if (ColorVideoFrame != null)
            {
                //Create array for pixel data and copy it from the image frame
                PixelData = new Byte[ColorVideoFrame.PixelDataLength];
                ColorVideoFrame.CopyPixelDataTo(PixelData);

                //Convert RGBA to BGRA, Kinect and XNA uses different color-formats.
                BgraPixelData = new Byte[ColorVideoFrame.PixelDataLength];
                for (int i = 0; i < PixelData.Length; i += 4)
                {
                    BgraPixelData[i] = PixelData[i + 2];
                    BgraPixelData[i + 1] = PixelData[i + 1];
                    BgraPixelData[i + 2] = PixelData[i];
                    BgraPixelData[i + 3] = (Byte)255; //The video comes with 0 alpha so it is transparent
                }

                // Create a texture and assign the realigned pixels
                ColorVideo = new Texture2D(Graphics.GraphicsDevice, ColorVideoFrame.Width, ColorVideoFrame.Height);
                ColorVideo.SetData(BgraPixelData);
                ColorVideoFrame.Dispose();
            }
        }
开发者ID:Hammerstad,项目名称:CustomerDrivenProject,代码行数:32,代码来源:KinectVideoStream.cs


示例2: SensorColorFrameReady

        /// <summary>
        /// Event handler for Kinect sensor's ColorFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            //drop the frame if you're not done with the last one
            if (!this.processingFrame)
            {
                this.processingFrame = true;
                using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
                {
                    if (colorFrame != null)
                    {
                        // Copy the pixel data from the image to a temporary array
                        colorFrame.CopyPixelDataTo(this.colorPixels);

                        IntPtr filteredPixels = this.colorFilter.FilterFrame(this.colorPixels, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight);

                        this.colorBitmap.WritePixels(
                            new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
                            filteredPixels,
                            this.colorPixels.Length,
                            this.colorBitmap.PixelWidth * sizeof(int));

                    }
                }
                this.processingFrame = false;
            }
        }
开发者ID:jgblight,项目名称:fydp,代码行数:31,代码来源:MainWindow.xaml.cs


示例3: sensor_ColorFrameReady

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


示例4: miKinect_ColorFrameReady

        void miKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame framesImagen = e.OpenColorImageFrame()) {
                
                if (framesImagen == null) 
                    return;
                
                byte[] datosColor = new byte[framesImagen.PixelDataLength];
                
                framesImagen.CopyPixelDataTo(datosColor);

                if (grabarFoto)
                {
                    bitmapImagen = BitmapSource.Create(
                        framesImagen.Width, framesImagen.Height, 96, 96, PixelFormats.Bgr32, null,
                        datosColor, framesImagen.Width * framesImagen.BytesPerPixel);
                    grabarFoto = false;
                }
                
                colorStream.Source = BitmapSource.Create(
                    framesImagen.Width, framesImagen.Height, 
                    96, 
                    96, 
                    PixelFormats.Bgr32, 
                    null, 
                    datosColor, 
                    framesImagen.Width * framesImagen.BytesPerPixel
                    );
            }
        }
开发者ID:egaleano,项目名称:Kinect,代码行数:30,代码来源:MainWindow.xaml.cs


示例5: miKinect_ColorFrameReady

        void miKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame framesColor = e.OpenColorImageFrame())
            {
                if (framesColor == null) return;

                if (datosColor == null)
                    datosColor = new byte[framesColor.PixelDataLength];

                framesColor.CopyPixelDataTo(datosColor);

                if (colorImagenBitmap == null)
                {
                    this.colorImagenBitmap = new WriteableBitmap(
                        framesColor.Width,
                        framesColor.Height,
                        96, 
                        96, 
                        PixelFormats.Bgr32,
                        null);
                }

                this.colorImagenBitmap.WritePixels(
                    new Int32Rect(0, 0, framesColor.Width, framesColor.Height),
                    datosColor,
                    framesColor.Width * framesColor.BytesPerPixel, 
                    0  
                    );

                canvasEsqueleto.Background = new ImageBrush(colorImagenBitmap);
            }
        }
开发者ID:egaleano,项目名称:Kinect,代码行数:32,代码来源:MainWindow.xaml.cs


示例6: sensor_ColorFrameReady

        /// <summary>
        /// Color frame main class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame imageFrame = e.OpenColorImageFrame())
            {
                // Check if the incoming frame is not null
                if (imageFrame != null)
                {
                    // Get the pixel data in byte array
                    this.pixelData = new byte[imageFrame.PixelDataLength];

                    // Copy the pixel data
                    imageFrame.CopyPixelDataTo(this.pixelData);

                    // assign the bitmap image source into image control
                    BitmapSource bitmapS = BitmapSource.Create(
                     imageFrame.Width,
                     imageFrame.Height,
                     96,
                     96,
                     PixelFormats.Bgr32,
                     null,
                     pixelData,
                     imageFrame.Width *4 );

                   // this.caller.setImg(bitmapS); //we send data to the caller class

                }
            }
        }
开发者ID:kandran,项目名称:musee-interactif,代码行数:34,代码来源:GestionSensorsColor.cs


示例7: kinect_ColorFrameReady

        public void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            try
            {
                using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
                {
                    if (colorFrame != null)
                    {
                        // RGBカメラのフレームデータを取得する
                        byte[] colorPixel = new byte[colorFrame.PixelDataLength];
                        colorFrame.CopyPixelDataTo(colorPixel);

                        // ピクセルデータをビットマップに変換する

                        mainWindow.imageRgb.Source = BitmapSource.Create(colorFrame.Width,
                            colorFrame.Height, 96, 96, PixelFormats.Bgr32, null,
                            colorPixel, colorFrame.Width * colorFrame.BytesPerPixel);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:weed,项目名称:p121029_KinectWatagashi,代码行数:25,代码来源:Kinect.cs


示例8: sensor_ColorFrameReady

        private void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            if (Enabled)
            {
                using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
                {
                    // can happen that we have to drop frames
                    if (null == colorFrame)
                    {
                        return;
                    }

                    height = colorFrame.Height;
                    width = colorFrame.Width;
                    bytesPerPixel = colorFrame.BytesPerPixel;

                    // TODO: does this remove the need to allocate the same space over and over again?
                    if (null == imageBuffer || imageBuffer.Length != colorFrame.PixelDataLength)
                    {
                        this.imageBuffer = new byte[colorFrame.PixelDataLength];
                    }

                    colorFrame.CopyPixelDataTo(this.imageBuffer);
                }
            }
        }
开发者ID:philiWeitz,项目名称:InteractionTechniques,代码行数:26,代码来源:CameraServiceImpl.cs


示例9: ColorFrameReady

        private void ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            ColorImageFrame frame = e.OpenColorImageFrame();

            if (frame != null)
            {
                if (frame.Format != this.oldformat)
                {
                    int bpp = frame.Format == ColorImageFormat.RgbResolution640x480Fps30 ? 4 : 2;
                    this.colorimage = new byte[640 * 480 * bpp];

                    this.oldformat = frame.Format;
                    this.DisposeTextures();
                }

                this.FInvalidate = true;
                this.frameindex = frame.FrameNumber;

                lock (m_lock)
                {
                    frame.CopyPixelDataTo(this.colorimage);
                }

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


示例10: SensorColorFrameReady

        public void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
            {
                if (colorFrame != null)
                {
                    if (0 == (framesNum + 1) % BUFFERSIZE) //if buffer is full - empty buffer to file\s
                    {
                        for (int i = framesNum - BUFFERSIZE + 1; i < framesNum + 1; i++)
                        {
                            //  CreateThumbnail(@"images\color"+i+".bmp", ConvertWriteableBitmapToBitmapImage(colorBitmap[i%BUFFERSIZE]));
                            //AddBmpToAvi(@"images\video.avi", BitmapFromWriteableBitmap(colorBitmap[i % BUFFERSIZE]));
                        }

                    }

                    // Copy the pixel data from the image to a temporary array
                    colorFrame.CopyPixelDataTo(this.colorPixels);

                    // Write the pixel data into our bitmap

                    this.colorBitmap[framesNum % BUFFERSIZE].WritePixels(
                            new Int32Rect(0, 0, this.colorBitmap[framesNum % BUFFERSIZE].PixelWidth, this.colorBitmap[framesNum % BUFFERSIZE].PixelHeight),
                            this.colorPixels,
                            this.colorBitmap[framesNum % BUFFERSIZE].PixelWidth * sizeof(int),
                            0);
                    framesNum++;
                }
            }
        }
开发者ID:saharki,项目名称:KinectRaD,代码行数:30,代码来源:ColorRecorder.cs


示例11: KinectSensorColorFrameReady

        void KinectSensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            bool receivedData = false;

            using (ColorImageFrame cFrame = e.OpenColorImageFrame())
            {
                if (cFrame == null)
                {
                    // The image processing took too long. More than 2 frames behind.
                }
                else
                {
                    pixelData = new byte[cFrame.PixelDataLength];
                    cFrame.CopyPixelDataTo(pixelData);
                    receivedData = true;
                }
            }

            if (receivedData)
            {
                BitmapSource source = BitmapSource.Create(640, 480, 96, 96,
                        PixelFormats.Bgr32, null, pixelData, 640 * 4);
                videoImage.Source = source;
            }
        }
开发者ID:emilpytka,项目名称:KinectRobotic,代码行数:25,代码来源:MainWindow.xaml.cs


示例12: SensorColorFrameReady

        public void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            if (bitmap == null) {
            bitmap = ((WSRKinect)WSRConfig.GetInstance().GetWSRMicro()).NewColorBitmap();
              }

              CheckQRCode();
        }
开发者ID:philippetavernier,项目名称:WSRMacro,代码行数:8,代码来源:WSRQRCode.cs


示例13: sensor_ColorFrameReady

 protected void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
 {
     using (var frame = e.OpenColorImageFrame()) {
         if (frame != null) {
             this.ProcessFrame(frame);
         }
     }
 }
开发者ID:gnavvy,项目名称:ParaIF,代码行数:8,代码来源:SDKRgbBitmapDataSource.cs


示例14: kinect_ColorFrameReady

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


示例15: SensorColorFrameReady

        private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            var colorImageFrame = e.OpenColorImageFrame();
            if (colorImageFrame != null)
            {


                var faceDetection = new FaceDetectionRecognition();
                var pixelData = new byte[colorImageFrame.PixelDataLength];
                colorImageFrame.CopyPixelDataTo(pixelData);

                pictureBox3.Image = FaceDetectionRecognition.BytesToBitmap(pixelData, colorImageFrame.Height, colorImageFrame.Width);
                pictureBox3.Refresh();
                var detectedFace = faceDetection.GetDetectedFace(pixelData, colorImageFrame.Height, colorImageFrame.Width);



                if (detectedFace != null)
                {
                    pictureBox4.Image = detectedFace.Bitmap;
                    pictureBox4.Refresh();

                    if (_remainingShots > 0)
                    {
                        faceDetection.SaveNewDetectedFace(_tempName, detectedFace);
                        _remainingShots--;
                    }
                    else
                    {
                        var user = faceDetection.RecognizeFace(detectedFace);


                        if (user != null)
                        {
                            Console.WriteLine("I recognize you with a mouth!, your are: {0}", user.NickName);
                            pictureBox2.Image = user.Face.GetBitmap();
                            pictureBox2.Refresh();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("You are a new user, would you like to be added to the database? Y/N");
                            var key = Console.ReadKey();

                            if (key.KeyChar == 'Y' || key.KeyChar == 'y')
                            {
                                Console.WriteLine("Please provide a nick name for you: ");
                                var name = Console.ReadLine();

                                faceDetection.SaveNewDetectedFace(name, detectedFace);
                                _tempName = name;
                                _remainingShots = 39;
                            }
                        }
                    }
                }
            }
        }
开发者ID:guozanhua,项目名称:KinectFaceRecognition,代码行数:58,代码来源:frmMain.cs


示例16: kinect_ColorFrameReady

 void kinect_ColorFrameReady( object sender, ColorImageFrameReadyEventArgs e )
 {
     // Disposableなのでusingでくくる
     using ( ColorImageFrame colorFrame = e.OpenColorImageFrame() ) {
         if ( colorFrame != null ) {
             imageRgbCamera.Source = colorFrame.ToBitmapSource();
         }
     }
 }
开发者ID:kaorun55,项目名称:KinectSdkIntroduction,代码行数:9,代码来源:MainWindow.xaml.cs


示例17: myKinect_ColorFrameReady

        void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
            {
                if (colorFrame == null) return;

                bmap = OpenCV2WPFConverter.ColorImageFrameToBitmap(colorFrame);

                imgBgr = new Image<Bgr, Byte>(bmap);
                imgHsv = new Image<Hsv, Byte>(bmap);

                if (imgBgr == null || imgHsv == null) return;
                processedBgr = imgBgr.InRange(new Bgr(B_min, G_min, R_min), new Bgr(B_max, G_max, R_max));

                processedHsv = imgHsv.InRange(new Hsv(H_min, S_min, V_min), new Hsv(H_max, S_max, V_max));
                //0,130,0 ~ 120, 256, 120 for green color.
                processedBgr = processedBgr.SmoothGaussian(7);
                processedHsv = processedHsv.SmoothGaussian(7);

                CircleF[] circlesBgr = processedBgr.HoughCircles(cannyThreshold, circleAccumulatorThreshold
                    , 2, processedBgr.Height / 8 , 8, 40)[0];

                CircleF[] circlesHsv = processedBgr.HoughCircles(cannyThreshold, circleAccumulatorThreshold
                    , 2, processedHsv.Height / 8, 8, 40)[0];

                HsvCircleCount = 0;
                RgbCircleCount = 0;

                // Draw Circles for RBG video stream
                foreach (CircleF circle in circlesBgr)
                {

                    RgbCircleCount += 1;
                    imgBgr.Draw(circle, new Bgr(System.Drawing.Color.Bisque), 3);

                }

                // Draw Circles for HSV video stream
                foreach (CircleF circle in circlesHsv)
                {

                    HsvCircleCount += 1;
                    imgBgr.Draw(circle, new Bgr(System.Drawing.Color.Bisque), 3);

                }

                kinectVideo.Source = OpenCV2WPFConverter.ToBitmapSource(imgBgr);
                HsvVideo.Source = OpenCV2WPFConverter.ToBitmapSource(processedHsv);
                RgbVideo.Source = OpenCV2WPFConverter.ToBitmapSource(processedBgr);
                //control the distance of different circles!
                this.HsvCircleUI.Content = HsvCircleCount.ToString();
                this.RgbCircleUI.Content = RgbCircleCount.ToString();

            }
        }
开发者ID:handsomesun,项目名称:hsv-finder,代码行数:55,代码来源:MainWindow.xaml.cs


示例18: miKinect_ColorFrameReady

        void miKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame framesImagen = e.OpenColorImageFrame()) {
                
                if (framesImagen == null) 
                    return;
                
                byte[] datosColor = new byte[framesImagen.PixelDataLength];
                
                framesImagen.CopyPixelDataTo(datosColor);

                if (grabarFoto)
                {
                    bitmapImagen = BitmapSource.Create(
                        framesImagen.Width, framesImagen.Height, 96, 96, PixelFormats.Bgr32, null,
                        datosColor, framesImagen.Width * framesImagen.BytesPerPixel);
                    grabarFoto = false;
                }

                if (WriteableBitmap.IsChecked == true)
                {
                    if (bitmapEficiente == null)
                    {
                        bitmapEficiente = new WriteableBitmap(
                            framesImagen.Width, framesImagen.Height,
                            96,
                            96,
                            PixelFormats.Bgr32,
                            null
                            );
                    }
                    bitmapEficiente.WritePixels(
                        new Int32Rect(0, 0, framesImagen.Width, framesImagen.Height),
                        datosColor,
                        framesImagen.Width * framesImagen.BytesPerPixel,
                        0
                        );

                    colorStream.Source = bitmapEficiente;
                }
                else
                {
                    colorStream.Source = BitmapSource.Create(
                        framesImagen.Width, framesImagen.Height,
                        96,
                        96,
                        PixelFormats.Bgr32,
                        null,
                        datosColor,
                        framesImagen.Width * framesImagen.BytesPerPixel
                        );
                }
            }
        }
开发者ID:egaleano,项目名称:Kinect,代码行数:54,代码来源:MainWindow.xaml.cs


示例19: sensor_ColorFrameReady

 void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
 {
     ColorImageFrame colorFrame = e.OpenColorImageFrame();
     if (colorFrame != null)
     {
         byte[] pixelData = new byte[colorFrame.PixelDataLength];
         colorFrame.CopyPixelDataTo(pixelData);
         BitmapSource source = BitmapSource.Create(640,480,96,96,PixelFormats.Bgr32, null, pixelData, 640*4);
         imgKinect.Source = source;
     }
 }
开发者ID:Thunkar,项目名称:ArmDuino,代码行数:11,代码来源:MainWindow.xaml.cs


示例20: ColorImageReady

        private void ColorImageReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame imageFrame = e.OpenColorImageFrame())
            {
                if (imageFrame != null)
                {
                    // We need to detect if the format has changed.
                    bool haveNewFormat = this.lastImageFormat != imageFrame.Format;

                    if (haveNewFormat)
                    {
                        this.pixelData = new byte[imageFrame.PixelDataLength];
                    }

                    imageFrame.CopyPixelDataTo(this.pixelData);

                    // A WriteableBitmap is a WPF construct that enables resetting the Bits of the image.
                    // This is more efficient than creating a new Bitmap every frame.
                    if (haveNewFormat)
                    {
                        //kinectColorImage.Visibility = Visibility.Visible;
                        this.outputImage = new WriteableBitmap(
                            imageFrame.Width,
                            imageFrame.Height,
                            96,  // DpiX
                            96,  // DpiY
                            PixelFormats.Bgr32,
                            null);

                        this.kinectColorImage.Source = this.outputImage;
                    }

                    this.outputImage.WritePixels(
                        new Int32Rect(0, 0, imageFrame.Width, imageFrame.Height),
                        this.pixelData,
                        imageFrame.Width * Bgr32BytesPerPixel,
                        0);

                    this.lastImageFormat = imageFrame.Format;

                    var stream = new MemoryStream();
                    var encoder = new JpegBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(outputImage));
                    encoder.Save(stream);
                    byte[] buffer = stream.GetBuffer();
                    //gui.colorImage.Image = new System.Drawing.Bitmap(new MemoryStream(buffer));

                    stream.Close();

                    UpdateFrameRate();
                }
            }
        }
开发者ID:khaerul10056,项目名称:OmicronInputConnector,代码行数:53,代码来源:KinectColorViewer.xaml.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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