-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_benchmark.py
72 lines (49 loc) · 2 KB
/
load_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
72
import yaml
import open3d as o3d
import numpy as np
import pandas as pd
import os.path as osp
import pickle
from utils import *
T_COLS = ['T00','T01','T02','T03',
'T10','T11','T12','T13',
'T20','T21','T22','T23',
'T30','T31','T32','T33']
def process_single_example(ind,benchmark,faust_data_path,indices_path):
scan_name = benchmark.loc[ind,'Scan']
viewpoint_i = benchmark.loc[ind,'Viewpoint_i']
viewpoint_j = benchmark.loc[ind,'Viewpoint_j']
overlap = benchmark.loc[ind,'overlap']
T_gt = np.array(benchmark[ind,T_COLS]).astype('float64').reshape(4,4)
indices_path = osp.join(indices_path,
f'indices_{scan_name}.pickle')
with open(indices_path,'rb') as f:
indices = pickle.load(f)
pc_o3d = o3d.io.read_point_cloud(osp.join(faust_data_path,scan_name+'.ply'))
pc = np.asarray(pc_o3d.points)
pci = pc[indices[viewpoint_i]]
pci = homo_matmul(pci,T_gt)
pcj = pc[indices[viewpoint_j]]
return_dict = {'scan_name':scan_name,
'viewpoint_i':viewpoint_i,
'viewpoint_j':viewpoint_j,
'overlap':overlap,
'transformation_GT':T_gt,
'pci':pci,
'pcj':pcj}
return return_dict
def load_benchmark(config):
faust_data_path = config['FAUST-DATA-PATH']
partial_view_indices_path = osp.join(config['BENCHMARK-CSV-PATH'],'indices')
benchmark_path = osp.join(config['BENCHMARK-CSV-PATH'],config['BENCHMARK-CSV-NAME'])
benchmark = pd.read_csv(benchmark_path)
N = benchmark.shape[0]
for ind in range(N):
# the goal is to register pcj to pci
# NOTE: this script does nothing -- extend script to do your bidding
return_dict = process_single_example(ind,benchmark,faust_data_path,partial_view_indices_path)
if __name__ == '__main__':
with open('config.yaml','r') as f:
config = yaml.safe_load(f)
config = config['LOAD-BENCHMARK']
load_benchmark(config)