Skip to content

Allow processing to continue if an error occurs in image decoding #33

@jellehierck

Description

@jellehierck

When an error arises during image decoding, processing stops entirely. It would be nice to have an option to only report the error but continue processing other messages.

Concretely, we have rosbags with many images in them. Unfortunately, some of the images are an empty sensor_msgs/msg/Image. An empty image does not have any data, no size, and also no encoding field. That triggers the error in ros2 unbag.

However, since ros2 unbag is multi threaded, it will stop other threads too when it encounters the error, which causes a race condition and other images to only be partially saved (which explains the inconsistent gray areas in other saved images).

One workaround is to set the CPU usage in ros2 unbag to 0 %. This does not prevent the error, but all images before the empty image will be processed and saved correctly. However, the program will still stop processing subsequent images.

My other (very, very dirty) workaround is to slightly adjust

raise ValueError(f"Unsupported encoding: {encoding}")
to prevent the error from being raised.

    # Around line 80
+   return np.zeros((2,2))
-   raise ValueError(f"Unsupported encoding: {encoding}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions