Getting a Green Image sometimes

We operate our ZED2i camera continuously for 4 to 8 hours a day (excluding weekends), capturing images rather than using a continuous video stream. In our Python code, we acquire RGB frames using:

if self.zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
self.zed.retrieve_image(image_msg, sl.VIEW.LEFT)

However, occasionally we receive a heavily green-tinted image like the one I shared. Could you explain why this happens and if there’s a way to prevent or fix it?

This is generally due to USB stream corrupting frames. The ZED SDK catches most of them, but the internal frame status is not always correct and invalid image can get through.

To avoid this, we added an image validity check, which can be controlled using InitParameters::enable_image_validity_check
https://www.stereolabs.com/docs/api/python/classpyzed_1_1sl_1_1InitParameters.html#ac92564822e486b753e9230a0ec283991

On recent versions of the ZED SDK, it should be on by default, but you can check or enable it explicitly. If it detects something, grab will output the ERROR_CODE::CORRUPTED_FRAME warning (with negative value).

If it’s enabled and doesn’t output this error, we’re interested in having more images if possible, to improve this detection. An SVO file would be ideal, or left and right full-size images or sequences; it can be shared privately if needed by sending an email to support@stereolabs.com. Thanks

1 Like

I had set my initparameters now in my code,

init_params = sl.InitParameters()
init_params.enable_image_validity_check = True

so your saying this will solve the issue

This won’t solve the problem, but you can handle it by detecting bad frames and taking the required actions; you must compare the output of the grab call with the ERROR_CODE::CORRUPTED_FRAME value

In your case, you can leave the rest of the code as is; the grab function will return a non-success error code, and the image will just be ignored (from the snippet you posted).

However, it’s possible that the internal image validity checker isn’t able to catch all bad frames. If this happens, we welcome data to improve this module

1 Like