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

我已经在这个问题上工作了很长一段时间,并且在我的创造力结束时,所以希望其他人可以帮助我指出正确的方向.我一直在使用Kinect并尝试将数据捕获到MATLAB.幸运的是有很多方法(我目前正在使用

http://www.mathworks.com/matlabcentral/fileexchange/30242-kinect-matlab).当我试图将捕获的数据投影到3D时,我的传统方法给出了很差的重建结果.

简而言之,我最终为matlab编写了一个Kinect SDK包装器,用于执行重建和对齐.重建就像一场梦,但……

我在这里看到了很多问题,你可以看到:

请不要过分关注模型:(.

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

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

如果有人能指出我应该深入研究的方向,那将非常感激.

编辑:

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

/* 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 ];

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值