Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9412370
  • 博文数量: 1748
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 20070
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1748)

文章存档

2024年(24)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: 其他平台

2021-03-19 14:40:41

环境 ubuntu 16.04 + ROS kinetic + ORB_SLAM

1. 准备数据集以及运行时文件
下载 rgbd_dataset_freiburg2_pioneer_360.tgz 数据, 解压,生成 associations.txt

associate.py文件来自于 /work/ws/src/ORB_SLAM3/evaluation/associate.py, 并稍作修改。

点击(此处)折叠或打开

  1. #!/usr/bin/python2.7

  2. # Requirements:
  3. # sudo apt-get install python-argparse

  4. """
  5. 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.

  6. 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.
  7. """

  8. import argparse
  9. import sys
  10. import os
  11. import numpy


  12. def read_file_list(filename):
  13.     """
  14.     Reads a trajectory from a text file.
  15.     
  16.     File format:
  17.     The file format is "stamp d1 d2 d3 ...", where stamp denotes the time stamp (to be matched)
  18.     and "d1 d2 d3.." is arbitary data (e.g., a 3D position and 3D orientation) associated to this timestamp.
  19.     
  20.     Input:
  21.     filename -- File name
  22.     
  23.     Output:
  24.     dict -- dictionary of (stamp,data) tuples
  25.     
  26.     """
  27.     file = open(filename)
  28.     data = file.read()
  29.     lines = data.replace(","," ").replace("\t"," ").split("\n")
  30.     list = [[v.strip() for v in line.split(" ") if v.strip()!=""] for line in lines if len(line)>0 and line[0]!="#"]
  31.     list = [(float(l[0]),l[1:]) for l in list if len(l)>1]
  32.     return dict(list)

  33. def associate(first_list, second_list,offset,max_difference):
  34.     """
  35.     Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim
  36.     to find the closest match for every input tuple.
  37.     
  38.     Input:
  39.     first_list -- first dictionary of (stamp,data) tuples
  40.     second_list -- second dictionary of (stamp,data) tuples
  41.     offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
  42.     max_difference -- search radius for candidate generation

  43.     Output:
  44.     matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
  45.     
  46.     """
  47.     first_keys = first_list.keys()
  48.     second_keys = second_list.keys()
  49.     potential_matches = [(abs(a - (b + offset)), a, b)
  50.                          for a in first_keys
  51.                          for b in second_keys
  52.                          if abs(a - (b + offset)) < max_difference]
  53.     potential_matches.sort()
  54.     matches = []
  55.     for diff, a, b in potential_matches:
  56.         if a in first_keys and b in second_keys:
  57.             first_keys.remove(a)
  58.             second_keys.remove(b)
  59.             matches.append((a, b))
  60.     
  61.     matches.sort()
  62.     return matches

  63. if __name__ == '__main__':
  64.     
  65.     # parse command line
  66.     parser = argparse.ArgumentParser(description='''
  67.     This script takes two data files with timestamps and associates them
  68.     ''')
  69.     parser.add_argument('first_file', help='first text file (format: timestamp data)')
  70.     parser.add_argument('second_file', help='second text file (format: timestamp data)')
  71.     parser.add_argument('--first_only', help='only output associated lines from first file', action='store_true')
  72.     parser.add_argument('--offset', help='time offset added to the timestamps of the second file (default: 0.0)',default=0.0)
  73.     parser.add_argument('--max_difference', help='maximally allowed time difference for matching entries (default: 0.02)',default=0.02)
  74.     args = parser.parse_args()

  75.     first_list = read_file_list(args.first_file)
  76.     second_list = read_file_list(args.second_file)

  77.     matches = associate(first_list, second_list,float(args.offset),float(args.max_difference))

  78.     if args.first_only:
  79.         for a,b in matches:
  80.             print("%f %s"%(a," ".join(first_list[a])))
  81.     else:
  82.         for a,b in matches:
  83.             print("%f %s %f %s"%(a," ".join(first_list[a]),b-float(args.offset)," ".join(second_list[b])))
执行

