Skip to content

Commit

Permalink
add py test_write_read_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrPanov committed Mar 22, 2022
1 parent a895e6a commit 9873fdc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions modules/aruco/misc/python/test/test_aruco.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,29 @@ def test_idsAccessibility(self):
with self.assertRaises(cv.error):
board.setIds(np.array([0]))

def test_write_read_dict(self):

aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_5X5_50)
markers_gold = aruco_dict.bytesList

# write aruco_dict
filename = "test_dict.yml"
fs_write = cv.FileStorage(filename, cv.FileStorage_WRITE)
aruco_dict.writeDictionary(fs_write)
fs_write.release()

# reset aruco_dict
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_6X6_250)

# read aruco_dict
fs_read = cv.FileStorage(filename, cv.FileStorage_READ)
aruco_dict.readDictionary(fs_read.root())
fs_read.release()

# check equal
self.assertEqual(aruco_dict.markerSize, 5)
self.assertEqual(aruco_dict.maxCorrectionBits, 3)
np.testing.assert_array_equal(aruco_dict.bytesList, markers_gold)

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

0 comments on commit 9873fdc

Please sign in to comment.