aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-09-06 15:38:16 +0200
committerThéo de la Hogue2022-09-06 15:38:16 +0200
commit095fbd030ccfbca82d4d7bd638b1502b5bb167d2 (patch)
tree3c5ab2631727dc2b917e1fdc084c04666b0fb9ec
parent33a50cd79d80d5448e63be06a7a850692831891d (diff)
downloadargaze-095fbd030ccfbca82d4d7bd638b1502b5bb167d2.zip
argaze-095fbd030ccfbca82d4d7bd638b1502b5bb167d2.tar.gz
argaze-095fbd030ccfbca82d4d7bd638b1502b5bb167d2.tar.bz2
argaze-095fbd030ccfbca82d4d7bd638b1502b5bb167d2.tar.xz
Drawing looked region.
-rw-r--r--src/argaze/AreaOfInterest/AOI2DScene.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/argaze/AreaOfInterest/AOI2DScene.py b/src/argaze/AreaOfInterest/AOI2DScene.py
index 4b8e603..2d0ff17 100644
--- a/src/argaze/AreaOfInterest/AOI2DScene.py
+++ b/src/argaze/AreaOfInterest/AOI2DScene.py
@@ -17,7 +17,7 @@ class AOI2DScene(AOIFeatures.AOIScene):
# set dimension member
self.dimension = 2
- def look_at(self, gaze_position: GazeFeatures.GazePosition):
+ def look_at(self, gaze_position: GazeFeatures.GazePosition, gaze_precision: GazeFeatures.GazePrecision):
"""Get looked and ignored AOI names."""
looked = {}
@@ -25,6 +25,9 @@ class AOI2DScene(AOIFeatures.AOIScene):
for name, aoi in self.items():
+ # TODO : use looked_region
+ # looked_region, aoi_ratio, gaze_ratio = aoi2D.looked_region(gaze_position, gaze_precision)
+
if aoi.looked():
looked[name] = aoi.look_at(gaze_position)
@@ -35,7 +38,7 @@ class AOI2DScene(AOIFeatures.AOIScene):
return looked, ignored
- def draw(self, frame, gaze_position: GazeFeatures.GazePosition, exclude=[], base_color=(0, 0, 255), looked_color=(0, 255, 0)):
+ def draw(self, frame, gaze_position: GazeFeatures.GazePosition, gaze_precision: GazeFeatures.GazePrecision, exclude=[], base_color=(0, 0, 255), looked_color=(0, 255, 0)):
"""Draw AOI polygons on frame."""
for name, aoi2D in self.items():
@@ -43,14 +46,24 @@ class AOI2DScene(AOIFeatures.AOIScene):
if name in exclude:
continue
- looked = aoi2D.looked(gaze_position)
+ looked_region, aoi_ratio, gaze_ratio = aoi2D.looked_region(gaze_position, gaze_precision)
+
+ # Draw looked region
+ looked_region.draw(frame, base_color, 4)
+
+ # TODO : Externalise this criteria
+ looked = aoi_ratio > 0.25 or gaze_ratio > 0.5
color = looked_color if looked else base_color
if looked:
+
top_left_corner_pixel = numpy.rint(aoi2D.clockwise()[0]).astype(int)
cv.putText(frame, name, top_left_corner_pixel, cv.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv.LINE_AA)
+ # Draw looked region
+ looked_region.draw(frame, looked_color, 4)
+
# 4 corners aoi only
if len(aoi2D) == 4:
looked_pixel = aoi2D.looked_pixel(aoi2D.look_at(gaze_position))