aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoCamera.py15
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoDetector.py23
2 files changed, 27 insertions, 11 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py
index 134e76b..5efc4f8 100644
--- a/src/argaze/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py
@@ -46,8 +46,19 @@ class ArUcoCamera(ArFeatures.ArCamera):
super().__post_init__()
- # Camera frame size should be equals to optic parameters dimensions
- assert(self.size == self.aruco_detector.optic_parameters.dimensions)
+ # Check optic parameters
+ if self.aruco_detector.optic_parameters is not None:
+
+ # Optic parameters dimensions should be equal to camera frame size
+ if self.aruco_detector.optic_parameters.dimensions != self.size:
+
+ raise ArFeatures.LoadingFailed('ArUcoCamera: aruco_detector.optic_parameters.dimensions have to be equal to size.')
+
+ # No optic parameters loaded
+ else:
+
+ # TODO: Create default optic parameters adapted to frame size
+ raise ArFeatures.LoadingFailed('ArUcoCamera: no aruco_detector.optic_parameters.')
def __str__(self) -> str:
"""
diff --git a/src/argaze/ArUcoMarkers/ArUcoDetector.py b/src/argaze/ArUcoMarkers/ArUcoDetector.py
index 73bea88..82c9394 100644
--- a/src/argaze/ArUcoMarkers/ArUcoDetector.py
+++ b/src/argaze/ArUcoMarkers/ArUcoDetector.py
@@ -177,19 +177,24 @@ class ArUcoDetector():
# Load ArUco marker size
new_marker_size = aruco_detector_data.pop('marker_size')
- # Load optic_parameters value type
- optic_parameters_value = aruco_detector_data.pop('optic_parameters')
+ # Load optic parameters
+ try:
+ optic_parameters_value = aruco_detector_data.pop('optic_parameters')
- # str: relative path to .json file
- if type(optic_parameters_value) == str:
+ # str: relative path to .json file
+ if type(optic_parameters_value) == str:
- optic_parameters_value = os.path.join(working_directory, optic_parameters_value)
- new_optic_parameters = ArUcoOpticCalibrator.OpticParameters.from_json(optic_parameters_value)
+ optic_parameters_value = os.path.join(working_directory, optic_parameters_value)
+ new_optic_parameters = ArUcoOpticCalibrator.OpticParameters.from_json(optic_parameters_value)
- # dict:
- else:
+ # dict:
+ else:
+
+ new_optic_parameters = ArUcoOpticCalibrator.OpticParameters(**optic_parameters_value)
+
+ except KeyError:
- new_optic_parameters = ArUcoOpticCalibrator.OpticParameters(**optic_parameters_value)
+ new_optic_parameters = None
# Load ArUco detector parameters
try: