BundleFusion的数据集中,在生成.sens文件之前,包括彩色图,深度图和一个位姿文件,并且这个pose文件中的位姿态是有变化的,所以我怀疑,推测,在这个pose文件中可以写入groundtruth的位姿,然后在重建的时候就按照传入的位姿进行计算.为了测试一下效果,我从TUM数据集开始入手,这个数据集中有彩色图,深度图,还有根据时间戳配准后的文件association.txt,还有groundtruth.但是groundtruth中的数据要比association.txt中的数据量多很多,前者更加密集,我将做这件事分成一下几个步骤:

1. 首先我要将association.txt中的时间戳在groundtruth.txt中找到匹配,并不能做到时间戳完全相等,而是找时间最近的数据.

2. 将找到的matches中的彩色图和深度图从他们原始的目录下,按照BundleFusion需要的图像命名格式对图像进行重命名,然后再拷贝到另外一个目录下.

3. 将配准后的对应到groundtruth.txt中存储的位姿数据保存下来,然后将四元数表示的旋转转换为旋转矩阵.

4. 将平移向量和旋转矩阵组合成SE3位姿矩阵,写入到文件中.

因为直接调用的是TUM数据集官网提供的associate.py中的 read_file_list()函数和associate()函数,所以需要将associate.py从TUM数据集官网上复制下来,放到一个工程内.

"""
step 1: read into two files, association.txt and groundtruth.txt
step 2: read the first column also the timestamp of each file above and thenassociate the first one to teh second one to find the matches.
step 3: for all matches, get all the correspondent rotation represented in quaternion form andthen transform them into rotation form.
step 4: combine rotation matrix generated above, translation vector and the shared_vec into thepose matrix with 4x4 form.
"""import numpy as np
from scipy.spatial.transform import Rotation as R
import associate
import os
import shutildef read_files(files_path):print(files_path)association = files_path + "association.txt"groundtruth = files_path + "groundtruth.txt"rgb_path = files_path + "rgb/"depth_path = files_path + "depth/"bf_data_path = files_path + "bf_data/"print(rgb_path)print(depth_path)assoc_list = associate.read_file_list(association)ground_list = associate.read_file_list(groundtruth)print("length of assoc_list", len(assoc_list))print("length of ground_list", len(ground_list))matches = associate.associate(assoc_list, ground_list, 0.0, 0.02)final_rgbs = []for match in matches:final_rgbs.append(match[0])# print(match)rgbs = []depths = []for data in assoc_list:if data[0] in final_rgbs:rgbs.append(data[1][0].split("/")[1])depths.append(data[1][2].split("/")[1])rgb_images = os.listdir(rgb_path)depth_images = os.listdir(depth_path)rgb_id = 0for rgb_name in rgbs:if rgb_name in rgb_images:shutil.copyfile(rgb_path + "/" + rgb_name,bf_data_path + "frame-" + str(rgb_id).zfill(6) + ".color.png")rgb_id += 1depth_id = 0for depth_name in depths:if depth_name in depth_images:shutil.copyfile(depth_path + "/" + depth_name,bf_data_path + "frame-" + str(depth_id).zfill(6) + ".depth.png")depth_id += 1print("length of matches",len(matches))groundtruth_list = []# initialize a dictionary with a listground_dict = dict(ground_list)for match in matches:# print(match)groundtruth_list.append(ground_dict[match[1]])print("length of groundtruth",len(groundtruth_list))quaternion2rotation(groundtruth_list, bf_data_path)def quaternion2rotation(groundtruth_list, bf_data_path):row_vec = np.array([0,0,0,1], dtype=np.float32)[np.newaxis, :]frame_id = 0for pose in groundtruth_list:translation = np.array([pose[0], pose[1], pose[2]], dtype=np.float32)[:, np.newaxis]quaternion = np.array([pose[3], pose[4], pose[5], pose[6]])rotation = R.from_quat(quaternion)# print(rotation.as_matrix())m34 = np.concatenate((rotation.as_matrix(), translation), axis=1)m44 = np.concatenate((m34, row_vec), axis=0)# write pose into .txt file# print(m44)fp = open( bf_data_path + "frame-" + str(frame_id).zfill(6) + ".pose.txt", 'w')for row in m44:fp.write(' '.join(str(i) for i in row)+'\n')frame_id += 1if __name__ == '__main__':# step 1: read two filesread_files("/home/yunlei/Datasets/TUM/rgbd_dataset_freiburg1_teddy/")# transform from quaternion to rotation# quaternion2rotation(groundtruth_list)

