Microsoft Kinect SDK深度数据到真实世界的坐标 [英] Microsoft Kinect SDK depth data to real world coordinates

查看:96
本文介绍了Microsoft Kinect SDK深度数据到真实世界的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Kinect SDK从Kinect获取深度和颜色信息,然后将该信息转换为点云.我需要深度信息在真实世界中以相机中心为原点的坐标.

I'm using the Microsoft Kinect SDK to get the depth and color information from a Kinect and then convert that information into a point cloud. I need the depth information to be in real world coordinates with the centre of the camera as the origin.

我已经看到了许多转换函数,但是这些转换函数显然适用于OpenNI和非Microsoft驱动程序.我已经知道来自Kinect的深度信息已经以毫米为单位,并包含在11位中……等等.

I've seen a number of conversion functions but these are apparently for OpenNI and non-Microsoft drivers. I've read that the depth information coming from the Kinect is already in millimetres, and is contained in the 11bits... or something.

如何将这些位信息转换为可以使用的真实世界坐标?

How do I convert this bit information into real world coordinates that I can use?

提前谢谢!

推荐答案

这是使用 Microsoft.Research.Kinect.Nui.SkeletonEngine类在Windows Kinect for Windows库中解决的.方法:

This is catered for within the Kinect for Windows library using the Microsoft.Research.Kinect.Nui.SkeletonEngine class, and the following method:

public Vector DepthImageToSkeleton (
    float depthX,
    float depthY,
    short depthValue
)

此方法将根据实际测量结果将Kinect生成的深度图像映射到矢量可缩放的图像中.

This method will map the depth image produced by the Kinect into one that is vector scalable, based on real world measurements.

从那里(当我过去创建网格时),在枚举Kinect深度图像创建的位图中的字节数组之后,您将创建一个新的Vector点列表,类似于以下内容:

From there (when I've created a mesh in the past), after enumerating the byte array in the bitmap created by the Kinect depth image, you create a new list of Vector points similar to the following:

        var width = image.Image.Width;
        var height = image.Image.Height;
        var greyIndex = 0;

        var points = new List<Vector>();

        for (var y = 0; y < height; y++)
        {
            for (var x = 0; x < width; x++)
            {
                short depth;
                switch (image.Type)
                {
                    case ImageType.DepthAndPlayerIndex:
                        depth = (short)((image.Image.Bits[greyIndex] >> 3) | (image.Image.Bits[greyIndex + 1] << 5));
                        if (depth <= maximumDepth)
                        {
                            points.Add(nui.SkeletonEngine.DepthImageToSkeleton(((float)x / image.Image.Width), ((float)y / image.Image.Height), (short)(depth << 3)));
                        }
                        break;
                    case ImageType.Depth: // depth comes back mirrored
                        depth = (short)((image.Image.Bits[greyIndex] | image.Image.Bits[greyIndex + 1] << 8));
                        if (depth <= maximumDepth)
                        {
                            points.Add(nui.SkeletonEngine.DepthImageToSkeleton(((float)(width - x - 1) / image.Image.Width), ((float)y / image.Image.Height), (short)(depth << 3)));
                        }
                        break;
                }

                greyIndex += 2;
            }
        }

这样做,最终结果是一个以毫米为单位存储的向量列表,如果要让厘米乘以100(等等).

By doing so, the end result from this is a list of vectors stored in millimeters, and if you want centimeters multiply by 100 (etc.).

这篇关于Microsoft Kinect SDK深度数据到真实世界的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