MATLAB Answers

Run the openni2 code with Kinect2 but the matlab collapsed(flashback) in ubuntu14.04

1 view (last 30 days)
Ben Lu
Ben Lu on 24 Feb 2017
Edited: Ben Lu on 24 Feb 2017
I use "Kinect_Matlab_version2" to run Kinect2 in ubuntu14.04.Codes is from here: http://cn.mathworks.com/matlabcentral/fileexchange/30242-kinect-matlab?s_tid=srchtitle. The mex function is below. When I run this code, matlab2016b collapsed. The code only can can be executed to this line(14) "printf("After initialization:\n%s\n", openni::OpenNI::getExtendedError());". The Kinect2 device can be detected. However if this code(line 16) "rc = device.open(deviceURI);" be executed, matlab2016b will collapse(flashback).So how to solve this problem, Thanks.
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
UInt64 *MXadress;
int Jdimsc[2]={1,5};
openni::Status rc = openni::STATUS_OK;
const char* deviceURI = openni::ANY_DEVICE;
plhs[0] = mxCreateNumericArray(2, Jdimsc, mxUINT64_CLASS, mxREAL);
MXadress = (UInt64*)mxGetData(plhs[0]);
rc = openni::OpenNI::initialize();
printf("After initialization:\n%s\n", openni::OpenNI::getExtendedError());
rc = device.open(deviceURI);
if (rc != openni::STATUS_OK)
{
printf("SimpleViewer: Device open failed:\n%s\n", openni::OpenNI::getExtendedError());
openni::OpenNI::shutdown();
return;
}
else
{
MXadress[0] = ( UInt64)&device;
}
rc = color.create(device, openni::SENSOR_COLOR);
if (rc == openni::STATUS_OK)
{
rc = color.start();
if (rc != openni::STATUS_OK)
{
printf("SimpleViewer: Couldn't start color stream:\n%s\n", openni::OpenNI::getExtendedError());
color.destroy();
}
else
{
MXadress[1] = ( UInt64)&color;
printf("Succesfull started color stream \n%");
}
}
else
{
printf("SimpleViewer: Couldn't find color stream:\n%s\n", openni::OpenNI::getExtendedError());
}
rc = depth.create(device, openni::SENSOR_DEPTH);
if (rc == openni::STATUS_OK)
{
rc = depth.start();
if (rc != openni::STATUS_OK)
{
printf("SimpleViewer: Couldn't start depth stream:\n%s\n", openni::OpenNI::getExtendedError());
depth.destroy();
}
else
{
MXadress[2] = ( UInt64)&depth;
printf("Succesfull started depth stream \n%");
}
}
else
{
printf("SimpleViewer: Couldn't find depth stream:\n%s\n", openni::OpenNI::getExtendedError());
}
}

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.