-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
41 lines (34 loc) · 1.18 KB
/
main.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
#!/usr/bin/python
import argparse
import csv
from spaam import SPAAM
def main():
parser = argparse.ArgumentParser(
description='Provide file path to csv file containing Pixel and corresponding 3D Coordinate Values')
parser.add_argument("filePath", type=str, help='path to relevant csv file')
args = parser.parse_args()
with open(args.filePath, newline='') as csvfile:
rows = csv.DictReader(csvfile)
pImage = []
pWorld = []
try:
for row in rows:
pImage.append([float(row['\ufeffDisplay Horizontal Pixel']),
float(row['Display Vertical Pixel'])])
pWorld.append([float(row['HMD Position X']),
float(row['HMD Position Y']), float(row['HMD Position Z'])])
except csv.Error as e:
print(e)
spaam = SPAAM(pImage, pWorld)
G = spaam.get_camera_matrix()
K, A = spaam.get_transformation_matrix()
print("G Matrix:")
print(G)
print("\n")
print("Projection (Camera) Matrix (K):")
print(K)
print("\n")
print("Transformation Matrix (R|t)")
print(A)
if __name__ == '__main__':
main()