【问题标题】:Kinect depth and color imageKinect 深度和彩色图像
【发布时间】:2014-06-04 08:10:48
【问题描述】:

深度图到点颜色图有一点问题, 我只是简单地阈值最近的深度(大约 70-80 厘米),然后我按位和阈值深度图像到相应的颜色图,

Mat depthFilter(Mat depth,Mat color){
Mat I;
depth.convertTo(I, CV_8UC1, 255.0 / 4096.0);
unsigned char *input = (unsigned char*)(I.data);
for (int i = 0; i < I.cols; i++){
    for (int j = 0; j < I.rows; j++){
        int pixel = input[I.cols*j + i];
        if (!(pixel <52 && pixel >42)){
            input[I.cols*j + i] = 0;
        }
        else
        {
            input[I.cols*j + i] = 255;
        }
    }
}
cvtColor(color, color, CV_BGR2GRAY);
bitwise_and(I, color, I);
return I;

} (我正在使用 OpenCvKinect,它使用 OpenNi 和 OpenCv) 但我的问题是,要点不一样..我想我需要找到两个图像之间的一些关系,但是如何:)!

http://postimg.org/image/hyxt25bwd/

【问题讨论】:

  • 深度图和RGB图像好像没有注册,尝试在Kinect上开启注册模式。

标签: opencv kinect


【解决方案1】:

我会看到Why kinect color and depth won't align correctly?,因为他们在 matlab 中遇到了类似的问题。答案建议使用 OpenNI 的 AlternateViewCapability 类来对齐图像。这是旧版本 OpenNI (1.5) 的文档,因为我找不到 C++ 的 2.0 文档,但可能有类似的方法。该答案上的图像显示了转变所产生的差异。

代码本质上是

depth.GetAlternativeViewPointCap().SetViewPoint(image); //depth is depth generator
                                                        //image is color generator

【讨论】:

    【解决方案2】:

    我不确定你是否已经解决了对齐问题,但是这已经在你已经使用的 OpenCVKinect Wrappers 中实现了。

    要从 Kinect 获取对齐的深度和彩色图像,您需要使用 setMode 函数,如下所示:

    setMode(C_MODE_DEPTH | C_MODE_COLOR | C_MODE_ALIGNED);
    

    【讨论】:

      猜你喜欢
      • 2011-10-14
      • 2015-04-04
      • 2014-11-05
      • 2013-11-24
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2021-10-06
      • 2014-11-17
      相关资源
      最近更新 更多