OpenCV + Asus Xtion sensor
Dear all,
I am having trouble getting the Asus Xtion sensor to work with the OpenCV framework. I know (or at least I believe) the problem is not my laptop as I have an example program working with PCL (the Point Cloud Library). I am using Debian Sid with a custom compiled OpenCV (to ensure support for OpenNI and the Xtion sensor). The following code is what should work, but is not:
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture capture( CAP_OPENNI_ASUS );
if (!capture.isOpened())
{
exit(1);
}
for(;;)
{
Mat depthMap;
capture >> depthMap;
if( waitKey( 30 ) >= 0 )
break;
}
}
This code compiles just fine. When I run it, however, with the Xtion sensor plugged in, it gives me the following output:
CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: Bad Parameter sent to the device!
What exactly is going on and how do I fix it? I have tried searching on Google and haven't found anything useful except for other people with the same problem and no responses.
Thank you very much in advance.
Sincerely,
Chaanakya
Does SamplesConfig.xml have anything at all to do with this not working? It seems that it should read /etc/openni/SamplesConfig.xml. However, I don't think it's doing that, since a) PCL worked (and works) just fine and b) nothing I do is actually changing the behavior of OpenCV.
Hi,
I don't know the answer, but maybe I can give you a hint. (I never used OpenNI 1.5, it's quite outdated; I prefer to use the newer OpenNI2.2 and transform the captured data to OpenCV Mat).
To get back to your question: the OpenNI capture is implemented in the modules/highgui/src/cap_openni.cpp file. There you can find a global variable called XMLConfig, right at the beginning. The CvCapture_OpenNI constructor tries to run this script, but it seems that it fails; there is a parameter in the XML text that your device doesn't understand.
workarounds: a) use OpenNI separately and transform the image to Mat; b) try to get a valid XML config file for your device; c) set the device in verbose mode (check the settings in OpenNI), maybe it gives you more hint about that bad parameter.
Thanks kbarni - I did change that variable and the result does work. How exactly do you do a) though? I'd like to do that if possible. Thanks!