• ROS
  • Does mjpeg affect image quality this much?

Hi,

We're using a camera setup with multiple streams. On of the streams sends high resolution images at a very low rate. We use the mjpeg video codec to compress the images and save bandwidth. We use this preset:

video_encoder.setDefaultProfilePreset(1, VideoEncoderProperties.Profile.MJPEG)

But the pictures look a bit strange. This old image is pretty sharp with natural colors:

This newer image shows a greenish glow around the plants, and it looks a bit like paint-by-numbers.

We suspect that the first image was made before we started using the mjpeg codec and the second after. Apart from the codec we didn't change other camera settings. Are we correct? Or is there something else we need to look at?

Thanks in advance!

  • The sharpness, luma denoise, chroma denoise settings caused this. Setting them to resp 0, 0, 1 solved the problem.

Hi @WouterOddBot
It is lossy but depending on what the quality is set to. You can change this using setQuality(). MJPEG encoding also offers setLossless() if you want to check it out,

Thanks,
Jaka

Hi @jakaskerl ,
Thanks for your answer. We're now using setQuality() indeed to have direct control over the quality. It will take a bit of time to test whether that makes a difference.

But may for instance the H265 encoder give better quality images?

Hi @WouterOddBot
Can't say for sure but I think MJPEG is higher quality when using the same value for setQuality().

Thanks,
Jaka

13 days later

Ok so even with jpeg quality setting setQuality(90) we see the same strange colors. I got some images from the rgb camera node directly. Those images show the same strange colors as well:

Could anyone give us a clue what causes these strange colors? This is all our code for the camera rgb node:

pipeline = Pipeline()
pipeline.setCameraTuningBlobPath(tuning_blob_path) # tuning_exp_limit_500us.bin
color = pipeline.create(ColorCamera)
color.setBoardSocket(CameraBoardSocket.RGB)
color.setFps(detections_frame_rate) # 5.0
color.setResolution(ColorCameraProperties.SensorResolution.THE_4_K)
color.setVideoSize(self.__color_video_width, self.__color_video_height) # 2144 x 2144
color.setInterleaved(False)
# color.setIspScale(1, 2)
if self.__params.focus != -1:
color.initialControl.setManualFocus(self.__params.focus) # -1

Besides the rgb node we also have several others nodes running, but I don't think that those affect the image quality.

4 days later

The sharpness, luma denoise, chroma denoise settings caused this. Setting them to resp 0, 0, 1 solved the problem.

Hi @WouterOddBot
Luma and chroma (not sure about sharpness) will have this effect on an image. Did you change it in any way, because usually they will be set to the most optimal (decided by the 3a)?

Thanks,
Jaka

    The code snippet in the post above shows all our code for the rgb camera node. Not sure why the 3a came up with suboptimal settings. Perhaps the light conditions?