當前位置: 首頁>>代碼示例>>C#>>正文


C# Kinect.ColorImageFrameReadyEventArgs類代碼示例

本文整理匯總了C#中Microsoft.Kinect.ColorImageFrameReadyEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# ColorImageFrameReadyEventArgs類的具體用法?C# ColorImageFrameReadyEventArgs怎麽用?C# ColorImageFrameReadyEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ColorImageFrameReadyEventArgs類屬於Microsoft.Kinect命名空間,在下文中一共展示了ColorImageFrameReadyEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Microsoft.Kinect.ColorImageFrameReadyEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。