aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoBoard.py25
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoBoard.py26
2 files changed, 29 insertions, 22 deletions
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoBoard.py b/src/argaze.test/ArUcoMarkers/ArUcoBoard.py
index 5ca1324..96c38b9 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoBoard.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoBoard.py
@@ -19,7 +19,7 @@ class TestArUcoBoardClass(unittest.TestCase):
square_size = 2
marker_size = 1
- aruco_board = ArUcoBoard.ArUcoBoard('DICT_ARUCO_ORIGINAL', columns, rows, square_size, marker_size)
+ aruco_board = ArUcoBoard.ArUcoBoard(columns, rows, square_size, marker_size, 'DICT_ARUCO_ORIGINAL')
# Check ArUco board
self.assertIsNone(numpy.testing.assert_array_equal(aruco_board.identifiers, [i for i in range(int((columns*rows)/2))]))
@@ -31,19 +31,20 @@ class TestArUcoBoardClass(unittest.TestCase):
"""Test ArUcoBoard creation using a dictionary instance."""
# Check ArUco board creation
- columns = 4
- rows = 3
- square_size = 2
- marker_size = 1
-
aruco_dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary('DICT_ARUCO_ORIGINAL')
- aruco_board = ArUcoBoard.ArUcoBoard(aruco_dictionary, columns, rows, square_size, marker_size)
+ aruco_board = ArUcoBoard.ArUcoBoard(4, 3, 2, 1, aruco_dictionary)
- # Check ArUco board
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_board.identifiers, [i for i in range(int((columns*rows)/2))]))
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_board.size, [columns, rows]))
- self.assertEqual(aruco_board.markers_number, int((columns*rows)/2))
- self.assertEqual(aruco_board.corners_number, (columns-1)*(rows-1))
+ # Check ArUco board dictionary name
+ self.assertEqual(aruco_board.dictionary.name, 'DICT_ARUCO_ORIGINAL')
+
+ def test_new_with_no_dictionary(self):
+ """Test ArUcoBoard creation using a dictionary instance."""
+
+ # Check ArUco board creation
+ aruco_board = ArUcoBoard.ArUcoBoard(4, 3, 2, 1)
+
+ # Check ArUco board dictionary name
+ self.assertEqual(aruco_board.dictionary.name, 'DICT_ARUCO_ORIGINAL')
if __name__ == '__main__':
diff --git a/src/argaze/ArUcoMarkers/ArUcoBoard.py b/src/argaze/ArUcoMarkers/ArUcoBoard.py
index e6772c4..5d2a39d 100644
--- a/src/argaze/ArUcoMarkers/ArUcoBoard.py
+++ b/src/argaze/ArUcoMarkers/ArUcoBoard.py
@@ -9,25 +9,31 @@ import cv2.aruco as aruco
class ArUcoBoard():
"""Calibration chess board with ArUco markers inside."""
- def __init__(self, dictionary: ArUcoMarkersDictionary.ArUcoMarkersDictionary | str, columns: int, rows: int, square_size: float, marker_size: float):
+ def __init__(self, columns: int, rows: int, square_size: float, marker_size: float, dictionary: ArUcoMarkersDictionary.ArUcoMarkersDictionary | str = None):
"""Create columns x rows chess board with ArUco markers at given size in centimeters."""
- # Handle dictionary str or instance
- if type(dictionary) == str:
- self.__dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary(dictionary)
- elif isinstance(dictionary, ArUcoMarkersDictionary.ArUcoMarkersDictionary):
- self.__dictionary = dictionary
- else:
- raise ValueError(f'dictionary: {dictionary}')
-
# Store properties
self.__columns = columns
self.__rows = rows
self.__square_size = square_size # in cm
self.__marker_size = marker_size # in cm
+ # Handle dictionary str or instance
+ if dictionary != None:
+
+ if type(dictionary) == str:
+ self.dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary(dictionary)
+ elif isinstance(dictionary, ArUcoMarkersDictionary.ArUcoMarkersDictionary):
+ self.dictionary = dictionary
+ else:
+ raise ValueError(f'dictionary: {dictionary}')
+
+ else:
+
+ self.dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary()
+
# Create board model
- self.__board = aruco.CharucoBoard((self.__columns, self.__rows), self.__square_size/100., self.__marker_size/100., self.__dictionary.markers)
+ self.__board = aruco.CharucoBoard((self.__columns, self.__rows), self.__square_size/100., self.__marker_size/100., self.dictionary.markers)
def __del__(self):
pass