ROS获取KinectV2相机的彩色图和深度图并制作bundlefusion需要的数据集

背景: 最近在研究BundleFusion,跑通官方数据集后,就想着制作自己的数据集来运行bundlefusion.KinectV2相机可直接获取的图像的分辨率分为三个HD 1920x1080, QHD: 960X540,SD: 512x424.我选择是中间的分辨率qhd.

录制了一段时间我去查看,彩色图和深度图,发现两者的帧数不相同,我就很纳闷了,还想着用什么方法对两个进行同步处理,但是我去查看了一下TUM数据集,发现数据集里面的深度图和彩色图的帧数也不相同,我恍然大悟,在orb-slam2运行tum数据集时,需要使用TUM数据集中的associate.py脚本,按照时间戳的远近将深度图和彩色图匹配起来,得到associate.txt文件,这个里面是彩色图时间戳,以时间戳命名的图像的名字,以及对应这个彩色图的深度图的时间戳,和以这个时间戳命名的图像的名字.这样在运行代码的时候就按照这个匹配结果去文件夹下读取相应的图像.

可以在我的git上下载完整代码,然后放到你的catkin_ws/src下然后catkin_make进行编译

https://github.com/Serena2018/save_color_depth_from_kinect2_with_ros

当然你需要提前配置好libfreenect2和iai-kinect2,然后运行roslaunch kinect2_bridge kinect2_bridge.launch

然后使用 rostopic list 查看当前系统上发布出来的话题.

这样运行上面下载的代码就可以订阅发布出来的彩色图像和深度图像的数据.

 

然后我使用了TUM数据集提供的associate.py工具,在保存下来的图像中找到对应,得到associate.txt文件,然后直接读取这个文件,去文件目录下找相应的图像,并按照bundlefusion需要的图像的命名格式对图像进行重命名,将重命名后的图像保存到新路径下

## in another script we have find the association of color and depth and now
## in this script we will pick the correspondents of color and depth images
## according their timestamps then rename them according the standards of
##  bundlefusion dataset and then store them in separate folders.

## step one: read the assoc.txt into this project.

import sys
import os
import shutil

def read_file_list(filename):
    """
    Reads a trajectory from a text file.

    File format:
    The file format is "stamp d1 d2 d3 ...", where stamp denotes the time stamp (to be matched
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值