diff options
author | Théo de la Hogue | 2023-09-06 09:56:36 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-09-06 09:56:36 +0200 |
commit | 067b3c6dc2588be4c4e416f4f07b7dd45cf1bc67 (patch) | |
tree | 843b60f086face2a547ea1f539d09c32699b793c | |
parent | 08bb1e067bc02190519023810b70c08897972804 (diff) | |
download | argaze-067b3c6dc2588be4c4e416f4f07b7dd45cf1bc67.zip argaze-067b3c6dc2588be4c4e416f4f07b7dd45cf1bc67.tar.gz argaze-067b3c6dc2588be4c4e416f4f07b7dd45cf1bc67.tar.bz2 argaze-067b3c6dc2588be4c4e416f4f07b7dd45cf1bc67.tar.xz |
Renaming detect_and_project method into watch.
-rw-r--r-- | src/argaze/ArFeatures.py | 10 | ||||
-rw-r--r-- | src/argaze/ArUcoMarkers/ArUcoCamera.py | 36 | ||||
-rw-r--r-- | src/argaze/utils/demo_aruco_markers_run.py | 2 |
3 files changed, 25 insertions, 23 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 1a13092..d7c70b1 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -48,7 +48,7 @@ class PoseEstimationFailed(Exception): class SceneProjectionFailed(Exception): """ - Exception raised by ArCamera detect_and_project method when the scene can't be projected. + Exception raised by ArCamera watch method when the scene can't be projected. """ def __init__(self, message): @@ -1413,15 +1413,15 @@ class ArCamera(ArFrame): yield scene_frame - def detect_and_project(self, image: numpy.array) -> Tuple[float, dict]: + def watch(self, image: numpy.array) -> Tuple[float, dict]: """Detect AR features from image and project scenes into camera frame.""" - raise NotImplementedError('detect_and_project() method not implemented') + raise NotImplementedError('watch() method not implemented') def look(self, timestamp: int|float, gaze_position: GazeFeatures.GazePosition): """Project timestamped gaze position into each scene frames. - !!! warning detect_and_project method needs to be called first. + !!! warning watch method needs to be called first. """ # Can't use camera frame when it is locked @@ -1470,7 +1470,7 @@ class ArCamera(ArFrame): def map(self): """Project camera frame background into scene frames background. - .. warning:: detect_and_project method needs to be called first. + .. warning:: watch method needs to be called first. """ # Can't use camera frame when it is locked diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py index 5ff4b85..ad70391 100644 --- a/src/argaze/ArUcoMarkers/ArUcoCamera.py +++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py @@ -71,25 +71,27 @@ class ArUcoCamera(ArFeatures.ArCamera): """ # Load ArUco detector - try: - new_detector_data = aruco_camera_data.pop('aruco_detector') + new_detector_data = aruco_camera_data.pop('aruco_detector') - new_aruco_dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary(**new_detector_data.pop('dictionary')) - new_marker_size = new_detector_data.pop('marker_size') + new_aruco_dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary(**new_detector_data.pop('dictionary')) + new_marker_size = new_detector_data.pop('marker_size') - # Check optic_parameters value type - optic_parameters_value = new_detector_data.pop('optic_parameters') + # Check optic_parameters value type + optic_parameters_value = new_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) + new_optic_parameters = ArUcoOpticCalibrator.OpticParameters(**optic_parameters_value) + + # Load ArUco detector parameters + try: # Check detector parameters value type detector_parameters_value = new_detector_data.pop('parameters') @@ -104,12 +106,12 @@ class ArUcoCamera(ArFeatures.ArCamera): else: new_aruco_detector_parameters = ArUcoDetector.DetectorParameters(**detector_parameters_value) - - new_aruco_detector = ArUcoDetector.ArUcoDetector(new_aruco_dictionary, new_marker_size, new_optic_parameters, new_aruco_detector_parameters) except KeyError: - new_aruco_detector = None + new_aruco_detector_parameters = ArUcoDetector.DetectorParameters() + + new_aruco_detector = ArUcoDetector.ArUcoDetector(new_aruco_dictionary, new_marker_size, new_optic_parameters, new_aruco_detector_parameters) # Load ArUcoScenes new_scenes = {} @@ -159,7 +161,7 @@ class ArUcoCamera(ArFeatures.ArCamera): return ArUcoCamera.from_dict(aruco_camera_data, working_directory) - def detect_and_project(self, image: numpy.array) -> Tuple[float, dict]: + def watch(self, image: numpy.array) -> Tuple[float, dict]: """Detect environment aruco markers from image and project scenes into camera frame. Returns: diff --git a/src/argaze/utils/demo_aruco_markers_run.py b/src/argaze/utils/demo_aruco_markers_run.py index dd79569..6dc081d 100644 --- a/src/argaze/utils/demo_aruco_markers_run.py +++ b/src/argaze/utils/demo_aruco_markers_run.py @@ -75,7 +75,7 @@ def main(): if success: # Detect and project AR features - detection_time, exceptions = aruco_camera.detect_and_project(video_image) + detection_time, exceptions = aruco_camera.watch(video_image) # Get ArUcoCamera frame image aruco_camera_image = aruco_camera.image() |