-
Notifications
You must be signed in to change notification settings - Fork 97
/
benchmark.py
executable file
·72 lines (50 loc) · 1.82 KB
/
benchmark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
import sys
import os
import tarfile
import associate
import matplotlib.pyplot as plt
import numpy as np
if sys.version_info[0] == 3:
from urllib.request import URLopener
elif sys.version_info[0] == 2:
from urllib import URLopener
dataset_url = 'https://vision.in.tum.de/rgbd/dataset/freiburg2/rgbd_dataset_freiburg2_pioneer_slam.tgz'
filename_zip = 'rgbd_dataset_freiburg2_pioneer_slam.tgz'
filename = 'rgbd_dataset_freiburg2_pioneer_slam'
# go to benchmak directory
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
if not os.path.exists(filename_zip):
print('Downloading dataset file ', filename_zip)
testfile = URLopener()
testfile.retrieve(dataset_url, filename_zip)
if not os.path.exists(filename):
print('Extracting dataset ', filename)
tar = tarfile.open(filename_zip, "r:gz")
tar.extractall()
tar.close()
if not os.path.exists(filename + '/depth_gt.txt'):
first_list = associate.read_file_list(filename + '/depth.txt')
second_list = associate.read_file_list(filename + '/groundtruth.txt')
matches = associate.associate(first_list, second_list, 0.0, 0.02)
f = open(filename + '/depth_gt.txt', 'w')
for a,b in matches:
f.write("%f %s %f %s\n"%(a, " ".join(first_list[a]), b-0.0, " ".join(second_list[b])))
f.close()
print('Dataset is ready.')
os.system('rosrun ewok_ring_buffer tum_rgbd_ring_buffer_example rgbd_dataset_freiburg2_pioneer_slam res.txt')
print('Results are ready.')
data = np.loadtxt('res.txt')
plt.figure()
plt.title('Insertion time for Ring Buffer [ms]')
plt.hist(data[:,0]/1e6, 100)
plt.figure()
plt.title('SDF computation for Ring Buffer [ms]')
plt.hist(data[:,1]/1e6, 100)
plt.figure()
plt.title('Insertion time for Octomap [ms]')
plt.hist(data[:,2]/1e6, 100)
plt.show()
print('Done.')