当前位置:   article > 正文

使用nuscenes-devkit读取nuscenes的视频文件并输出为mp4视频

nuscenes-devkit

访问 https://github.com/nutonomy/nuscenes-devkit,下载依赖。
使用方法,可以学习教程 https://www.nuscenes.org/tutorials/nuscenes_tutorial.html

如何保存到路径

nusc.render_scene_channel(my_scene_token, 'CAM_FRONT', out_path=f"{query}.mp4")指定保存路径参数。

from nuscenes.nuscenes import NuScenes
import cv2


nusc = NuScenes(version='v1.0', dataroot=r'{path-to-nuscenes}', verbose=True)
print(nusc)
print(nusc.list_scenes())
table_name, field, query = 'scene', 'name', 'scene-0061'
print("field2token", nusc.field2token(table_name, field, query))
my_scene_token = nusc.field2token(table_name, field, query)[0]
print("token", my_scene_token)
nusc.render_scene_channel(my_scene_token, 'CAM_FRONT', out_path=f"{query}.mp4")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

输出mp4视频

深入nusc.render_scene_channel,修改依赖包,文件D:\programs\anaconda\Lib\site-packages\nuscenes\nuscenes.py的render_scene_channel函数,如下两处:

if out_path is not None:
    assert osp.splitext(out_path)[-1] == '.avi' or osp.splitext(out_path)[-1] == '.mp4'
  • 1
  • 2
if out_path is not None:
    # fourcc = cv2.VideoWriter_fourcc(*'MJPG')
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(out_path, fourcc, freq, imsize)
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/620644
推荐阅读
相关标签
  

闽ICP备14008679号