Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C语言的Kinect v2颜色深度映射#_C#_Kinect_Kinect Sdk - Fatal编程技术网

C# 使用C语言的Kinect v2颜色深度映射#

C# 使用C语言的Kinect v2颜色深度映射#,c#,kinect,kinect-sdk,C#,Kinect,Kinect Sdk,我试图使用sdk中的coordinateMapper函数将深度贴图映射到颜色空间。然而,我收到的输出不是我预期的,它似乎有一个较小的纵横比,图像似乎是镜像 下面是我使用的代码: depthWidth = depthFrameDescription.Width; depthHeight = depthFrameDescription.Height; var colorDesc = colorFrame.FrameDescription; int colorWidth = colorDesc.Wi

我试图使用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;

如果尝试将深度帧的坐标映射到颜色帧,则缺少一个步骤

下面是一个链接,它可能更好地解释了我可以:

但在你的情况下,当你使用

coordinateMapper.MapColorFrameToDepthSpace(frameData, colSpacePoints);
输出不能用于您使用它的方式。此函数的输出包含颜色空间和深度空间中存在的所有点。为了显示这些,你需要迭代你的colSpacePoints并对每个结果做一些处理,在我链接的例子中,它被称为_colorSpacePoints,这样你就可以看到他用它做了什么

我一直试图做一些类似于您正在做的事情,但是几天后我发现了如何正确使用映射。如果您想在问题上获得更多帮助,请告诉我您希望在WriteableBitmap中显示什么