Openni error opening video stream [closed]
I have Ubuntu 12.04 LTS 64bits. Since 1 or 2 month I use ros fuerte. I capture from matlab using the following mex: mathworks.com/matlabcentral/fileexchange/30242-kinect-matlab. The first time that i opened stream it work fine, but the second time didn't, I need to restart my computer. To try to solve solve the problem I reinstall ubuntu and install ros groovy. Now the problem is bigger I can not run any time. I try to run Example and I have the following error:
Example Open failed: Bad Parameter sent to the device! Error using mxNiCreateContext Kinect Error
Error in Example (line 10) KinectHandles=mxNiCreateContext(SAMPLE_XML_PATH);
The xml config file doesn't change. The XML code is:
<OpenNI>
<Licenses>
<License vendor="PrimeSense" key="0KOIk2JeIBYClPWVnMoRKn5cdY4="/>
</Licenses>
<Log writeToConsole="false" writeToFile="false">
<!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -->
<LogLevel value="2"/>
<Masks>
<Mask name="ALL" on="true"/>
</Masks>
<Dumps>
</Dumps>
</Log>
<ProductionNodes>
<Node type="Image" name="Image1">
<Configuration>
<MapOutputMode xRes="640" yRes="480" FPS="30"/>
<Mirror on="true"/>
</Configuration>
</Node>
<Node type="Depth" name="Depth1">
<Configuration>
<MapOutputMode xRes="640" yRes="480" FPS="30"/>
<Mirror on="true"/>
</Configuration>
</Node>
<!--
<Node type="Audio" name="Audio1">
</Node>
-->
</ProductionNodes>
</openni>
I have done programs that use openni and they also do not run but compile. The source code is the following:
int key;
XnStatus result = XN_STATUS_OK;
xn::DepthMetaData depthMD;
xn::ImageMetaData imageMD;
IplImage* imgDepth16u=cvCreateImage(cvSize(640,480),IPL_DEPTH_16U,1);
IplImage* imgRGB8u=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
IplImage* imageShow=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
IplImage* depthShow=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1);
cvNamedWindow("depth",1);
cvNamedWindow("image",1);
xn::Context context;
result = context.Init();
//CheckOpenNIError( result, "initialize context" );
// creategenerator
xn::DepthGenerator depthGenerator;
result = depthGenerator.Create( context );
//CheckOpenNIError( result, "Create depth generator" );
xn::ImageGenerator imageGenerator;
result = imageGenerator.Create( context );
//CheckOpenNIError( result, "Create image generator" );
//map mode
XnMapOutputMode mapMode;
mapMode.nXRes = 640;
mapMode.nYRes = 480;
mapMode.nFPS = 30;
result = depthGenerator.SetMapOutputMode( mapMode );
result = imageGenerator.SetMapOutputMode( mapMode );
//read data
result = context.StartGeneratingAll();
while(!(result = context.WaitAndUpdateAll( )))
{
//get meta data
depthGenerator.GetMetaData(depthMD);
imageGenerator.GetMetaData(imageMD);
//convert to OpenCV output
memcpy(imgDepth16u->imageData,depthMD.Data(),640*480*2);
cvConvertScale(imgDepth16u,depthShow,255/4096.0,0);
memcpy(imgRGB8u->imageData,imageMD.Data(),640*480*3);
cvCvtColor(imgRGB8u,imageShow,CV_RGB2BGR);
//imshow
cvShowImage("depth", depthShow);
cvShowImage("image",imageShow);
//delay for update the imshow
//key=cvWaitKey(2);
usleep(2*1000);
}
I tried also to run roslaunch openni_launch openni.launch and I can not see anything.