aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2024-03-11 17:18:42 +0100
committerThéo de la Hogue2024-03-11 17:18:42 +0100
commit6ebb4b5e418a0a69fce423eccfa35bcbb6502b70 (patch)
tree2da61e83bb619e5441c1b00bb8f0259c0474d608 /src
parent78d2f6801e2b1c80d4685c9fb3186c205b7dc9e6 (diff)
downloadargaze-6ebb4b5e418a0a69fce423eccfa35bcbb6502b70.zip
argaze-6ebb4b5e418a0a69fce423eccfa35bcbb6502b70.tar.gz
argaze-6ebb4b5e418a0a69fce423eccfa35bcbb6502b70.tar.bz2
argaze-6ebb4b5e418a0a69fce423eccfa35bcbb6502b70.tar.xz
removing property decorator to method that was not an object property but an object status.
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoDetector.py34
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoScene.py4
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoCamera.py4
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoDetector.py7
-rw-r--r--src/argaze/utils/aruco_markers_group_export.py4
5 files changed, 24 insertions, 29 deletions
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoDetector.py b/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
index 403d1a6..06c56f5 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
@@ -51,8 +51,8 @@ class TestArUcoDetectorClass(unittest.TestCase):
self.assertEqual(aruco_detector.dictionary.name, 'DICT_ARUCO_ORIGINAL')
self.assertEqual(aruco_detector.marker_size, 3)
self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.optic_parameters.dimensions, [0, 0]))
- self.assertEqual(aruco_detector.detected_markers_number, 0)
- self.assertEqual(aruco_detector.detected_markers, {})
+ self.assertEqual(aruco_detector.detected_markers_number(), 0)
+ self.assertEqual(aruco_detector.detected_markers(), {})
aruco_dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary('DICT_APRILTAG_16h5')
aruco_detector = ArUcoDetector.ArUcoDetector(aruco_dictionary, 5.2)
@@ -61,8 +61,8 @@ class TestArUcoDetectorClass(unittest.TestCase):
self.assertEqual(aruco_detector.dictionary.name, 'DICT_APRILTAG_16h5')
self.assertEqual(aruco_detector.marker_size, 5.2)
self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.optic_parameters.dimensions, [0, 0]))
- self.assertEqual(aruco_detector.detected_markers_number, 0)
- self.assertEqual(aruco_detector.detected_markers, {})
+ self.assertEqual(aruco_detector.detected_markers_number(), 0)
+ self.assertEqual(aruco_detector.detected_markers(), {})
def test_from_json(self):
"""Test ArUcoDetector creation."""
@@ -94,24 +94,24 @@ class TestArUcoDetectorClass(unittest.TestCase):
# Check ArUcoMarker detection
aruco_detector.detect_markers(image)
- self.assertEqual(aruco_detector.detected_markers_number, 1)
+ self.assertEqual(aruco_detector.detected_markers_number(), 1)
- self.assertEqual(aruco_detector.detected_markers[0].dictionary, aruco_detector.dictionary)
- self.assertEqual(aruco_detector.detected_markers[0].identifier, 0)
- self.assertEqual(aruco_detector.detected_markers[0].size, 3)
+ self.assertEqual(aruco_detector.detected_markers()[0].dictionary, aruco_detector.dictionary)
+ self.assertEqual(aruco_detector.detected_markers()[0].identifier, 0)
+ self.assertEqual(aruco_detector.detected_markers()[0].size, 3)
# Check corner positions with -/+ 10 pixels precision
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].corners[0][0].astype(int), numpy.array([3823, 2073]), decimal=-1))
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].corners[0][1].astype(int), numpy.array([4177, 2073]), decimal=-1))
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].corners[0][2].astype(int), numpy.array([4177, 2427]), decimal=-1))
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].corners[0][3].astype(int), numpy.array([3823, 2427]), decimal=-1))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].corners[0][0].astype(int), numpy.array([3823, 2073]), decimal=-1))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].corners[0][1].astype(int), numpy.array([4177, 2073]), decimal=-1))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].corners[0][2].astype(int), numpy.array([4177, 2427]), decimal=-1))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].corners[0][3].astype(int), numpy.array([3823, 2427]), decimal=-1))
# Check marker pose estimation
aruco_detector.estimate_markers_pose([0])
# Check marker translation with -/+ 0.1 cm precision and rotation with -/+ 0.001 radian precision
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].translation, numpy.array([33.87, 19.05, 0.]), decimal=1))
- self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers[0].rotation, numpy.array([[1., 0., 0.], [0., -1., 0.], [0., 0., -1.]]), decimal=3))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].translation, numpy.array([33.87, 19.05, 0.]), decimal=1))
+ self.assertIsNone(numpy.testing.assert_almost_equal(aruco_detector.detected_markers()[0].rotation, numpy.array([[1., 0., 0.], [0., -1., 0.], [0., 0., -1.]]), decimal=3))
# Check detect metrics
detect_count, markers_count = aruco_detector.detection_metrics
@@ -131,9 +131,9 @@ class TestArUcoDetectorClass(unittest.TestCase):
# Check ArUcoMarker board detection
aruco_detector.detect_board(image, aruco_board, aruco_board.markers_number)
- self.assertEqual(aruco_detector.board_corners_number, aruco_board.corners_number)
- self.assertEqual(len(aruco_detector.board_corners), 24)
- self.assertEqual(len(aruco_detector.board_corners_identifier), 24)
+ self.assertEqual(aruco_detector.board_corners_number(), aruco_board.corners_number)
+ self.assertEqual(len(aruco_detector.board_corners()), 24)
+ self.assertEqual(len(aruco_detector.board_corners_identifier()), 24)
if __name__ == '__main__':
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoScene.py b/src/argaze.test/ArUcoMarkers/ArUcoScene.py
index 628eac5..0d7b601 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoScene.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoScene.py
@@ -39,7 +39,7 @@ class TestArUcoMarkersGroupClass(unittest.TestCase):
def setup_markers(self):
# Prepare detected markers
- self.detected_markers = {
+ self.detected_markers() = {
0: ArUcoMarker.ArUcoMarker('DICT_ARUCO_ORIGINAL', 0, 1.),
1: ArUcoMarker.ArUcoMarker('DICT_ARUCO_ORIGINAL', 1, 1.),
2: ArUcoMarker.ArUcoMarker('DICT_ARUCO_ORIGINAL', 2, 1.),
@@ -47,7 +47,7 @@ class TestArUcoMarkersGroupClass(unittest.TestCase):
}
# Prepare scene markers and remaining markers
- self.scene_markers, self.remaining_markers = self.aruco_markers_group.filter_markers(self.detected_markers)
+ self.scene_markers, self.remaining_markers = self.aruco_markers_group.filter_markers(self.detected_markers())
def test_new_from_obj(self):
"""Test ArUcoMarkersGroup creation."""
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py
index c5f8892..bf51a2e 100644
--- a/src/argaze/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py
@@ -158,7 +158,7 @@ class ArUcoCamera(ArFeatures.ArCamera):
try:
# Build AOI scene directly from detected ArUco marker corners
- self.layers[??].aoi_2d_scene |= scene.build_aruco_aoi_scene(self.__aruco_detector.detected_markers)
+ self.layers[??].aoi_2d_scene |= scene.build_aruco_aoi_scene(self.__aruco_detector.detected_markers())
except ArFeatures.PoseEstimationFailed:
@@ -166,7 +166,7 @@ class ArUcoCamera(ArFeatures.ArCamera):
'''
# Estimate scene pose from detected scene markers
- tvec, rmat, _ = scene.estimate_pose(self.__aruco_detector.detected_markers, timestamp=self.timestamp)
+ tvec, rmat, _ = scene.estimate_pose(self.__aruco_detector.detected_markers(), timestamp=self.timestamp)
# Project scene into camera frame according estimated pose
for layer_name, layer_projection in scene.project(tvec, rmat, self.visual_hfov, self.visual_vfov, timestamp=self.timestamp):
diff --git a/src/argaze/ArUcoMarkers/ArUcoDetector.py b/src/argaze/ArUcoMarkers/ArUcoDetector.py
index 19b0f45..505eaf9 100644
--- a/src/argaze/ArUcoMarkers/ArUcoDetector.py
+++ b/src/argaze/ArUcoMarkers/ArUcoDetector.py
@@ -333,13 +333,11 @@ class ArUcoDetector(DataFeatures.PipelineStepObject):
marker.size = size
marker.points = markers_points.reshape(4, 3).dot(marker.rotation) - marker.translation
- @property
def detected_markers(self) -> dict[ArUcoMarkerType]:
"""Access to detected markers dictionary."""
return self.__detected_markers
- @property
def detected_markers_number(self) -> int:
"""Return detected markers number."""
@@ -390,19 +388,16 @@ class ArUcoDetector(DataFeatures.PipelineStepObject):
cv.drawChessboardCorners(image, ((self.__board.size[0] - 1 ), (self.__board.size[1] - 1)), self.__board_corners, True)
- @property
def board_corners_number(self) -> int:
"""Get detected board corners number."""
return self.__board_corners_number
- @property
def board_corners_identifier(self) -> list[int]:
"""Get detected board corners identifier."""
return self.__board_corners_ids
- @property
def board_corners(self) -> list:
"""Get detected board corners."""
@@ -440,7 +435,7 @@ class Observer(DataFeatures.PipelineStepObserver):
"""Update ArUco markers detection metrics."""
self.__try_count += 1
- detected_markers_list = list(aruco_detector.detected_markers.keys())
+ detected_markers_list = list(aruco_detector.detected_markers().keys())
if len(detected_markers_list):
diff --git a/src/argaze/utils/aruco_markers_group_export.py b/src/argaze/utils/aruco_markers_group_export.py
index 5012d01..dd3d914 100644
--- a/src/argaze/utils/aruco_markers_group_export.py
+++ b/src/argaze/utils/aruco_markers_group_export.py
@@ -121,7 +121,7 @@ def main():
aruco_detector.estimate_markers_pose(args.size)
# Build aruco scene from detected markers
- aruco_markers_group = ArUcoMarkersGroup.ArUcoMarkersGroup(aruco_detector.dictionary, aruco_detector.detected_markers)
+ aruco_markers_group = ArUcoMarkersGroup.ArUcoMarkersGroup(aruco_detector.dictionary, aruco_detector.detected_markers())
# Detection suceeded
exception = None
@@ -137,7 +137,7 @@ def main():
aruco_detector.draw_detected_markers(video_image, draw_parameters)
# Write detected markers
- cv2.putText(video_image, f'Detecting markers {list(aruco_detector.detected_markers.keys())}', (20, video_height-40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+ cv2.putText(video_image, f'Detecting markers {list(aruco_detector.detected_markers().keys())}', (20, video_height-40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
# Write timing
cv2.putText(video_image, f'Frame at {int(current_image_time)}ms', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)