-
Notifications
You must be signed in to change notification settings - Fork 0
/
globmatinterpret.py
71 lines (37 loc) · 1.58 KB
/
globmatinterpret.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
import sys, os
sys.path.append('./libs')
import numpy as np
import scipy.io
from libs import *
import matlab.engine
import numpy as np
import scipy.io
def CalculateGlobICP():
eng = matlab.engine.start_matlab()
#create a list of numpy arrays
#50
eng.globalProcrustesWrapper(modelpcs,5, nargout=0) #sending input to the function
eng.cd("./GlobalProcrustesICP")
return RetrieveGlobICPOutput()
def RetrieveGlobICPOutput(outputpath='./GlobalProcrustesICP/globalIcpOut.mat'):
mat = scipy.io.loadmat(outputpath)
print(mat['R'].shape)
#first dimension is number of cameras, second is number of steps
Hs = [[] for i in range(mat['R'].shape[0])]
for i in range(mat['R'].shape[0]):
#cuz last step returns no rotation
for k in range(mat['R'].shape[1]-1):
Hs[i].append(matmanip.Rt2Homo(mat['R'][i,k],np.squeeze(mat['t'][i,k])))
actualHs = [np.eye(4) for i in range(mat['R'].shape[0])]
print(len(actualHs),actualHs[0].shape)
for i in range(mat['R'].shape[0]):
for k in range(mat['R'].shape[1]-1):
actualHs[i] = np.dot(Hs[i][k] , actualHs[i])
print(actualHs[0].shape)
registeredModel = []
#registeredmodel[0][x][0] cointains the array of points of pointcloud x
for i in range(len(actualHs)):
registeredModel.append(print(mat['registeredModel'][0][i][0]))
#for i in range()
# Rt2Homo(R=None,t=None)
return actualHs,registeredModel