protected virtual void OnColorFrameReceived(KinectBase.ColorFrameEventArgs e) { if (ColorFrameReceived != null) { ColorFrameReceived(this, e); } }
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); } } }
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); } } }
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); } } }
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); } }
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); } } }
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); } } }