Robotics StackExchange | Archived questions

Extract image with Rosbag API

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 (imageview extractimages) 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 extractimages from imageview 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! :)

Asked by davdmc on 2020-05-22 07:59:48 UTC

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.

Asked by davdmc on 2020-05-24 12:55:34 UTC

Answers

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.

Asked by jarvisschultz on 2020-05-22 10:51:16 UTC

Comments