ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Extract image with Rosbag API

asked 2020-05-22 08:00:40 -0500

davdmc gravatar image

Hello everyone. My intention is to extract numerous sensor_msgs from a .bag file (IMU, Velodyne, Image, GPS).

When I looked for a bag extractor I saw many packages (image_view extract_images) or methods (to extract data into a CSV) but no method for specific formating. I looked into the Rosbag API (in C++) and managed to extract data to a .txt or binary files.

However, my images are compressed and the recommended nodes are extract_images from image_view and republish from image_transport which use publisher/subscriber principle (same as in this example).

¿Is there any reason for not using the rosbag API to extract images from a bag? ¿Is there any easy way to decompress images without using the image_transport package?

So far I came across this answer, but ¿can anyone confirms me if cv::imdecode is enough as a substitution for image_transport? ¿Would it be the same application as the compressed_subscriber or am I missing something?

Thank you in advance for your help! :)

edit retag flag offensive close merge delete

Comments

Thank you for your answer. I was unaware that toCvCopy accepted a compressed image as input. However, this answer also confirms that I was not in the wrong direction.

davdmc gravatar image davdmc  ( 2020-05-24 12:55:34 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-05-22 10:51:16 -0500

updated 2020-05-26 12:02:47 -0500

As a fast answer, I've successfully used cv_bridge to convert sensor_msgs/CompressedImage messages from a bag file into OpenCV-native types in both Python and C++. E.g. using toCvCopy in C++ and compressed_imgmsg_to_cv2 in Python. I think that technique is likely simpler than using image_transport.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-05-22 07:59:48 -0500

Seen: 1,661 times

Last updated: May 26 '20