2
我想使用sdk中的coordinateMapper函數將深度圖映射到顏色空間。但是,我收到的輸出結果並不符合我的預期,它的縱橫比似乎較小,圖像似乎是鏡像的。使用C的Kinect v2顏色深度映射#
下面是我使用的代碼:
depthWidth = depthFrameDescription.Width;
depthHeight = depthFrameDescription.Height;
var colorDesc = colorFrame.FrameDescription;
int colorWidth = colorDesc.Width;
int colorHeight = colorDesc.Height;
int size = colorWidth * colorHeight;
DepthSpacePoint[] colSpacePoints = new DepthSpacePoint[colorWidth * colorHeight];
using (KinectBuffer depthFrameData = depthFrame.LockImageBuffer())
using (KinectBuffer colorBuffer = colorFrame.LockRawImageBuffer())
{
this.bitmap.Lock();
if ((colorWidth == this.bitmap.PixelWidth) && (colorHeight == this.bitmap.PixelHeight))
{
byte[] colorFrameData = new byte[size * bytesPerPixel];
// Map the values here
ushort [] frameData = new ushort[depthWidth * depthHeight];
depthFrame.CopyFrameDataToArray(frameData);
coordinateMapper.MapColorFrameToDepthSpace(frameData, colSpacePoints);
this.bitmap.WritePixels(new Int32Rect(0, 0, colorWidth, colorHeight), colSpacePoints, colorWidth * bytesPerPixel, 0);
this.bitmap.AddDirtyRect(new Int32Rect(0, 0, this.bitmap.PixelWidth, this.bitmap.PixelHeight));
}
this.bitmap.Unlock();
}
this.bitmapBackBufferSize = (uint)![enter image description here][1]((this.bitmap.BackBufferStride * (this.bitmap.PixelHeight - 1)) + (this.bitmap.PixelWidth * this.bytesPerPixel));
isBitmapLocked = true;