aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-09-21 17:02:12 +0200
committerThéo de la Hogue2022-09-21 17:02:12 +0200
commit24c433c6582dffcf8e3065985faa9bfa7620f2ce (patch)
treef8b67b089226753456d5d65b72e5d57f0bd69645 /src
parentbbba702d02a21b74f9756561befaaeeafbe19515 (diff)
downloadargaze-24c433c6582dffcf8e3065985faa9bfa7620f2ce.zip
argaze-24c433c6582dffcf8e3065985faa9bfa7620f2ce.tar.gz
argaze-24c433c6582dffcf8e3065985faa9bfa7620f2ce.tar.bz2
argaze-24c433c6582dffcf8e3065985faa9bfa7620f2ce.tar.xz
Using gaze position as GazePosition. Raising exception when trying to draw AOI of non 2 dimension.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/AreaOfInterest/AOIFeatures.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py
index c5cbaef..7dd0964 100644
--- a/src/argaze/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze/AreaOfInterest/AOIFeatures.py
@@ -50,7 +50,7 @@ class AreaOfInterest(numpy.ndarray):
return mpath.Path(self).contains_points([tuple(gaze_position)])[0]
- def look_at(self, gaze_pixel):
+ def look_at(self, pixel_position):
"""Get where the area is looked using perpespective transformation."""
if self.dimension() != 2:
@@ -63,7 +63,7 @@ class AreaOfInterest(numpy.ndarray):
Dst = numpy.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]]).astype(numpy.float32)
P = cv.getPerspectiveTransform(Src, Dst)
- X = numpy.append(numpy.array(gaze_pixel - Src_origin), [1.0]).astype(numpy.float32)
+ X = numpy.append(numpy.array(pixel_position - Src_origin), [1.0]).astype(numpy.float32)
Y = numpy.dot(P, X)
La = (Y/Y[2])[:-1]
@@ -90,14 +90,14 @@ class AreaOfInterest(numpy.ndarray):
return numpy.rint(Lp).astype(int).tolist()
- def looked_region(self, gaze_position, gaze_radius):
- """Get intersection shape with gaze circle as the looked area, (looked area / AOI area) and (looked area / gaze circle area)."""
+ def looked_region(self, gaze_position):
+ """Get intersection shape with gaze accuracy circle as the looked area, (looked area / AOI area) and (looked area / gaze accuracy circle area)."""
if self.dimension() != 2:
raise RuntimeError(f'Bad area dimension ({self.dimension()})')
self_polygon = Polygon(self)
- gaze_circle = Point(gaze_position).buffer(gaze_radius)
+ gaze_circle = Point(gaze_position).buffer(gaze_position.accuracy)
if self_polygon.intersects(gaze_circle):
@@ -115,6 +115,9 @@ class AreaOfInterest(numpy.ndarray):
def draw(self, frame, color, border_size=1):
+ if self.dimension() != 2:
+ raise RuntimeError(f'Bad area dimension ({self.dimension()})')
+
if len(self) > 1:
# Draw form
@@ -150,6 +153,7 @@ class AOIScene():
del self.areas[key]
def items(self):
+ """Iterate over areas."""
for name, area in self.areas.items():
yield name, numpy.array(area).astype(numpy.float32).view(AreaOfInterest)