This package was edited starting image_view and image_transport to extract images from multiples cameras in ROS bags.
To build this package, clone it in your workspace, then just type the command below:
$ catkin build extract_images
Before running the code, check if the launch file export_image.launch
is configured in the way you need. Make sure that the topics are the topics that are you looking for. As well, make sure that the others parameters are set up as you needed.
To extract raw images, do the following steps in order:
- Open a terminal and run roscore;
- In other terminal, go to the directory which the bags are stored and run the following command (this command will make all the bag files in directory run in order):
$ rosbag play *.bag
- In order terminal run the roslaunch:
$ roslaunch extract_images export_image.launch
To extract compressed images it's necessary to perfom a taks more to be possible extract the images. So, to do this, follow the steps below:
- Open a terminal and run roscore;
- In other terminal, go to the directory which the bags are stored and run the following command (this command will make all the bag files in directory run in order):
$ rosbag play *.bag
- In other terminal run the command (this sould be done for each topic):
$ rosrun image_transport republish compressed in:="/topic" raw out:="/new_topic"
For example:
$ rosrun image_transport republish compressed in:=/spot2/camera_front/color/image_raw_throttle/ raw out:=/spot2/camera_front/color/image
- In other terminal run the roslaunch:
$ roslaunch extract_images export_image.launch
To remove the "count%04i_
" from the file names, install the library rename from Linux, by the command:
$ sudo apt install rename
Then, type the command:
$ rename 's/count[0-9][0-9][0-9][0-9]_//' *
Other useful commands are available in the file commands.txt
.
More information can be found in Wiki ROS.