Skip to content

Commit 010a2d3

Browse files
authored
Merge pull request #16 from scaleapi/nisse-data-loader6
Added intrinsics to camera class
2 parents 0b31897 + e19cecd commit 010a2d3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

python/pandaset/sensors.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def _load_data_file(self, fp):
6969
class Lidar(Sensor):
7070

7171
def __init__(self, directory):
72+
self._intrinsics_structure = None
73+
self.intrinsics = None
7274
Sensor.__init__(self, directory, 'pkl.gz')
7375

7476
def _load_data_file(self, fp):
@@ -78,6 +80,39 @@ def _load_data_file(self, fp):
7880
class Camera(Sensor):
7981
def __init__(self, directory):
8082
Sensor.__init__(self, directory, 'jpg')
83+
self._load_intrinsics()
84+
85+
def load(self):
86+
super().load()
87+
self._load_intrinsics()
8188

8289
def _load_data_file(self, fp):
8390
return Image.open(fp)
91+
92+
def _load_data_structure(self):
93+
super()._load_data_structure()
94+
self._load_intrinsics()
95+
96+
def _load_intrinsics_structure(self):
97+
intrinsics_file = f'{self._directory}/intrinsics.json'
98+
if os.path.isfile(intrinsics_file):
99+
self._intrinsics_structure = intrinsics_file
100+
101+
def _load_intrinsics(self):
102+
self.intrinsics = []
103+
with open(self._intrinsics_structure, 'r') as f:
104+
file_data = json.load(f)
105+
self.intrinsics = Intrinsics(
106+
fx=file_data['fx'],
107+
fy=file_data['fy'],
108+
cx=file_data['cx'],
109+
cy=file_data['cy']
110+
)
111+
112+
113+
class Intrinsics:
114+
def __init__(self, fx, fy, cx, cy):
115+
self.fx = fx,
116+
self.fy = fy,
117+
self.cx = cx,
118+
self.cy = cy

0 commit comments

Comments
 (0)