Object 获取其他对象的深度Kinect

Object 获取其他对象的深度Kinect,object,opencv,kinect,tracking,depth,Object,Opencv,Kinect,Tracking,Depth,我是kinect编程的新手,我正在使用kinect和opencv进行球跟踪。我们都知道kinect提供深度数据,代码如下: DepthImagePoint righthandDepthPoint = sensor.CoordinateMapper.MapSkeletonPointToDepthPoint ( me.Joints[JointType.HandRight].Position, DepthImageFormat.Resolution6

我是kinect编程的新手,我正在使用kinect和opencv进行球跟踪。我们都知道kinect提供深度数据,代码如下:

DepthImagePoint righthandDepthPoint = 
    sensor.CoordinateMapper.MapSkeletonPointToDepthPoint
    (
        me.Joints[JointType.HandRight].Position, 
        DepthImageFormat.Resolution640x480Fps30
    );

double rightdepthmeters = (righthandDepthPoint.Depth);
使用此函数,我可以通过指定jointtype,使用函数
MapSkeletonPointToDepthPoint()
获得右手的深度

是否可以通过在图像中指定位置来获取其他对象的深度?
给定坐标..我想获取该坐标中对象的深度?

可以从结构中提取Kinect SDK中的深度数据

下面的示例代码在整个
DepthImageFrame
中循环,以检查每个像素。如果要查看特定坐标,请删除
for
循环,并将
x
y
设置为特定值

// global variables

private const DepthImageFormat DepthFormat = DepthImageFormat.Resolution320x240Fps30;
private const ColorImageFormat ColorFormat = ColorImageFormat.RgbResolution640x480Fps30;

private DepthImagePixel[] depthPixels;

// defined in an initialization function

this.depthWidth = this.sensor.DepthStream.FrameWidth;
this.depthHeight = this.sensor.DepthStream.FrameHeight;

this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];

private void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e)
{
    if (null == this.sensor)
        return;

    bool depthReceived = false;

    using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
    {
        if (null != depthFrame)
        {
            // Copy the pixel data from the image to a temporary array
            depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);

            depthReceived = true;
        }
    }

    if (true == depthReceived)
    {
        // loop over each row and column of the depth
        for (int y = 0; y < this.depthHeight; ++y)
        {
            for (int x = 0; x < this.depthWidth; ++x)
            {
                // calculate index into depth array
                int depthIndex = x + (y * this.depthWidth);

                // extract the given index
                DepthImagePixel depthPixel = this.depthPixels[depthIndex];

                Debug.WriteLine("Depth at [" + x + ", " + y + "] is: " + depthPixel.Depth);
            }
        }
    }
}
//全局变量
private const DepthImageFormat DepthFormat=DepthImageFormat.resolution 320x240fps30;
private const ColorImageFormat ColorFormat=ColorImageFormat.RgbResolution640x480Fps30;
私有深度图像像素[]深度像素;
//在初始化函数中定义
this.depthWidth=this.sensor.DepthStream.FrameWidth;
this.depthHeight=this.sensor.DepthStream.FrameHeight;
this.depthPixels=新的DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
私有void传感器AllFramesReady(对象发送方,AllFramesReadyEventArgs e)
{
if(null==此传感器)
返回;
bool depthReceived=假;
使用(DepthImageFrame depthFrame=e.OpenDepthImageFrame())
{
如果(空!=深度帧)
{
//将像素数据从图像复制到临时阵列
CopyDepthImagePixelDataTo(this.depthPixels);
深度接收=真;
}
}
if(true==depthReceived)
{
//在深度的每行和每列上循环
对于(int y=0;y
先生,我还有一个问题..depthPixels.Depth是用来返回深度的毫米单位,还是我仍然需要进行一些转换。。此代码非常有效。然而,返回的深度不同于以毫米为单位的骨架关节。我看到了大量的数字,尽管我的对象如此接近,但我是否做错了什么,或者此代码是否工作正常?值应以毫米为单位。