aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArFeatures.py54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 154050f..020c194 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -506,7 +506,7 @@ class ArFrame():
# Return look data
return fixation, look_at, scan_step_analysis, aoi_scan_step_analysis, exception
- def draw(self, image:numpy.array, aoi_color=(0, 0, 0)):
+ def draw(self, image:numpy.array, aoi_color=(0, 0, 0)) -> Exception:
"""
Draw frame into image.
@@ -517,35 +517,48 @@ class ArFrame():
# Lock frame exploitation
self.__look_lock.acquire()
- # Draw aoi
- self.aoi_2d_scene.draw(image, color=aoi_color)
+ # Catch any drawing error
+ exception = None
+
+ try:
- # Draw current gaze position
- self.__gaze_position.draw(image, color=(255, 255, 255))
+ # Draw aoi
+ self.aoi_2d_scene.draw(image, color=aoi_color)
- # Draw current gaze movements
- if self.gaze_movement_identifier:
+ # Draw current gaze position
+ self.__gaze_position.draw(image, color=(255, 255, 255))
- current_fixation = self.gaze_movement_identifier.current_fixation
+ # Draw current gaze movements
+ if self.gaze_movement_identifier:
+
+ current_fixation = self.gaze_movement_identifier.current_fixation
- if current_fixation.valid:
+ if current_fixation.valid:
- current_fixation.draw(image, color=(0, 255, 255))
- current_fixation.draw_positions(image)
+ current_fixation.draw(image, color=(0, 255, 255))
+ current_fixation.draw_positions(image)
- # Draw looked AOI
- self.aoi_2d_scene.draw_circlecast(image, current_fixation.focus, current_fixation.deviation_max, base_color=(0, 0, 0), matching_color=(255, 255, 255))
+ # Draw looked AOI
+ self.aoi_2d_scene.draw_circlecast(image, current_fixation.focus, current_fixation.deviation_max, base_color=(0, 0, 0), matching_color=(255, 255, 255))
- current_saccade = self.gaze_movement_identifier.current_saccade
+ current_saccade = self.gaze_movement_identifier.current_saccade
- if current_saccade.valid:
+ if current_saccade.valid:
- current_saccade.draw(image, color=(0, 255, 255))
- current_saccade.draw_positions(image)
+ current_saccade.draw(image, color=(0, 255, 255))
+ current_saccade.draw_positions(image)
+
+ except Exception as e:
+
+ # Store error to return it
+ exception = e
# Unlock frame exploitation
self.__look_lock.release()
+ # Return drawing error
+ return exception
+
@dataclass
class ArScene():
"""
@@ -1167,7 +1180,7 @@ class ArEnvironment():
json.dump(self, file, ensure_ascii=False, indent=4, cls=DataStructures.JsonEncoder)
- def draw(self, image: numpy.array):
+ def draw(self, image: numpy.array) -> Exception:
"""Draw ArUco detection visualisation and camera frame projections."""
# Draw detected markers
@@ -1181,7 +1194,10 @@ class ArEnvironment():
self.__camera_frame_lock.acquire()
# Draw camera frame
- self.camera_frame.draw(image)
+ exception = self.camera_frame.draw(image)
# Unlock camera frame exploitation
self.__camera_frame_lock.release()
+
+ # Return camera frame drawing error
+ return exception