点击(此处)折叠或打开

  1. PATH_TO_SEQUENCE_FOLDER=/media/iibull/backup/ORB_SLAM3_Data/RGBD/rgbd_dataset
  2. ASSOCIATIONS_FILE=/media/iibull/backup/ORB_SLAM3_Data/RGBD/rgbd_dataset/associations.txt
  3. ./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml ${PATH_TO_SEQUENCE_FOLDER} ${ASSOCIATIONS_FILE}



执行的日志信息为

点击(此处)折叠或打开

  1. iibull@URay:/work/ws/src/ORB_SLAM3$ PATH_TO_SEQUENCE_FOLDER=/media/iibull/backup/ORB_SLAM3_Data/RGBD/rgbd_dataset
  2. iibull@URay:/work/ws/src/ORB_SLAM3$ ASSOCIATIONS_FILE=/media/iibull/backup/ORB_SLAM3_Data/RGBD/rgbd_dataset/associations.txt
  3. iibull@URay:/work/ws/src/ORB_SLAM3$ ./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml ${PATH_TO_SEQUENCE_FOLDER} ${ASSOCIATIONS_FILE}

  4. ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
  5. ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
  6. This program comes with ABSOLUTELY NO WARRANTY;
  7. This is free software, and you are welcome to redistribute it
  8. under certain conditions. See LICENSE.txt.

  9. Input sensor was set to: RGB-D

  10. Loading ORB Vocabulary. This could take a while...
  11. Vocabulary

  12. Creation of new map with id: 0
  13. Creation of new map with last KF id: 0
  14. Seq. Name:

  15. Camera Parameters:
  16. - Camera: Pinhole
  17. - fx: 517.306
  18. - fy: 516.469
  19. - cx: 318.643
  20. - cy: 255.314
  21. - k1: 0.262383
  22. - k2: -0.953104
  23. - p1: -0.005358
  24. - p2: 0.002628
  25. - k3: 1.16331
  26. - fps: 30
  27. - color order: RGB (ignored if grayscale)

  28. Depth Threshold (Close/Far Points): 0

  29. ORB Extractor Parameters:
  30. - Number of Features: 1000
  31. - Scale Levels: 8
  32. - Scale Factor: 1.2
  33. - Initial Fast Threshold: 20
  34. - Minimum Fast Threshold: 7

  35. -------
  36. Start processing sequence ...
  37. Images in the sequence: 830

  38. First KF:0; Map init KF:0
  39. New Map created with 740 points
  40. virtual int g2o::SparseOptimizer::optimize(int, bool): 0 vertices to optimize, maybe forgot to call initializeOptimization()
  41. virtual int g2o::SparseOptimizer::optimize(int, bool): 0 vertices to optimize, maybe forgot to call initializeOptimization()
  42. virtual int g2o::SparseOptimizer::optimize(int, bool): 0 vertices to optimize, maybe forgot to call initializeOptimization()
  43. KF in map: 77
  44. Fail to track local
  45. Fail to track local
  46. Creation of new map with id: 1
  47. Exits current map
  48. Saved map with ID: 0
  49. Creation of new map with last KF id: 77
  50. First KF:77; Map init KF:77
  51. New Map created with 518 points
  52. Fail to track local
  53. Creation of new map with id: 2
  54. Exits current map
  55. Saved map with ID: 1
  56. Creation of new map with last KF id: 143
  57. First KF:143; Map init KF:143
  58. New Map created with 909 points
  59. virtual int g2o::SparseOptimizer::optimize(int, bool): 0 vertices to optimize, maybe forgot to call initializeOptimization()
  60. -------

  61. median tracking time: 0.0300204
  62. mean tracking time: 0.0314181

  63. Saving camera trajectory to CameraTrajectory.txt ...

  64. Saving keyframe trajectory to KeyFrameTrajectory.txt ...
  65. QObject::~QObject: Timers cannot be stopped from another thread
目前可惜的是: ORB-SLAM3 不是最终产品, 它生成地图但是无法把他们保存到文件中, 也无法从文件加载它们。

目前有 Osmap尝试对ORB-SLAM2的地图(单目地图)进行序列化,它使用了google protoc的协议缓冲。但一直处于有崩溃的情况,在2020.03已经不再更新维持开发计划。

阅读(4034) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~