gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.21k stars 484 forks source link

L8 and L_INT8 Camera Format Only Uses Red Color Channel #3168

Open shonigmann opened 2 years ago

shonigmann commented 2 years ago

I am trying to simulate a monochrome camera, but have noticed in my tests that the L8 and L_INT8 <format> options result in a grey image that only considers the RED color channel of the rendered scene. This could lead to pretty misleading results, as shown in the image below, where the purely green and blue objects are interpreted as black (0), and the pure red background is interpreted as white (255):

L8_format_test_2

Looking at the source code, it looks like L8 and L_INT8 set bpp to 8, which is used by FreeImage_ConvertFromRawBits() as the bit-depth:

bpp Type: SystemUInt32 The bit depth (bits per pixel) of the raw bitmap.

I have a hunch that the renderer is producing an RGB image by default, and the L8 option is just taking the first 8 bits of each pixel, i.e. the Red channel only.

Certainly more efficient than averaging over the 3 channels for each frame, but it feels a bit misleading...

Related Gazebo Answers question here: https://answers.gazebosim.org/question/27793/how-to-simulate-monochrome-greyscale-camera-in-gazebo/

System Info: Gazebo 11.9.0 binary install Ubuntu 20.04