aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)