TUM RGBD数据集的tool-associate.py使用遇到的问题

在使用TUM数据集上的数据时,首先要对深度图序列和rgb图序列进行时间戳的配准,数据集上自带了一个Python脚本可以很容易得完成这件事。 用法: 

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

但是,我在使用时总是报错— 

Traceback (most recent call last):
  File "associate.py", line 118, in <module>
    matches = associate(first_list, second_list,float(args.offset),float(args.max_difference))    
  File "associate.py", line 97, in associate
    first_keys.remove(a)
AttributeError: 'dict_keys' object has no attribute 'remove'

出现该问题的原因是,因为Python2和Python3的版本问题,语法上出现了差异。解决方法有两种: 

第一:

(见https://blog.csdn.net/u012796629/article/details/87932936

需要将associate.py中第86行87行的

    first_keys = first_list.keys()
    second_keys = second_list.keys()
改为

    first_keys = list(first_list.keys())
    second_keys = list(second_list.keys())

第二: 

在终端上输入Python,回车,会显示我的Python的版本为3.5;如果输入Python2,版本为2.7,因此只需要运行: 

python2 associate.py rgb.txt depth.txt > associate.txt

即可解决。   

Done。 

猜你喜欢

转载自blog.csdn.net/weixin_43795395/article/details/89716824