Ask Your Question

How can I extract a depth image from a .bag file?

asked 2020-11-23 06:44:49 -0600

fluxy gravatar image

I would like to extract a depth image - a simple short int matrix - from a .bag file. This is what I tried with a launch file:

  <node name="extract" pkg="image_view" type="extract_images" respawn="false" required="true" output="screen" cwd="ROS_HOME">
    <remap from="image" to="/l515/depth/image_rect_raw"/>

and then used

rosbag play my_file.bag

However the extractor gives me the following error message:

[ INFO] [1606132041.164919359]: Initialized sec per frame to 0.100000
[ERROR] [1606132047.642971073]: Unable to convert 16UC1 image to bgr8
[ WARN] [1606132047.643110024]: Couldn't save image, no data!

I would like to tell the system to just store the 16UC1 as is, not try to convert it to bgr8. But how do I do that?

I am sure that I am listening to the correct topic.

Any help is very much appreciated! Thanks a lot!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-11-24 08:15:08 -0600

miura gravatar image

If you want to view it in an image viewer, you'd need to convert the depth image to a normal image, as shown below.

  <node pkg="nodelet" type="nodelet" name="nodelet_manager" args="manager" />

  <node pkg="nodelet" type="nodelet" name="nodelet1"
        args="load depth_image_proc/convert_metric nodelet_manager">
    <remap from="image_raw" to="/l515/depth/image_rect_raw"/>

  <node name="extract" pkg="image_view" type="extract_images" respawn="false" required="true" output="screen" cwd="ROS_HOME">


edit flag offensive delete link more


Thank you, but this is not what I meant. I don't want to view the image. I want to save it (raw data). I don't want ROS to convert anything, just save the data. How do I do this?

fluxy gravatar image fluxy  ( 2020-11-27 06:47:32 -0600 )edit

If you don't want to see it in the viewer rostopic echo -b my_file.bag -p /l515/depth/image_rect_raw > my_file.csv Output to csv file.

miura gravatar image miura  ( 2020-11-27 06:55:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-11-23 06:44:49 -0600

Seen: 255 times

Last updated: Nov 24 '20