-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_dataset.py
39 lines (27 loc) · 1.29 KB
/
test_dataset.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
import numpy as np
from patchmatch_stereo.dataset import Dataset
import unittest
dataset = Dataset("data/")
intrinsics = dataset.get_intrinsics('fountain')
rotation = dataset.get_rotation('fountain')
translation = dataset.get_translation('fountain')
p_mat = dataset.get_p_matrices('fountain')
class MatricesTest(unittest.TestCase):
# def test_init(self):
def test_num_images(self):
"""verify all dataframes have the same number of images"""
self.assertTrue(len(intrinsics.index) == len(rotation.index) == len(translation.index) == len(p_mat.index))
def test_shapes(self):
"""verify that all data has the expected shape"""
self.assertEqual(rotation['rotation'][1].shape, (3,3))
self.assertEqual(translation['translation'][1].shape, (3,1))
self.assertEqual(intrinsics['intrinsics'][1].shape, (3,3))
self.assertEqual(p_mat['pmat'][1].shape, (3,4))
def test_pmat_generation(self):
"""verify that the p_matrices are generated by the standard equation P = K[R.T | -R.T t]"""
# TODO finish this
# append R and t properly
self.assertEqual((np.append(rotation['rotation'][1], translation['translation'][1]).shape), (4,3))
# multiply by K
if __name__ == "__main__":
unittest.main(exit=False, verbosity = 2)