How can I extract a depth image from a .bag file?
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:
<launch>
<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"/>
</node>
</launch>
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!
Asked by fluxy on 2020-11-23 07:44:49 UTC
Answers
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.
<launch>
<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>
<node name="extract" pkg="image_view" type="extract_images" respawn="false" required="true" output="screen" cwd="ROS_HOME">
</node>
</launch>
ref: http://wiki.ros.org/depth_image_proc
Asked by miura on 2020-11-24 09:15:08 UTC
Comments
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?
Asked by fluxy on 2020-11-27 07:47:32 UTC
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.
Asked by miura on 2020-11-27 07:55:05 UTC
Comments