aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoScene.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoScene.py b/src/argaze/ArUcoMarkers/ArUcoScene.py
index 8acedb1..0edb253 100644
--- a/src/argaze/ArUcoMarkers/ArUcoScene.py
+++ b/src/argaze/ArUcoMarkers/ArUcoScene.py
@@ -36,6 +36,7 @@ class ArUcoScene(ArFeatures.ArScene):
# Init private attribute
self.__aruco_markers_group = None
+ self.__required_markers_number = 2
@property
def aruco_markers_group(self) -> ArUcoMarkersGroup.ArUcoMarkersGroup:
@@ -53,6 +54,24 @@ class ArUcoScene(ArFeatures.ArScene):
self.__aruco_markers_group.parent = self
+ @property
+ def required_markers_number(self) -> int:
+ """Numbers of markers that have to be detected to allow pose estimation (default: 2)."""
+
+ return self.__required_markers_number
+
+ @required_markers_number.setter
+ def required_markers_number(self, n: int):
+
+ # Constrain number to 1 at least
+ if n < 1:
+
+ self.__required_markers_number = 1
+
+ else:
+
+ self.__required_markers_number = n
+
@DataFeatures.PipelineStepMethod
def estimate_pose(self, detected_markers: dict) -> tuple[numpy.array, numpy.array, dict]:
"""Estimate scene pose from detected ArUco markers.
@@ -78,10 +97,10 @@ class ArUcoScene(ArFeatures.ArScene):
raise ArFeatures.PoseEstimationFailed('No marker belongs to the scene')
- # Pose estimation fails if only one marker belongs to the scene
- if len(scene_markers) == 1:
+ # Pose estimation fails when not enough marker belongs to the scene
+ if len(scene_markers) < self.required_markers_number:
- raise ArFeatures.PoseEstimationFailed('Only one marker belongs to the scene')
+ raise ArFeatures.PoseEstimationFailed(f'Not enough marker belongs to the scene')
# Estimate pose from markers corners
success, tvec, rmat = self.__aruco_markers_group.estimate_pose_from_markers_corners(scene_markers, self.parent.aruco_detector.optic_parameters.K, self.parent.aruco_detector.optic_parameters.D)