[ros-users] Converting Kinect RGB image to OpenCV gives wrong colours

Patrick Goebel patrick at pirobot.org
Sat Mar 5 16:00:03 UTC 2011


Hi Sebastian,

If you repost this question over at http://answers.ros.org, I'll post 
some Python code similar to your C++ code that works for me.  Then at 
least you'll have something to compare.

--patrick

On 03/05/2011 06:51 AM, Aslund wrote:
> Hey everyone
>
> I have been playing a bit with the kinect camera using the openni
> driver. When running openni_node.launch and viewing the rgb image using
> rviz, then everything looks perfect, but when I create a node that has
> to the purpose to read the rgb image, convert it to a cv image and
> displaying it using imshow, then the colours are all wrong. Red is blue,
> blue is red, green is something yellow and yellow is light blue. I have
> been trying to use RGB8 and BGR8 encodings, but nether of them shows any
> difference.
> A sample of my code is shown below, inspired from the example cv_bridge
> tutorial
> <http://www.ros.org/wiki/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages>:
>
>
> void processRGB::processImage( const sensor_msgs::Image::ConstPtr& img ) {
>      CvImagePtr cv_ptr;
>
>      try {
>
>          cv_ptr = toCvCopy(img, enc::BGR8); //enc::RGB8 also used
>
>      } catch (cv_bridge::Exception& e) {
>
>          ROS_ERROR("cv_bridge exception: %s", e.what());
>          return;
>      }
>
>      imshow("Kinect RGB image", cv_ptr->image);
>      waitKey(3);
> }
>
> Does anyone know what might cause this problem?
>
> Regards
>
> Sebastian Aslund
>
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users



More information about the ros-users mailing list