aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-10-17 18:40:18 +0200
committerThéo de la Hogue2023-10-17 18:40:18 +0200
commit07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54 (patch)
treeb5f9c512c2da32d453c1fa22dcdca1e2b558c309 /src
parent45af88fcb056ca0d5fd1be49972cef9b0f275fad (diff)
downloadargaze-07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54.zip
argaze-07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54.tar.gz
argaze-07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54.tar.bz2
argaze-07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54.tar.xz
Implementing LinearRegression drawing function.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/GazeAnalysis/LinearRegression.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/argaze/GazeAnalysis/LinearRegression.py b/src/argaze/GazeAnalysis/LinearRegression.py
index de7725d..0e10b87 100644
--- a/src/argaze/GazeAnalysis/LinearRegression.py
+++ b/src/argaze/GazeAnalysis/LinearRegression.py
@@ -79,14 +79,26 @@ class GazePositionCalibrator(GazeFeatures.GazePositionCalibrator):
return gaze_position
- def draw(self, image: numpy.array):
- """Draw calibration into image.
+ def draw(self, image: numpy.array, size: tuple, resolution: tuple, line_color: tuple = (0, 0, 0), thickness: int = 1):
+ """Draw calibration field."""
+
+ width, height = size
- Parameters:
- image: where to draw
- """
+ if width * height > 0:
+
+ rx, ry = resolution
+ lx = numpy.linspace(0, width, rx)
+ ly = numpy.linspace(0, height, ry)
+ xv, yv = numpy.meshgrid(lx, ly, indexing='ij')
+
+ for i in range(rx):
+
+ for j in range(ry):
+
+ start = (xv[i][j], yv[i][j])
+ end = self.apply(GazeFeatures.GazePosition(start)).value
- raise NotImplementedError('draw() method not implemented')
+ cv2.line(image, (int(start[0]), int(start[1])), (int(end[0]), int(end[1])), line_color, thickness)
@property
def calibrating(self) -> bool: