Skip to content

Commit

Permalink
add python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrPanov committed Apr 20, 2022
1 parent ed749c5 commit 1d294fd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/aruco/misc/python/test/test_aruco.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ def test_write_read_dict(self):
if os.path.exists(filename):
os.remove(filename)

def test_identify(self):
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
expected_idx = 9
expected_rotation = 2
bit_marker = np.array([[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 1]], dtype=np.uint8)

check, idx, rotation = aruco_dict.identify(bit_marker, 0)

self.assertTrue(check, True)
self.assertEqual(idx, expected_idx)
self.assertEqual(rotation, expected_rotation)

def test_getDistanceToId(self):
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
idx = 7
rotation = 3
bit_marker = np.array([[0, 1, 0, 1], [0, 1, 1, 1], [1, 1, 0, 0], [0, 1, 0, 0]])
dist = aruco_dict.getDistanceToId(bit_marker, idx, dtype=np.uint8)

self.assertEqual(dist, 0)

if __name__ == '__main__':
NewOpenCVTests.bootstrap()

0 comments on commit 1d294fd

Please sign in to comment.