• 欢迎访问GanAHE的小创元世纪,技术交流与资源分享,欢迎加入GanAHE的小创元世纪🤪 微信公众号:星辰换日
  • 电影、教程、软件等分享资源请在本站或微信公众号合作平台:【星辰换日】获取。
  • 首页展示个人参与或独立开发的产品,更多功能在建中......🙆🏼天王盖地虎
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏本站吧🥺
  • 注册采用有效的邮箱,有助于及时收到评论回复、最新资源以及活动通知哟~✔🥳
  • 目前在逐渐打通微信小程序与网站之前的间隔~💻🏢

从rosbag从提取某一个Topic视频

Linux GanAHE 3个月前 (06-29) 10次浏览 已收录 0个评论 扫描二维码

有时候我们通过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:~/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')
()
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:~/rosbag2video$ frame= 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:~/rosbag2video$ frame= 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$ 

file
frame= 1564 fps= 12 q=-1.0 Lsize= 4468kB time=00:01:02.44 bitrate= 586.1kbits/s speed=0.473x

注意,二次录制时输出的文件不能同名。


GanAHE 的小创元世纪, 版权所有丨如未注明 , 均为原创丨本网站采用@BY-NC-SA协议进行授权
转载请注明原文链接:从rosbag从提取某一个Topic视频
喜欢 (0)
关于作者:
网站的建设与维护者、DGZC的守护者
0 0 评分
都看完了,打个分儿叭~
通知
提醒
0 评论
内部反馈
显示所有评论
0
有什么想法吗,快来留下你的评论吧!x
()
x