Xtion PRO LIVE RGB image error [closed]

asked 2012-08-12 15:00:42 -0500

moyashi gravatar image

updated 2012-08-12 15:05:09 -0500

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) :
    <License vendor = "PrimeSense" key = "(*key was inserted here)"/>
  <Log writeToConsole = "true" writeToFile = "false">
    <!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error(default) -->
    <LogLevel value = "1"/>
      <Mask name = "ALL" on = "true"/>
    <Node type = "Image" name = "Image1">
        <MapOutputMode xRes = "640" yRes = "480" FPS = "30"/>
    <Node type = "Depth" name = "Depth1">
        <MapOutputMode xRes = "640" yRes = "480" FPS = "30"/>
    <Node type = "Scene"/>
    <Node type = "User"/>
    <Node type = "Gesture"/>
    <Node type = "Hands"/>

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;
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;

  int width = mapMode.nXRes;
  int height = mapMode.nYRes;

  rgb_img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);


    xn::ImageMetaData 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')

  if(rgb_img != NULL)

  return 0;

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-04-06 01:52:38.871748



You should be more precise! What do you mean, with "it didn't work well"?

Georg gravatar image Georg  ( 2012-08-13 03:58:53 -0500 )edit

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.

moyashi gravatar image moyashi  ( 2012-08-14 21:32:50 -0500 )edit