예제 #1
0
 protected virtual void OnColorFrameReceived(KinectBase.ColorFrameEventArgs e)
 {
     if (ColorFrameReceived != null)
     {
         ColorFrameReceived(this, e);
     }
 }
예제 #2
0
        void irReader_FrameArrived(object sender, InfraredFrameArrivedEventArgs e)
        {
            using (InfraredFrame frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    FrameDescription desc = frame.FrameDescription;

                    KinectBase.ColorFrameEventArgs irE = new KinectBase.ColorFrameEventArgs();
                    irE.bytesPerPixel = (int)desc.BytesPerPixel;
                    irE.pixelFormat   = PixelFormats.Gray16;
                    irE.height        = desc.Height;
                    irE.width         = desc.Width;
                    irE.kinectID      = kinectID;
                    irE.timeStamp     = frame.RelativeTime;
                    irE.isIR          = true;
                    //irE.image = new byte[desc.LengthInPixels * sizeof(UInt16)];
                    irE.image = irImagePool.GetObject();
                    unsafe
                    {
                        fixed(byte *ptr = irE.image)
                        {
                            frame.CopyFrameDataToIntPtr((IntPtr)ptr, desc.LengthInPixels * sizeof(UInt16));
                        }
                    }

                    OnColorFrameReceived(irE);
                }
            }
        }
예제 #3
0
 private void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
 {
     using (ColorImageFrame frame = e.OpenColorImageFrame())
     {
         if (frame != null)
         {
             KinectBase.ColorFrameEventArgs colorE = new KinectBase.ColorFrameEventArgs();
             colorE.kinectID = this.kinectID;
             if (frame.Format == ColorImageFormat.InfraredResolution640x480Fps30)
             {
                 colorE.pixelFormat = PixelFormats.Gray16;
                 colorE.isIR        = true;
             }
             else
             {
                 colorE.pixelFormat = PixelFormats.Bgr32;
                 colorE.isIR        = false;
             }
             colorE.width         = frame.Width;
             colorE.height        = frame.Height;
             colorE.bytesPerPixel = frame.BytesPerPixel;
             colorE.timeStamp     = new TimeSpan(frame.Timestamp * 10000); //Convert from milliseconds to ticks and set the time span
             //colorE.image = new byte[frame.PixelDataLength];
             colorE.image = colorImagePool.GetObject();                    //Get an array from the image pool
             if (colorE.image.Length != frame.PixelDataLength)             //If the image array is the wrong size, create a new one (it will get cycled into the pool on its own later)
             {
                 colorE.image = new byte[frame.PixelDataLength];
             }
             frame.CopyPixelDataTo(colorE.image);
             OnColorFrameReceived(colorE);
         }
     }
 }
예제 #4
0
        void colorReader_FrameArrived(object sender, ColorFrameArrivedEventArgs e)
        {
            using (ColorFrame frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    FrameDescription desc = frame.FrameDescription;

                    KinectBase.ColorFrameEventArgs colorE = new KinectBase.ColorFrameEventArgs();
                    colorE.bytesPerPixel = 4; //This is fixed to 4 because we are converting to bgra below)
                    colorE.pixelFormat   = PixelFormats.Bgra32;
                    colorE.height        = desc.Height;
                    colorE.width         = desc.Width;
                    colorE.kinectID      = kinectID;
                    colorE.timeStamp     = frame.RelativeTime;
                    colorE.isIR          = false;
                    colorE.image         = colorImagePool.GetObject();
                    //colorE.image = new byte[desc.LengthInPixels * colorE.bytesPerPixel];
                    //frame.CopyConvertedFrameDataToArray(colorE.image, ColorImageFormat.Bgra);
                    unsafe
                    {
                        fixed(byte *ptr = colorE.image)
                        {
                            frame.CopyConvertedFrameDataToIntPtr((IntPtr)ptr, desc.LengthInPixels * sizeof(byte) * 4, ColorImageFormat.Bgra);
                        }
                    }

                    OnColorFrameReceived(colorE);
                }
            }
        }
