diff options
Diffstat (limited to 'src/argaze/ArUcoMarkers/ArUcoCamera.py')
-rw-r--r-- | src/argaze/ArUcoMarkers/ArUcoCamera.py | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py index dcabd81..916c9ed 100644 --- a/src/argaze/ArUcoMarkers/ArUcoCamera.py +++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py @@ -150,11 +150,8 @@ class ArUcoCamera(ArFeatures.ArCamera): This method timestamps camera frame and its layers. """ - # Use try block to always release the camera frame lock in finally block - try: - - # Lock camera frame exploitation - self.acquire() + # Use camera frame locker feature + with self.locker: # Detect aruco markers self.aruco_detector.detect_markers(image) @@ -201,13 +198,8 @@ class ArUcoCamera(ArFeatures.ArCamera): pass - finally: - - # Unlock camera frame exploitation - self.release() - - # Timestamp camera frame - self.timestamp = timestamp + # Timestamp camera frame + self.timestamp = timestamp def __image(self, draw_detected_markers: dict = None, draw_scenes: dict = None, draw_optic_parameters_grid: dict = None, **kwargs: dict) -> numpy.array: """Get frame image with ArUco detection visualisation. @@ -223,22 +215,25 @@ class ArUcoCamera(ArFeatures.ArCamera): # Note: don't lock/unlock camera frame here as super().image manage it. image = super().image(**kwargs) - # Draw optic parameters grid if required - if draw_optic_parameters_grid is not None: + # Use frame locker feature + with self.locker: + + # Draw optic parameters grid if required + if draw_optic_parameters_grid is not None: - self.aruco_detector.optic_parameters.draw(image, **draw_optic_parameters_grid) + self.aruco_detector.optic_parameters.draw(image, **draw_optic_parameters_grid) - # Draw scenes if required - if draw_scenes is not None: + # Draw scenes if required + if draw_scenes is not None: - for scene_name, draw_scenes_parameters in draw_scenes.items(): + for scene_name, draw_scenes_parameters in draw_scenes.items(): - self.scenes[scene_name].draw(image, **draw_scenes_parameters) + self.scenes[scene_name].draw(image, **draw_scenes_parameters) - # Draw detected markers if required - if draw_detected_markers is not None: + # Draw detected markers if required + if draw_detected_markers is not None: - self.aruco_detector.draw_detected_markers(image, draw_detected_markers) + self.aruco_detector.draw_detected_markers(image, draw_detected_markers) return image |