ORB_SLAM2运行RGBD数据集需要使用图片序列信息

使用以下代码进行汇集:

#!/usr/bin/python
# Software License Agreement (BSD License)
#
# Copyright (c) , Juergen Sturm, TUM
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of TUM nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Requirements:
# sudo apt-get install python-argparse """
The Kinect provides the color and depth images in an un-synchronized way. This means that the set of time stamps from the color images do not intersect with those of the depth images. Therefore, we need some way of associating color images to depth images. For this purpose, you can use the ''associate.py'' script. It reads the time stamps from the rgb.txt file and the depth.txt file, and joins them by finding the best matches.
""" import argparse
import sys
import os
import numpy 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)
and "d1 d2 d3.." is arbitary data (e.g., a 3D position and 3D orientation) associated to this timestamp. Input:
filename -- File name Output:
dict -- dictionary of (stamp,data) tuples """
file = open(filename)
data = file.read()
lines = data.replace(","," ").replace("\t"," ").split("\n")
list = [[v.strip() for v in line.split(" ") if v.strip()!=""] for line in lines if len(line)> and line[]!="#"]
list = [(float(l[]),l[:]) for l in list if len(l)>]
return dict(list) def associate(first_list, second_list,offset,max_difference):
"""
Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim
to find the closest match for every input tuple. Input:
first_list -- first dictionary of (stamp,data) tuples
second_list -- second dictionary of (stamp,data) tuples
offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
max_difference -- search radius for candidate generation Output:
matches -- list of matched tuples ((stamp1,data1),(stamp2,data2)) """
first_keys = first_list.keys()
second_keys = second_list.keys()
potential_matches = [(abs(a - (b + offset)), a, b)
for a in first_keys
for b in second_keys
if abs(a - (b + offset)) < max_difference]
potential_matches.sort()
matches = []
for diff, a, b in potential_matches:
if a in first_keys and b in second_keys:
first_keys.remove(a)
second_keys.remove(b)
matches.append((a, b)) matches.sort()
return matches if __name__ == '__main__': # parse command line
parser = argparse.ArgumentParser(description='''
This script takes two data files with timestamps and associates them
''')
parser.add_argument('first_file', help='first text file (format: timestamp data)')
parser.add_argument('second_file', help='second text file (format: timestamp data)')
parser.add_argument('--first_only', help='only output associated lines from first file', action='store_true')
parser.add_argument('--offset', help='time offset added to the timestamps of the second file (default: 0.0)',default=0.0)
parser.add_argument('--max_difference', help='maximally allowed time difference for matching entries (default: 0.02)',default=0.02)
args = parser.parse_args() first_list = read_file_list(args.first_file)
second_list = read_file_list(args.second_file) matches = associate(first_list, second_list,float(args.offset),float(args.max_difference)) if args.first_only:
for a,b in matches:
print("%f %s"%(a," ".join(first_list[a])))
else:
for a,b in matches:
print("%f %s %f %s"%(a," ".join(first_list[a]),b-float(args.offset)," ".join(second_list[b])))

使用方法:

python  associate.py ×××/rgb.txt  ×××/depth.txt > associate.txt

最新文章

  1. 2013 duilib入门简明教程 -- XML配置界面(6)
  2. Jquery ajax请求
  3. java获取当前执行文件的路径
  4. LeetCode:Remove Duplicates from Sorted List I II
  5. [转载]MVC3缓存:使用页面缓存
  6. Android SDK 环境变量配置(Windows)
  7. 8086的分段寻址技术学习总结(Segmented Addressing)
  8. AWS中的Internet 网关
  9. beautiful soup
  10. flex布局小记
  11. 文科生打开python的大门
  12. leetcode125. Valid Palindrome
  13. Tell Me About Yourself - Best Answers and Examples
  14. 洛谷P1373小a和uim大逃离题解
  15. 策略梯度训练cartpole小游戏
  16. python:函数中五花八门的参数形式(茴香豆的『回』字有四种写法)
  17. vue组件生命周期详解
  18. Nginx配置资源下载目录
  19. GitHub笔记(一)——本地库基础操作
  20. PCL点云特征描述与提取(3)

热门文章

  1. kotlin之字符串模板
  2. Centos 7 安装tomcat并部署jar实录
  3. CMake下,某些选项的后调整
  4. document的属性操作
  5. java:LeakFilling (Mybatis)
  6. CentOS 7 Tomcat 启动后 外部无法访问的问题
  7. MySQL改密
  8. 实验吧-PHP大法-eregi()函数
  9. 【Qt开发】QSplitter的使用和设置
  10. 深入理解java:4.1. 框架编程之Spring MVC