예제 #5
0
        protected virtual void OnColorFrameReceived(KinectBase.ColorFrameEventArgs e)
        {
            if (ColorFrameReceived != null)
            {
                ColorFrameReceived(this, e);
            }

            //Put the object back in the image pool
            if (e.isIR)
            {
                irImagePool.PutObject(e.image);
            }
            else
            {
                colorImagePool.PutObject(e.image);
            }
        }
예제 #6
0
        void irReader_FrameArrived(object sender, InfraredFrameArrivedEventArgs e)
        {
            using (InfraredFrame frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    FrameDescription desc = frame.FrameDescription;

                    KinectBase.ColorFrameEventArgs irE = new KinectBase.ColorFrameEventArgs();
                    irE.bytesPerPixel = (int)desc.BytesPerPixel;
                    irE.pixelFormat = PixelFormats.Gray16;
                    irE.height = desc.Height;
                    irE.width = desc.Width;
                    irE.kinectID = kinectID;
                    irE.timeStamp = frame.RelativeTime;
                    irE.isIR = true;
                    //irE.image = new byte[desc.LengthInPixels * sizeof(UInt16)];
                    irE.image = irImagePool.GetObject();
                    unsafe
                    {
                        fixed (byte* ptr = irE.image)
                        {
                            frame.CopyFrameDataToIntPtr((IntPtr)ptr, desc.LengthInPixels * sizeof(UInt16));
                        }
                    }

                    OnColorFrameReceived(irE);
                }
            }
        }
예제 #7
0
        void colorReader_FrameArrived(object sender, ColorFrameArrivedEventArgs e)
        {
            using (ColorFrame frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    FrameDescription desc = frame.FrameDescription;

                    KinectBase.ColorFrameEventArgs colorE = new KinectBase.ColorFrameEventArgs();
                    colorE.bytesPerPixel = 4; //This is fixed to 4 because we are converting to bgra below)
                    colorE.pixelFormat = PixelFormats.Bgra32;
                    colorE.height = desc.Height;
                    colorE.width = desc.Width;
                    colorE.kinectID = kinectID;
                    colorE.timeStamp = frame.RelativeTime;
                    colorE.isIR = false;
                    colorE.image = colorImagePool.GetObject();
                    //colorE.image = new byte[desc.LengthInPixels * colorE.bytesPerPixel];
                    //frame.CopyConvertedFrameDataToArray(colorE.image, ColorImageFormat.Bgra);
                    unsafe
                    {
                        fixed (byte* ptr = colorE.image)
                        {
                            frame.CopyConvertedFrameDataToIntPtr((IntPtr)ptr, desc.LengthInPixels * sizeof(byte) * 4, ColorImageFormat.Bgra);
                        }
                    }

                    OnColorFrameReceived(colorE);
                }
            }
        }
예제 #8
0
 private void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
 {
     using (ColorImageFrame frame = e.OpenColorImageFrame())
     {
         if (frame != null)
         {
             KinectBase.ColorFrameEventArgs colorE = new KinectBase.ColorFrameEventArgs();
             colorE.kinectID = this.kinectID;
             if (frame.Format == ColorImageFormat.InfraredResolution640x480Fps30)
             {
                 colorE.pixelFormat = PixelFormats.Gray16;
                 colorE.isIR = true;
             }
             else
             {
                 colorE.pixelFormat = PixelFormats.Bgr32;
                 colorE.isIR = false;
             }
             colorE.width = frame.Width;
             colorE.height = frame.Height;
             colorE.bytesPerPixel = frame.BytesPerPixel;
             colorE.timeStamp = new TimeSpan(frame.Timestamp * 10000);  //Convert from milliseconds to ticks and set the time span
             //colorE.image = new byte[frame.PixelDataLength];
             colorE.image = colorImagePool.GetObject();  //Get an array from the image pool
             if (colorE.image.Length != frame.PixelDataLength)  //If the image array is the wrong size, create a new one (it will get cycled into the pool on its own later)
             {
                 colorE.image = new byte[frame.PixelDataLength];
             }
             frame.CopyPixelDataTo(colorE.image);
             OnColorFrameReceived(colorE);
         }
     }
 }