1
我想從Microsoft Kinect彩色攝像機視頻流中分離紅色,綠色,藍色的彩色流。到目前爲止,爲了接收彩色視頻流,我使用了Kinect for Windows SDK 2.0提供的示例代碼。來自Microsoft Kinect彩色攝像機視頻流的獨立紅色流
每當接收到新幀時,彩色幀的事件處理程序就會將幀寫入WriteableBitmap對象。在複製到WriteableBitmap對象之前,如何將紅色流從彩色框中分離出來?
private void Reader_ColorFrameArrived(object sender, ColorFrameArrivedEventArgs e)
{
// ColorFrame is IDisposable
using (ColorFrame colorFrame = e.FrameReference.AcquireFrame())
{
if (colorFrame != null)
{
FrameDescription colorFrameDescription = colorFrame.FrameDescription;
using (KinectBuffer colorBuffer = colorFrame.LockRawImageBuffer())
{
this.colorBitmap.Lock();
// verify data and write the new color frame data to the display bitmap
if ((colorFrameDescription.Width == this.colorBitmap.PixelWidth) && (colorFrameDescription.Height == this.colorBitmap.PixelHeight))
{
colorFrame.CopyConvertedFrameDataToIntPtr(
this.colorBitmap.BackBuffer,
(uint)(colorFrameDescription.Width * colorFrameDescription.Height * 4),
ColorImageFormat.Bgra);
this.colorBitmap.AddDirtyRect(new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight));
}
this.colorBitmap.Unlock();
}
}
}
}
日報.NET技巧有article關於這個,但他們在這裏展示的代碼是不夠清晰。 This是我需要的結果(以及一篇Daily .NET Tips在他們的文章中顯示)。
請幫忙。
如何以字節爲單位存儲數據? – misfitmaniac
我在一些帖子中看到了這個LOC,但這僅適用於WriteableBitmap對象。 'byte * imgData =(byte *)bitmap.BackBuffer;' 但是我想在將Kinect中的幀數據寫入位圖對象之前以字節爲單位存儲和處理幀數據。 – misfitmaniac