0
$\begingroup$

Gazebo Answers logo

Is there a proper way to simulate monochrome / greyscale camera in Gazebo?

The answer to question #3470 suggests setting the <format> tag to L8. This almost works as expected, but I noticed that the output image only uses the red channel of the rendered scene. Thus a blue object would appear as black, as shown below:

image description

Is there a way to get the sensor to output the mean greyscale value (e.g. (R+G+B)/3)?

Edit: adding a photo showing the same result in RViz and the Gazebo Topic Visualizer, as well as showing the ambient and background color settings image description


Originally posted by shonigmann on Gazebo Answers with karma: 16 on 2022-02-04

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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... I'll open an issue on the Gazebo github, but given the massive issue backlog I have doubts anything will come of it. For my purposes I will likely end up writing a plugin to average RGB images into grey scale.


Originally posted by shonigmann with karma: 16 on 2022-02-07

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Veerachart on 2022-02-08:
There is an example for B&W OGRE compositor. Add the compositor to the OGRE camera of an RGB camera sensor (via sensor plugin), and more correct grey RGB images can be obtained. Necessary files can be found from these files. GLSL 150 should be good for Gazebo on Ubuntu. Would be better to get output in 1 channel anyway.

Comment by shonigmann on 2022-02-08:
Interesting - thanks for the resources! We may go this route if we end up needing "true" mono. for now, we're going to see how much mileage we can get out of L8

Comment by Veerachart on 2022-02-08:
There is actually a sample browser from OGRE that you can install and see the samples (the version will be quite newer than what Gazebo is using). They look quite different from what we see from Gazebo. I've been trying to pick out some tricks to improve model's look in the cameras, not actually successful though.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.