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.pswp.cn/news/252391.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/252391.shtml
英文地址,請注明出處:http://en.pswp.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…