TUM数据集制作BundleFusion数据集相关推荐

  1. matlab 数据集制作,机器学习数据集制作与划分MATLAB实现

    .mat数据集制作 若整个数据集是一个.mat文件且最后一列数据时标签,则单独将决策变量和标签划分开,一个为ins,另一个为lab. 相关文章 .mat数据集说明 数据集名称GLIOMA GIOMA包 ...

  2. 【数据集|COCO】COCO格式数据集制作与数据集参数计算

    文章目录 1. 批量修改 JSON 文件中的参数 1.1 问题背景 1.2 代码实现 2. 划分训练集和测试集 2.1 问题背景 2.2 环境配置 2.3 代码实现 3. 生成 JSON 标签文件 3 ...

  3. 化学实验室自动化 - 1. 深度学习视觉检测(实例分割) - COCO格式的化学实验室常见物体实例分割数据集制作

    前言 随着自动化.智能化技术在各行各业获得了广泛应用,化学实验室领域也不可避免的迎来了变革.视觉检测是自动化和智能化的基础,本文将介绍化学实验室常见物体的COCO格式的实例分割数据集的制作方法,后续将 ...

  4. 超级简单的VOC2007数据集制作——使用自制的VOC2007数据集制作工具

    使用自制VOC2007数据集制作工具 数据集制作工具下载链接 本人win10 64位系统 操作没有问题(其他系统没有试过),在有的机子测试会出现应用程序无法正常启动0xc0000007b,请从以下几个 ...

  5. 从xml数据集到FairMOT数据集转换

    这是我写的数据集,大家需要修改路径即可,当然希望大家可以看一下转换思路,以后就会转换啦,授之以鱼不如授之以渔 """ 把UA-DETRAC数据集制作FairMOT数据集的 ...

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

    背景: 最近在研究BundleFusion,跑通官方数据集后,就想着制作自己的数据集来运行bundlefusion.KinectV2相机可直接获取的图像的分辨率分为三个HD 1920x1080, QH ...

  7. 将TUM数据集制作成BundleFusion数据集

    在上一篇文章中,我写到了如何将TUM数据生成BundleFusion所需要的数据集,生成的数据集如下图中所示.并且是将每一组数据的groundtruth.txt中的位姿数据写如到这里的pose文件中, ...

  8. realsense D435获取RGB-D数据集-制作.klg文件

    记录个人工作日志.恳求大佬指点简单的方法!! 1.  <利用ros记录话题,获得bag文件> 首先launch相机节点: roslaunch realsense2_camera rs_ca ...

  9. 生成.sens格式数据集用于BundleFusion重建

    BundleFusion算法离线重建输入为.sens格式数据集,这里我测试了官网的数据和两款深度相机采集的数据去进行格式转换,一个是Intel RealSense D435,一个是KinectDK. ...

最新文章

  1. win10双屏让任务栏显示不相同的方法
  2. 人群计数--Mixture of Counting CNNs
  3. 【leetcode】Jump Game I, II 跳跃游戏一和二
  4. 数据库查询前十条数据_西门子PLC1200组态王-Access数据库-⑨数据库查询
  5. 火狐浏览器Firefox如何使用插件,火狐有哪些好用的插件
  6. 微信小程序之 3d轮播(swiper来实现)
  7. 资源放送丨《Oracle中为什么没有Double Write?Oracle支持原子写吗?》PPT视频
  8. 使用javascript实现浏览器全屏
  9. Apple任意代码执行漏洞
  10. 判断字符串中是否存在的几种方案:string.indexof、string.contains、list.contains、list.any几种方式效率对比...
  11. java.exe 不是有效的win32_WinXP提示不是有效的Win32应用程序怎么办?
  12. cholesky分解_Time Series Analysis-1.2 LDL分解
  13. 基础集合论 第二章 9 族
  14. LiveQing视频点播RTMP直播服务一步一步搭建视频直播RTMP推流流媒体服务
  15. notepad html 自动格式化代码,notepad++格式化html代码
  16. matlab simulink 六自由度机械臂模糊控制pid
  17. 2.语音增强短时谱估计算法——幅度谱减法
  18. 微信小程序单个页面导航栏 设置
  19. 快速搭建centos7虚拟机——使用virtualbox+vagrant
  20. 学习大数据要掌握哪些语言?哪些必备知识和技能呢?

热门文章

  1. UI-UIScrollView
  2. 3.寄存器(内存访问)
  3. Debian下IPv6设定主地址 Set primary IPv6 address under Debian Linux
  4. JavaScript-内存空间
  5. 在mac上安装gitlab
  6. Leetcode No.146 ****
  7. 编写基于Property-based的单元测试
  8. python基础知识-列表,元组,字典
  9. (12)MSP430F5529 常用内置函数和一些说明
  10. Extjs4 MVC 添加view层