TUM数据集制作BundleFusion数据集

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)

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/252391.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linq查询datatable的记录集合

通过linq查询datatable数据集合满足条件的数据集 1.首先定义查询字段的变量,比方深度 string strDepth查询深度的值; var dataRows from datarow in dataTable(须要查询的datatable数据集).AsEnumerable() where …

Java 概述和编程基础

First of all,Java概述: 类是Java程序设计的基石和基本单元; main()方法是程序的入口,它是共有的、静态的,参数String[] args表示一个字符串数组可以传入该程序,用来传递外部数据以初始化程序。   计算机…

19、Fragment

一、Fragment 1.1、fragment介绍 fragment的出现是为了同时适应手机和平板,可以将其看做Activity的组成部分,甚至Activity界面完全由不同的Fragment组成,它拥有自己的生命 周期和接收、处理用户的事件,更为重要的是,可…

喜好:

不喜欢吃:一瓣瓣的蘑菇、海带、豆腐皮、 不喜欢喝:鱼汤; 不喜欢吃:山楂片、法式小面包(软软的)、果冻、 不喜欢喝:对饮料无感、不喜欢脉动、可乐雪碧等少量还行、 喜欢:啃骨头、排骨…

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

在上一篇文章中,我写到了如何将TUM数据生成BundleFusion所需要的数据集,生成的数据集如下图中所示.并且是将每一组数据的groundtruth.txt中的位姿数据写如到这里的pose文件中,作为每一帧图像的先验位姿. 今天我便将生成的数据集转换为了.sens格式,然后运行bundlefusion算法,第…

每一次突破都是一种进步

一直以来,我接触一门新技术,都是先看开发文档,了解了这个技术是做什么的,能做什么。但是不知道怎么起步,也不敢贸然动手。我的解决办法是看视频,看别人怎么使用,跟着别人做,然后听别…

mysql盲注学习-1

mysql: 1.left() //left()函数 left(a,b)从左侧截取a,的b位 2.mid() //mid()函数 参数 描述 column_name 必需。要提取字符的字段。 start 必需。规定开始位置(起始值是 1)。 length 可选。要返回的字符数。如果省略,则 MID() 函数…

二分学习笔记

写在前面 二分是一种常用且非常精妙的算法,常常是我们解决问题的突破口。二分的基本用途是在单调序列或单调函数中做查找。因此当问题的答案具有单调性时,就可以通过二分把求解转化为判定。进一步地,我们还可以通过三分法解决单调函数的极值以…

解析.sens数据集

python脚本在下面网址中https://github.com/ScanNet/ScanNet/tree/master/SensReader/python 一定要使用python2运行此脚本. 使用指令如下 python reader.py --filename /media/yunlei/YL/DATASETS/ICL_DATABASE/lr_kt1/living_room_traj1n_frei_png.sens --output_path /me…

ConcurrentHashMap 解读

初始化&#xff1a; 问题&#xff1a;如何当且仅只有一个线程初始化table 1 private final Node<K,V>[] initTable() {2 Node<K,V>[] tab; int sc;3 while ((tab table) null || tab.length 0) {4 if ((sc sizeCtl) < 0)5 …

XML Schema 基本结构

<?xml version1.0?> <Schema name"cangchuSchema" metamodelVersion"4.0"><PhysicalSchema><Table name"highway_toll"><Key><Column name"uid"/></Key></Table><Table name&qu…

关于系统自带 .NET Framework 版本的说明

系统自带版本&#xff1a; Windows XP (SP3) .NET Framework 1.1Windows 7 (SP1) .NET Framework 3.5.1Windows 8.1 .NET Framework 4.5.1Windows 10 (1507) .NET Framework 4.6Windows 10 (1511) .NET Framework 4.6.1Windows 10 (1607) .NET Framework 4.6.2Windows 10 (1703…

BundleFusion那些事儿

背景&#xff1a;前面几篇博客中写了很多关于BundleFusion的东西&#xff0c;主要包括bundlefusion的论文阅读笔记&#xff0c;.sens数据集的生成等&#xff0c;经过最近几天的工作&#xff0c;我对bundlefusion又有了新的技术积累&#xff0c;在这里整理一下&#xff0c;也算是…

问题:图片怎么保存到数据库, 以及怎么把图片从数据库中取出来使用?(已解决)...

简单&#xff0c;不保存图片到数据库&#xff0c;而是图片的路径。 也就是说&#xff0c;先把图片下载到服务器的指定目录下&#xff0c;然后&#xff0c;在把相对的路径保存到数据库中。 如果下次获取图片&#xff0c;就访问数据库&#xff0c;获取图片路径&#xff0c;然后根…

Oracle Study之--Oracle 11gR2通过RMAN克隆数据库

Oracle Study之--Oracle 11gR2通过RMAN克隆数据库Purpose of Database Duplication A duplicate database is useful for a variety of purposes, most of which involve testing. You can perform the following tasks in a duplicate database: Test backup and recovery pro…

ubuntu16.04安装evo

背景:这已经是我第二次尝试安装evo了,最近因为在bundlefusion加入groundtruth的问题搞的很烦躁,我怀疑是不是我给定的groundtruth是不是不正确,所以我就写python脚本,获取计算生成的位姿数据,写入的groundtruth位姿数据.获取数据后,将数据可视化就成了一个很重要的问题,我还是打…

前端性能优化之gzip

gzip是GNUzip的缩写&#xff0c;它是一个GNU自由软件的文件压缩程序。它最早由Jean-loup Gailly和Mark Adler创建&#xff0c;用于UNⅨ系统的文件压缩。我们在Linux中经常会用到后缀为.gz的文件&#xff0c;它们就是GZIP格式的。现今已经成为Internet 上使用非常普遍的一种数据…

luogu2770 航空路线问题 网络流

题目大意&#xff1a; 给定一张航空图&#xff0c;图中顶点代表城市&#xff0c;边代表 2 城市间的直通航线。现要求找出一条满足下述限制条件的且途经城市最多的旅行路线。(1)从最西端城市出发&#xff0c;单向从西向东途经若干城市到达最东端城市&#xff0c;然后再单向从东向…

手机录音ogg格式怎么转换mp3

Ogg这种音频格式刚出来的时候大家是非常热爱的&#xff0c;但是随着时代的发展&#xff0c;这种音频格式已经已经被取代了&#xff0c;现在呢走在音频格式前端的是MP3格式&#xff0c;这是大家都比较熟悉的&#xff0c;但是我们还是会经常下载到ogg这种格式的音频&#xff0c;就…

TP3.2设置URL伪静态满足更好的SEO效果

URL伪静态通常是为了满足更好的SEO效果&#xff0c;ThinkPHP支持伪静态URL设置&#xff0c;可以通过设置URL_HTML_SUFFIX参数随意在URL的最后增加你想要的静态后缀&#xff0c;而不会影响当前操作的正常执行。 例如&#xff0c;我们设置 URL_HTML_SUFFIX>shtml 的话&#xf…