ros2bag_to_image
is a ROS2 package that extracts images from a specified topic in a .db3
ROS2 bag file and saves them as individual image files. This package is particularly useful for processing recorded image data from robots or sensors in ROS2 environments, saving each frame as a sequential image file.
- Extracts images from a specified topic in ROS2 bag files.
- Saves images in PNG format with sequential naming.
- Uses OpenCV and
cv_bridge
to handle and convert image data. - Ros2 Humble support.
This package requires the following ROS2 and Python packages:
rclpy
: ROS2 Python client libraryrosbag2_py
: ROS2 bag reading and processing librarycv_bridge
: Bridges ROS image messages with OpenCVopencv-python
: OpenCV library for image handling in Python
To install these dependencies, use:
sudo apt update
sudo apt install ros-humble-rclpy ros-humble-rosbag2-py ros-humble-cv-bridge python3-opencv
- Clone the Repository:
cd ~/ros2_ws/src
git clone https://github.com/AbdullahGM1/ros2bag_to_images.git
- Build the Package:
cd ~/ros2_ws
colcon build --packages-select ros2bag_to_image
- Source the Workspace:
source ~/ros2_ws/install/setup.bash
- To extract images from a ROS2 bag file, you can specify the bag file path, topic name, and output directory as command-line arguments:
ros2 run ros2bag_to_image extract_images /path/to/your_bag_file.db3 --topic /your_topic_name --output_dir /path/to/save/images
- The script extracts images from the
/your_topic_name
topic in the bag file located at/path/to/your_bag_file.db3
. - Images are saved in
/path/to/save/images
path.