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. mysql dba系统学习(2)了解mysql的源码目录及源文件
  2. 如何用产品思维找到意中人?
  3. opencv函数findcontours_OpenCV 中的轮廓应用
  4. 详谈为何不要使用Windows的notepad编写shell
  5. 对discuz的代码分析学习(三)mysql驱动
  6. 【DP】Bovine Genetics G(P7152)
  7. I/0口输入输出实验 学习IO口的位操作方法,分别选择P0、P1、P2、P3端口中的某一位,该位作为输出使用,连接一只发光二极管,控制器闪烁。
  8. PHP排雷之编码问题
  9. 【数据分析】脑图讲述数据分析方法论
  10. flutter之从零开始搭建(一)之 BottomNavigationBar
  11. 今年暑假不ac (c语言版)
  12. 针对2020年市面上短信供应商的对比(8家SMS供应商对比)
  13. python爬取网易云评论_Python - 网易云热门评论爬取
  14. N叉树的所有路径搜索
  15. Excel文件解析性能对比(POI,easyexcel,xlsx-streamer)
  16. 扔掉Windows 中的盗版软件,使用免费正版软件
  17. 【回归预测-FNN预测】基于蝙蝠算法优化前馈网络实现数据回归预测附Matlab代码
  18. halcon绘制多边形轮廓的方法
  19. parsec-3.0 安装报错(__mbstate_t)
  20. MyISAM 与 InnoDB

热门文章

  1. 【数据库】《SQL必知必会 4th》部分笔记
  2. Cookie详解整理
  3. Xtreme8.0 - Kabloom dp
  4. SQL Server 数据库的维护(四)__游标(cursor)
  5. HDU 1028 Ignatius and the Princess III
  6. 杭电1027Ignatius and the Princess II模拟
  7. javascript引用bug带来的继承
  8. PMP 第七章 项目成本管理
  9. 第七节:EF Core调用SQL语句和存储过程
  10. [19/04/24-星期三] GOF23_创建型模式(建造者模式、原型模式)