有时候我们通过rosbag录制到材料后,需要从中提取某一个视频topic出来,以供后续处理,此时就需要进行视频的提取,相关的执行脚本已经包含在TianqueROS的工具包中,直接使用即可。
提取流程如下:
WARNING: The directory '/home/ganahe/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting gnupg
Downloading gnupg-2.3.1.tar.gz (100 kB)
|████████████████████████████████| 100 kB 1.3 MB/s
Requirement already satisfied: psutil>=1.2.1 in /home/ganahe/.local/lib/python3.6/site-packages (from gnupg) (5.8.0)
Building wheels for collected packages: gnupg
Building wheel for gnupg (setup.py) ... done
Created wheel for gnupg: filename=gnupg-2.3.1-py3-none-any.whl size=94604 sha256=29006c0637bb1c3252bac79f3b4acee1216420a5a9b6fceb71f116f064450b6c
Stored in directory: /tmp/pip-ephem-wheel-cache-_d058vub/wheels/da/1a/e9/8c803384d9a14a7b66a4b0d1cff29eb064c303cf7a08f37593
Successfully built gnupg
Installing collected packages: gnupg
Successfully installed gnupg-2.3.1
WARNING: You are using pip version 21.0.1; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
ganahe@ganahe-Nitro-AN515-51:~/rosbag2video./rosbag2video.py -o image_track.mp4 --topic /vins_estimator/image_track --start 15 experiment.bag
Failed to load Python extension for LZ4 support. LZ4 compression will not be available.
Traceback (most recent call last):
File "./rosbag2video.py", line 21, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
ganahe@ganahe-Nitro-AN515-51:~/rosbag2video python rosbag2video.py -o image_track.mp4 --topic /vins_estimator/image_track --start 15 experiment.bag
############# UNCOMPRESSED IMAGE ######################
('/vins_estimator/image_track', ' with datatype:', 'sensor_msgs/Image')
()
^CTraceback (most recent call last):4096kB time=00:01:00.28 bitrate= 556.6kbits/s speed=0.459x
File "rosbag2video.py", line 305, in <module>
videowriter.addBag(bagfile)
File "rosbag2video.py", line 207, in addBag
for topic, msg, t in bag.read_messages(connection_filter=self.filter_image_msgs, start_time=self.opt_start, end_time=self.opt_end):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2699, in read_messages
yield self.seek_and_read_message_data_record((entry.chunk_pos, entry.offset), raw, return_connection_header)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2811, in seek_and_read_message_data_record
encrypted_chunk = _read(f, chunk_header.compressed_size)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 1944, in _read
data = f.read(size)
KeyboardInterrupt
frame= 1564 fps= 12 q=-1.0 Lsize= 4468kB time=00:01:02.44 bitrate= 586.1kbits/s speed=0.473x
ganahe@ganahe-Nitro-AN515-51:~/rosbag2videopython rosbag2video.py -o image_track.mp4 --topic /vins_estimator/image_track --start 15 experiment.bag
############# UNCOMPRESSED IMAGE ######################
('/vins_estimator/image_track',\'with datatype:', 'sensor_msgs/Image')
()
Traceback (most recent call last):
File "rosbag2video.py", line 305, in <module>
videowriter.addBag(bagfile)
File "rosbag2video.py", line 264, in addBag
self.write_output_video( msg, topic, t, RAWIMAGE_VIDEO, pix_fmt )
File "rosbag2video.py", line 185, in write_output_video
self.p_avconv[topic].stdin.write(msg.data)
IOError: [Errno 32] Broken pipe
ganahe@ganahe-Nitro-AN515-51:~/rosbag2video python rosbag2video.py -o image_track.mp4 --topic /vins_estimator/image_track --start 30 experiment.bag
############# UNCOMPRESSED IMAGE ######################
('/vins_estimator/image_track', ' with datatype:', 'sensor_msgs/Image')
()
finished851 fps= 12 q=28.0 size= 29696kB time=00:03:11.92 bitrate=1267.6kbits/s speed=0.462x
ganahe@ganahe-Nitro-AN515-51:~/rosbag2videoframe= 4854 fps= 12 q=-1.0 Lsize= 29859kB time=00:03:14.04 bitrate=1260.6kbits/s speed=0.466x
ganahe@ganahe-Nitro-AN515-51:~/rosbag2video python rosbag2video.py -o image_color.mp4 --topic /camera/color/image_raw --start 130 experiment.bag
############# UNCOMPRESSED IMAGE ######################
('/camera/color/image_raw', ' with datatype:', 'sensor_msgs/Image')
()
finished891 fps= 21 q=28.0 size= 9984kB time=00:03:13.52 bitrate= 422.6kbits/s speed=0.846x
ganahe@ganahe-Nitro-AN515-51:~/rosbag2videoframe= 4897 fps= 21 q=-1.0 Lsize= 10412kB time=00:03:15.76 bitrate= 435.7kbits/s speed=0.852x
tree
.
├── experiment.bag
├── image_color.mp4
├── image_track.mp4
├── LICENSE
├── README.md
└── rosbag2video.py
0 directories, 6 files
ganahe@ganahe-Nitro-AN515-51:~/rosbag2video
frame= 1564 fps= 12 q=-1.0 Lsize= 4468kB time=00:01:02.44 bitrate= 586.1kbits/s speed=0.473x
注意,二次录制时输出的文件不能同名。
Comments NOTHING