Ask Your Question

cv_bridge swaps the RGB channels?

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

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


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

Seen: 742 times

Last updated: Nov 24 '14