gpt4 book ai didi

matlab - 为什么 kinect 颜色和深度不能正确对齐?

转载 作者:太空宇宙 更新时间:2023-11-03 19:41:58 26 4
gpt4 key购买 nike

我已经在这个问题上工作了很长一段时间,但我的创造力已经走到了尽头,所以希望其他人可以帮助我指明正确的方向。我一直在使用 Kinect 并尝试将数据捕获到 MATLAB。幸运的是,有很多方法可以做到这一点(我目前正在使用 http://www.mathworks.com/matlabcentral/fileexchange/30242-kinect-matlab )。当我尝试将捕获的数据投影到 3D 时,我的传统方法给出了很差的重建结果。

长话短说,我最终为执行重建和对齐的 matlab 编写了一个 Kinect SDK 包装器。重建工作如梦如幻,但是......

正如您在此处看到的那样,我在对齐方面遇到了很多麻烦:

enter image description here

请不要太仔细地看模型:(。

如您所见,对齐方式不正确。我不确定为什么会这样。我已经阅读了很多论坛,其中其他人使用相同的方法比我更成功。

我目前的流程是使用 Kinect Matlab(使用 Openni)捕获数据,使用 Kinect SDK 重建,然后使用 Kinect SDK 对齐(通过 NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution)。我怀疑这可能是由于 Openni,但我在创建 mex 函数调用以使用 Kinect SDK 进行捕获方面收效甚微。

如果有人能指出我应该更深入研究的方向,我们将不胜感激。

编辑:

图我应该发布一些代码。这是我用于对齐的代码:

    /* The matlab mex function */
void mexFunction( int nlhs, mxArray *plhs[], int nrhs,
const mxArray *prhs[] ){

if( nrhs < 2 )
{
printf( "No depth input or color image specified!\n" );
mexErrMsgTxt( "Input Error" );
}

int width = 640, height = 480;

// get input depth data

unsigned short *pDepthRow = ( unsigned short* ) mxGetData( prhs[0] );
unsigned char *pColorRow = ( unsigned char* ) mxGetData( prhs[1] );

// compute the warping

INuiSensor *sensor = CreateFirstConnected();
long colorCoords[ 640*480*2 ];
sensor->NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution(
NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480,
640*480, pDepthRow, 640*480*2, colorCoords );
sensor->NuiShutdown();
sensor->Release();

// create matlab output; it's a column ordered matrix ;_;

int Jdimsc[3];
Jdimsc[0]=height;
Jdimsc[1]=width;
Jdimsc[2]=3;

plhs[0] = mxCreateNumericArray( 3, Jdimsc, mxUINT8_CLASS, mxREAL );
unsigned char *Iout = ( unsigned char* )mxGetData( plhs[0] );

for( int x = 0; x < width; x++ )
for( int y = 0; y < height; y++ ){

int idx = ( y*width + x )*2;
long c_x = colorCoords[ idx + 0 ];
long c_y = colorCoords[ idx + 1 ];

bool correct = ( c_x >= 0 && c_x < width
&& c_y >= 0 && c_y < height );
c_x = correct ? c_x : x;
c_y = correct ? c_y : y;

Iout[ 0*height*width + x*height + y ] =
pColorRow[ 0*height*width + c_x*height + c_y ];
Iout[ 1*height*width + x*height + y ] =
pColorRow[ 1*height*width + c_x*height + c_y ];
Iout[ 2*height*width + x*height + y ] =
pColorRow[ 2*height*width + c_x*height + c_y ];

}

}

最佳答案

这是立体视觉系统的一个众所周知的问题。前一段时间我遇到了同样的问题。我发布的原始问题可以找到here .我正在尝试做的事情与此类似。然而,经过大量研究后,我得出的结论是捕获的数据集不容易对齐。

另一方面,在记录数据集时,您可以轻松地使用函数调用来对齐 RGB 和深度数据。该方法在OpenNI和Kinect SDK中都有(功能相同,只是函数调用名称不同)

看起来您正在使用 Kinect SDK 捕获数据集,要将数据与 Kinect SDK 对齐,您可以使用 MapDepthFrameToColorFrame .

由于您还提到了使用 OpenNI,请查看 AlternativeViewPointCapability .

我没有使用 Kinect SDK 的经验,但是对于 OpenNI v1.5,在注册记录器节点之前通过调用以下函数解决了整个问题:

depth.GetAlternativeViewPointCap().SetViewPoint(image);

其中 image 是图像生成器节点,depth 是深度生成器节点。这是旧版 SDK 已被 OpenNI 2.0 SDK 取代。因此,如果您使用的是最新的 SDK,那么函数调用可能会有所不同,但整体过程可能是相似的。

我还添加了一些示例图片:

不使用上述对齐函数调用 RGB 上的深度边缘未对齐 Without Alignment

当使用函数调用时,深度边缘得到完美对齐(有一些红外阴影区域显示了一些边缘,但它们只是无效的深度区域) With Alignment

关于matlab - 为什么 kinect 颜色和深度不能正确对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18050285/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com