0
$\begingroup$

Rosanswers logo

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.


Originally posted by Benoit Larochelle on ROS Answers with karma: 867 on 2013-04-15

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by Wolf with karma: 7555 on 2014-11-24

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.