-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbundle2json.py
executable file
·33 lines (25 loc) · 945 Bytes
/
bundle2json.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
#! /usr/bin/python
import json
import sys
if __name__ == "__main__":
if len(sys.argv) < 3:
print "usage: ./bundle2pts.py <bundle file> <json pts file>"
sys.exit()
bundle_file = sys.argv[1]
json_pts_file = sys.argv[2]
print "- Reading [%s] and writing [%s]" % (bundle_file, json_pts_file)
with open(bundle_file) as f_in:
header = f_in.readline()
num_images, num_points = map(int, f_in.readline().split()[0:2])
print num_images, num_points
for i in xrange(num_images*6):
line = f_in.readline()
pts = []
for i in xrange(min(num_points, 20000)):
player_id = f_in.readline()
x, y, z = map(float, f_in.readline().split())
color = f_in.readline()
track = f_in.readline()
pts.append(dict(x=x, y=z))
with open(json_pts_file, 'w') as f_out:
json.dump(pts, f_out)