aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/GazeAnalysis
diff options
context:
space:
mode:
authorThéo de la Hogue2023-08-30 20:32:48 +0200
committerThéo de la Hogue2023-08-30 20:32:48 +0200
commite6d7257954ea343329460a4d8e3863eacc47d222 (patch)
tree7b8195e79834aad033a25e93cdb2f2d51265750e /src/argaze/GazeAnalysis
parente030928f9a182cfcdf78b93adfec422fcdb80f78 (diff)
downloadargaze-e6d7257954ea343329460a4d8e3863eacc47d222.zip
argaze-e6d7257954ea343329460a4d8e3863eacc47d222.tar.gz
argaze-e6d7257954ea343329460a4d8e3863eacc47d222.tar.bz2
argaze-e6d7257954ea343329460a4d8e3863eacc47d222.tar.xz
Fixing empty parameters cases.
Diffstat (limited to 'src/argaze/GazeAnalysis')
-rw-r--r--src/argaze/GazeAnalysis/DeviationCircleCoverage.py14
-rw-r--r--src/argaze/GazeAnalysis/DispersionThresholdIdentification.py4
-rw-r--r--src/argaze/GazeAnalysis/FocusPointInside.py12
-rw-r--r--src/argaze/GazeAnalysis/VelocityThresholdIdentification.py13
4 files changed, 25 insertions, 18 deletions
diff --git a/src/argaze/GazeAnalysis/DeviationCircleCoverage.py b/src/argaze/GazeAnalysis/DeviationCircleCoverage.py
index 98706f7..e1b33f1 100644
--- a/src/argaze/GazeAnalysis/DeviationCircleCoverage.py
+++ b/src/argaze/GazeAnalysis/DeviationCircleCoverage.py
@@ -108,35 +108,35 @@ class AOIMatcher(GazeFeatures.AOIMatcher):
looked_aoi_name_offset: ofset of text from the upper left aoi bounding box corner
"""
- if self.__matched_gaze_movement:
+ if self.__matched_gaze_movement is not None:
if GazeFeatures.is_fixation(self.__matched_gaze_movement):
# Draw matched fixation if required
- if draw_matched_fixation:
+ if draw_matched_fixation is not None:
self.__matched_gaze_movement.draw(image, **draw_matched_fixation)
# Draw matched fixation positions if required
- if draw_matched_fixation_positions:
+ if draw_matched_fixation_positions is not None:
self.__matched_gaze_movement.draw_positions(image, **draw_matched_fixation_positions)
# Draw matched aoi
- if self.looked_aoi.all() != None:
+ if self.looked_aoi.all() is not None:
# Draw looked aoi if required
- if draw_looked_aoi:
+ if draw_looked_aoi is not None:
self.looked_aoi.draw(image, **draw_looked_aoi)
# Draw matched region if required
- if draw_matched_region:
+ if draw_matched_region is not None:
self.__matched_region.draw(image, **draw_matched_region)
# Draw looked aoi name if required
- if looked_aoi_name_color:
+ if looked_aoi_name_color is not None:
top_left_corner_pixel = numpy.rint(self.looked_aoi.bounding_box[0]).astype(int) + looked_aoi_name_offset
cv2.putText(image, self.looked_aoi_name, top_left_corner_pixel, cv2.FONT_HERSHEY_SIMPLEX, 1, looked_aoi_name_color, 1, cv2.LINE_AA)
diff --git a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
index bf7b862..85f2fb5 100644
--- a/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
+++ b/src/argaze/GazeAnalysis/DispersionThresholdIdentification.py
@@ -83,12 +83,12 @@ class Fixation(GazeFeatures.Fixation):
"""
# Draw deviation circle if required
- if deviation_circle_color:
+ if deviation_circle_color is not None:
cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), deviation_circle_color, -1)
# Draw duration border if required
- if duration_border_color:
+ if duration_border_color is not None:
cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), duration_border_color, int(self.duration * duration_factor))
diff --git a/src/argaze/GazeAnalysis/FocusPointInside.py b/src/argaze/GazeAnalysis/FocusPointInside.py
index 2ac4411..c071f82 100644
--- a/src/argaze/GazeAnalysis/FocusPointInside.py
+++ b/src/argaze/GazeAnalysis/FocusPointInside.py
@@ -63,30 +63,30 @@ class AOIMatcher(GazeFeatures.AOIMatcher):
looked_aoi_name_offset: ofset of text from the upper left aoi bounding box corner
"""
- if self.__matched_gaze_movement:
+ if self.__matched_gaze_movement is not None:
if GazeFeatures.is_fixation(self.__matched_gaze_movement):
# Draw matched fixation if required
- if draw_matched_fixation:
+ if draw_matched_fixation is not None:
self.__matched_gaze_movement.draw(image, **draw_matched_fixation)
# Draw matched fixation positions if required
- if draw_matched_fixation_positions:
+ if draw_matched_fixation_positions is not None:
self.__matched_gaze_movement.draw_positions(image, **draw_matched_fixation_positions)
# Draw matched aoi
- if self.looked_aoi.all() != None:
+ if self.looked_aoi.all() is not None:
# Draw looked aoi if required
- if draw_looked_aoi:
+ if draw_looked_aoi is not None:
self.looked_aoi.draw(image, **draw_looked_aoi)
# Draw looked aoi name if required
- if looked_aoi_name_color:
+ if looked_aoi_name_color is not None:
top_left_corner_pixel = numpy.rint(self.looked_aoi.bounding_box[0]).astype(int) + looked_aoi_name_offset
cv2.putText(image, self.looked_aoi_name, top_left_corner_pixel, cv2.FONT_HERSHEY_SIMPLEX, 1, looked_aoi_name_color, 1, cv2.LINE_AA)
diff --git a/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py b/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py
index 1160a0d..ab90fe7 100644
--- a/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py
+++ b/src/argaze/GazeAnalysis/VelocityThresholdIdentification.py
@@ -72,7 +72,7 @@ class Fixation(GazeFeatures.Fixation):
return self
- def draw(self, image: numpy.array, deviation_circle_color=(255, 255, 255), duration_border_color=(255, 255, 255), duration_factor: float = 1.):
+ def draw(self, image: numpy.array, deviation_circle_color: tuple = None, duration_border_color: tuple = None, duration_factor: float = 1.):
"""Draw fixation into image.
Parameters:
@@ -81,8 +81,15 @@ class Fixation(GazeFeatures.Fixation):
duration_factor: how many pixels per duration unit
"""
- cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), deviation_circle_color, -1)
- cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), duration_border_color, int(self.duration * duration_factor))
+ # Draw deviation circle if required
+ if deviation_circle_color is not None:
+
+ cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), deviation_circle_color, -1)
+
+ # Draw duration border if required
+ if duration_border_color is not None:
+
+ cv2.circle(image, (int(self.focus[0]), int(self.focus[1])), int(self.deviation_max), duration_border_color, int(self.duration * duration_factor))
@dataclass(frozen=True)
class Saccade(GazeFeatures.Saccade):