ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

cv_bridge swaps the RGB channels?

asked 2013-04-15 22:39:19 -0500

Benoit Larochelle gravatar image

I'm not sure if this is a bug or the intended behavior, but cv_bridge converts both ROS image formats RGB8 and BGR8 to OpenCV format CV_8UC3. The result is that the images from some sources have their red and blue channels swapped.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-24 02:49:17 -0500

Wolf gravatar image

Both RGB8 and BGR8 are stored in the data format CV_8UC3. (Depth and channels are exactly identical). If your set "rgb8" or "bgr8" it will convert the channels accordingly, i. e. the channel data in our cv::Mat will be ordered as you told it to be. If you want to do some own image processing you can do this in RGB8 or BGR8, does not matter if you are aware which format you use.

However, OpenCV's highgui functions (cv::imshow, cv::imwrite etc.) always assume BGR8 color space. This means if you use RGB8 the R and B channels will appear to be flipped if you save or show the image using OpenCV highgui methods....

edit flag offensive delete link more

Question Tools


Asked: 2013-04-15 22:39:19 -0500

Seen: 1,448 times

Last updated: Nov 24 '14