Xtion PRO LIVE RGB image error [closed]
I bought xtion pro live and tried to use it.
With openni.launch and rviz, it worked well(I could see a RGB-D image).
I wrote my own program which shows just a RGB image,
it didn't work well.
Strangely, a RGB image was shown well with kinect.
Any idea?
Thanks in advance.
Configuration and Code are shown as followings.
OS : Ubuntu10.04
ROS version: Electric
used package : openni_kinect
SampleConfig.xml(used for context.InitFromXmlFile() function) :
<OpenNI>
<Licenses>
<License vendor = "PrimeSense" key = "(*key was inserted here)"/>
</Licenses>
<Log writeToConsole = "true" writeToFile = "false">
<!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error(default) -->
<LogLevel value = "1"/>
<Masks>
<Mask name = "ALL" on = "true"/>
</Masks>
<Dumps>
</Dumps>
</Log>
<ProductionNodes>
<Node type = "Image" name = "Image1">
<Configuration>
<MapOutputMode xRes = "640" yRes = "480" FPS = "30"/>
</Configuration>
</Node>
<Node type = "Depth" name = "Depth1">
<Configuration>
<MapOutputMode xRes = "640" yRes = "480" FPS = "30"/>
</Configuration>
</Node>
<Node type = "Scene"/>
<Node type = "User"/>
<Node type = "Gesture"/>
<Node type = "Hands"/>
</ProductionNodes>
</OpenNI>
Source code :
#include <XnCppWrapper.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main(int argc, char* argv)
{
xn::Context context;
IplImage rgb_img = NULL;
context.InitFromXmlFile("/home/(*user name was inserted)/ros_workspace/xtion_test/src/SampleConfig.xml");
xn::ImageGenerator image_gen;
context.FindExistingNode(XN_NODE_TYPE_IMAGE, image_gen);
XnMapOutputMode mapMode;
image_gen.GetMapOutputMode(mapMode);
int width = mapMode.nXRes;
int height = mapMode.nYRes;
rgb_img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
for(;;)
{
context.WaitAndUpdateAll();
xn::ImageMetaData imageMetaData;
image_gen.GetMetaData(imageMetaData);
xnOSMemCopy(rgb_img->imageData, imageMetaData.RGB24Data(), rgb_img->imageSize);
cvCvtColor(rgb_img, rgb_img, CV_RGB2BGR);
cvShowImage("RGB image", rgb_img);
char key = cvWaitKey(5);
if(key == 'q')
break;
}
if(rgb_img != NULL)
cvReleaseImage(&rgb_img);
return 0;
}
You should be more precise! What do you mean, with "it didn't work well"?
Thank you for your comment, Georg. Window was opened, but it showed sandstorm instead of a correct RGB image. Depth image which was drawn by using depth histogram was showed correctly.