需要建议使用 kinect 在 opencv 中找到最近的块

发布于 2024-12-08 18:19:14 字数 448 浏览 0 评论 0原文

我对opencv完全陌生,最近我被分配了一项任务,寻找kinect检测到的最近斑点的中心,这意味着如果你在kinect面前伸出你的手,那么你的手就会成为与kinect相比最接近的斑点你的身体。

我获得了一个示例代码,也可以在此处在线找到。到目前为止,我只能想到两种方法,一种是使用 cvFindContours() 获取对象的所有轮廓,然后循环遍历每个轮廓并找到最接近的轮廓。问题是我不知道该怎么做,因为我不知道是否有函数可以用来获取每个轮廓的深度信息。

我的第二个想法是循环遍历 heightMat 矩阵,找到最低值(应该是最近的点),然后传播出去找到一个块,然后绘制该块。这样做的问题是需要进行大量计算,导致我的 kinect 视频响应速度非常慢。

有人对这个任务有好的建议吗?谢谢。

I'm totally new to opencv, and I was recently assigned an assignment to find the center of the closest blob detected by kinect, which means that if you reach out your hands in front of kinect, then your hands become the closest blobs compared to your body.

I'm given a sample code, which can also be found online at here. So far I can only think of 2 approaches, one is using cvFindContours() to get all contours of objects, and loop though each of them and find the closest one. The problem is I don't know how to do that, because I don't know if there are functions that I can use to get each contour's depth information.

My second idea is to just loop though the depthMat matrix, and find the lowest value, which is supposed to be the closest point, and propagate out to find a block, and draw the block. The problem with this is that it takes so many calculations that my kinect video response very slowly.

Does anyone have a good suggestion on this task? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅忆流年 2024-12-15 18:19:14

您可以尝试迭代范围选通。 Kinect 的最大有效范围约为 6m,因此对于有限的距离,这可能有效。

假设深度以厘米为单位(如果以计数为单位,则将计数划分为 10、100 或 1000 计数等合适的容器)。

Mat depthData, objectMask;
Mat closestDepth, closestObjectMask, closestDist;

// getting depth data from kinect out here...

for(int i = 600; i > 0; i -= 20)
{
    threshold(depthData, objectMask, (double)i, 1, THRESH_BINARY_INV);
    // gated out all objects (may need to adjust pixel count for best results)
    Scalar pixelCount = sum(objectMask);
    if(pixelCount.val[0] < 1.0) 
    {
        break;
    }

    closestDepth = depthData; // last good depth data
    closestObjectMask = objectMask; // last good object mask
    closestDist = i; // last closest distance
}

一旦循环中断,您应该得到以下结果:

  • closestDepth - 应该是深度图像,用于通过将其与蒙版相乘来获取实际对象距离。
  • closestDist - 应该是“黑掉”之前距离门的距离
  • closestObjectMask - 应该是最近对象的掩码(用最大轮廓或类似的东西跟踪它)

希望这有帮助!

You could try iterative range gating. The maximum effective range on the Kinect is about 6m, so for limited distances this might work.

Assuming depth is in centimeters (if it's in counts, divide counts up into bins of say 10, 100 or 1000 counts whatever seems appropriate).

Mat depthData, objectMask;
Mat closestDepth, closestObjectMask, closestDist;

// getting depth data from kinect out here...

for(int i = 600; i > 0; i -= 20)
{
    threshold(depthData, objectMask, (double)i, 1, THRESH_BINARY_INV);
    // gated out all objects (may need to adjust pixel count for best results)
    Scalar pixelCount = sum(objectMask);
    if(pixelCount.val[0] < 1.0) 
    {
        break;
    }

    closestDepth = depthData; // last good depth data
    closestObjectMask = objectMask; // last good object mask
    closestDist = i; // last closest distance
}

Once that loop breaks out, you should have the following:

  • closestDepth - should be depth image to use to get actual object distance by multiplying it with the mask.
  • closestDist - should be the distance of the range gate before "black out"
  • closestObjectMask - should be a mask of the closest object (track it with largest contour or something similar)

Hope that's helpful!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文