Robotics StackExchange | Archived questions

Xtion PRO LIVE RGB image error

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* rgbimg = NULL;

  context.InitFromXmlFile("/home/(*user name was inserted)/ros
workspace/xtiontest/src/SampleConfig.xml");

  xn::ImageGenerator image
gen;
  context.FindExistingNode(XNNODETYPEIMAGE, imagegen);

  XnMapOutputMode mapMode;
  imagegen.GetMapOutputMode(mapMode);

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

  rgb
img = cvCreateImage(cvSize(width, height), IPLDEPTH8U, 3);

  for(;;)
  {
    context.WaitAndUpdateAll();

    xn::ImageMetaData imageMetaData;
    imagegen.GetMetaData(imageMetaData);

    xnOSMemCopy(rgb
img->imageData, imageMetaData.RGB24Data(), rgbimg->imageSize);
    cvCvtColor(rgb
img, rgbimg, CVRGB2BGR);

    cvShowImage("RGB image", rgbimg);

    char key = cvWaitKey(5);
    if(key == 'q')
      break;
  }

  if(rgb
img != NULL)
    cvReleaseImage(&rgb_img);

  return 0;
}

Asked by moyashi on 2012-08-12 15:00:42 UTC

Comments

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

Asked by Georg on 2012-08-13 03:58:53 UTC

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.

Asked by moyashi on 2012-08-14 21:32:50 UTC

Answers