返回首页

大家好,我很新编程和玩弄OPENCV和KINECT SDK和刚刚alittle帮助寻找。

我已设法按照SDK例子,显示深度流和流的RGB KINECT使用OpenCV,但是现在我不能似乎做任何图像处理深度流了未处理的异常错误。

的错误,我不断收到国家

未处理的异常在0x75acb9bc在AdvancedTopic1.exe:微软C异常:CV ::在内存位置0x002bf41c异常..

任何先进的
帮助表示感谢
任何方式,到目前为止,这是我的代码:


//Create Depth Image

int createDepthImage(HANDLE h, IplImage* depth)

{

const NUI_IMAGE_FRAME * pImageFrame = NULL;

HRESULT hr = NuiImageStreamGetNextFrame(h, 0, &pImageFrame);

 

if (FAILED (hr))

{ 

cout << "Create Depth Image Failed\n";

//system ("PAUSE");

}

 

NuiImageBuffer * pTexture = pImageFrame ->pFrameTexture;

KINECT_LOCKED_RECT LockedRect;

pTexture->LockRect (0, &LockedRect, NULL, 0);

 

if (LockedRect.Pitch != 0)

{

USHORT * pBuff = (USHORT*) LockedRect.pBits;

for(int i=0; i<(320*240); i++)

{

 

BYTE index = pBuff[i]&0x07;

USHORT realDepth = (pBuff[i]&0xFFF8)>>3;

BYTE scale = 255 - (BYTE)(256*realDepth/0x0fff);

buf[CHANNEL*i] = buf[CHANNEL*i+1] =buf[CHANNEL *i+2] =0;

switch(index)

{

case 0:

buf[CHANNEL*i] = scale/2;

buf[CHANNEL*i+1] = scale/2;

buf[CHANNEL*i+2]=scale/2;

break;

 

case 1:

buf[CHANNEL*i]=scale;

break;

 

case 2:

buf[CHANNEL*i+1]=scale;

break;

 

case 3:

buf[CHANNEL*i+2]=scale;

break;

 

case 4:

buf[CHANNEL*i]=scale;

buf[CHANNEL*i+1]=scale;

break;

 

case 5:

buf[CHANNEL*i]=scale;

buf[CHANNEL*i+2]=scale;

break;

 

case 6:

buf[CHANNEL*i+1]=scale;

buf[CHANNEL*i+2]=scale;

break;

case 7:

buf[CHANNEL*i]=255-scale/2;

buf[CHANNEL*i+1]=255-scale/2;

buf[CHANNEL*i+2]=255-scale/2;

break;

}

 

}

cvSetData(depth, buf, 320*CHANNEL);

}

 

NuiImageStreamReleaseFrame(h, pImageFrame);

cvShowImage("Depth Image",depth);

cvCvtColor(depth, depth, CV_RGB2GRAY);

return 0;

}

<pre lang="c++">

 

The error i keep getting states

 

Unhandled exception at 0x75acb9bc in AdvancedTopic1.exe: Microsoft C++ exception: cv::Exception at memory location 0x002bf41c..

 

Thanks for any help in advanced
艾琳・伯克

回答