From 07fb4ce51650e9b0edaf1b9ebc01c1b9589c9a54 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 17 Oct 2023 18:40:18 +0200 Subject: Implementing LinearRegression drawing function. --- src/argaze/GazeAnalysis/LinearRegression.py | 24 ++++++++++++++++++------ 1 file 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: -- cgit v1.1