File tree 1 file changed +29
-0
lines changed
modules/aruco/misc/python/test
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -30,5 +30,34 @@ def test_idsAccessibility(self):
30
30
with self .assertRaises (cv .error ):
31
31
board .setIds (np .array ([0 ]))
32
32
33
+ def test_write_read_dict (self ):
34
+
35
+ try :
36
+ aruco_dict = cv .aruco .getPredefinedDictionary (cv .aruco .DICT_5X5_50 )
37
+ markers_gold = aruco_dict .bytesList
38
+
39
+ # write aruco_dict
40
+ filename = "test_dict.yml"
41
+ fs_write = cv .FileStorage (filename , cv .FileStorage_WRITE )
42
+ aruco_dict .writeDictionary (fs_write )
43
+ fs_write .release ()
44
+
45
+ # reset aruco_dict
46
+ aruco_dict = cv .aruco .getPredefinedDictionary (cv .aruco .DICT_6X6_250 )
47
+
48
+ # read aruco_dict
49
+ fs_read = cv .FileStorage (filename , cv .FileStorage_READ )
50
+ aruco_dict .readDictionary (fs_read .root ())
51
+ fs_read .release ()
52
+
53
+ # check equal
54
+ self .assertEqual (aruco_dict .markerSize , 5 )
55
+ self .assertEqual (aruco_dict .maxCorrectionBits , 3 )
56
+ np .testing .assert_array_equal (aruco_dict .bytesList , markers_gold )
57
+
58
+ finally :
59
+ if os .path .exists (filename ):
60
+ os .remove (filename )
61
+
33
62
if __name__ == '__main__' :
34
63
NewOpenCVTests .bootstrap ()
You can’t perform that action at this time.
0 commit comments