gpt4 book ai didi

c# - 使用 C# 的 Kinect v2 颜色深度映射

转载 作者:行者123 更新时间:2023-11-30 18:25:53 25 4
gpt4 key购买 nike

我正在尝试使用 sdk 中的 coordinateMapper 函数将深度图映射到颜色空间。然而,我收到的输出并不是我所期望的,它的纵横比似乎更小,而且图像似乎是镜像的。

下面是我使用的代码:

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;

最佳答案

如果您尝试将深度框架的坐标映射到彩色框架,则您错过了一个步骤。

这是一个链接,我可以更好地解释它: http://www.bryancook.net/2014/03/mapping-between-kinect-color-and-depth.html

但是在你使用的情况下

coordinateMapper.MapColorFrameToDepthSpace(frameData, colSpacePoints);

输出不会按照您的使用方式使用。此函数的输出包含存在于颜色空间和深度空间中的所有点。因此,为了显示这些,您需要遍历 colSpacePoints 并对每个结果做一些事情,在我链接的示例中,它称为 _colorSpacePoints,因此您可以查看他用它做了什么。

我一直在尝试做可能与您正在做的事情类似的事情,但是几天后我发现了如何正确使用映射。如果您需要有关问题的更多帮助,请告诉我您希望在 WriteableBitmap 中显示什么。

关于c# - 使用 C# 的 Kinect v2 颜色深度映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29479746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com