diff options
Diffstat (limited to 'src/argaze/AreaOfInterest/AOIFeatures.py')
-rw-r--r-- | src/argaze/AreaOfInterest/AOIFeatures.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py index 4495df5..8b93935 100644 --- a/src/argaze/AreaOfInterest/AOIFeatures.py +++ b/src/argaze/AreaOfInterest/AOIFeatures.py @@ -53,10 +53,12 @@ class AreaOfInterest(numpy.ndarray): Dst = numpy.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]]).astype(numpy.float32) P = cv.getPerspectiveTransform(Src, Dst) - G = gaze_pixel - Src_origin - Gp = numpy.dot(P, numpy.array([G[0], G[1], 1]))[:-1] + X = numpy.append(numpy.array(gaze_pixel - Src_origin), [1.0]).astype(numpy.float32) + Y = numpy.dot(P, X) - return numpy.around(Gp, 4).tolist() + La = (Y/Y[2])[:-1] + + return numpy.around(La, 4).tolist() def looked_pixel(self, look_at): """Get which pixel is looked.""" @@ -71,8 +73,10 @@ class AreaOfInterest(numpy.ndarray): Dst = (Dst - Dst_origin).reshape((len(Dst)), 2) P = cv.getPerspectiveTransform(Src, Dst) - L = look_at - Lp = Dst_origin + numpy.dot(P, numpy.array([L[0], L[1], 1]))[:-1] + X = numpy.array([look_at[0], look_at[1], 1.0]).astype(numpy.float32) + Y = numpy.dot(P, X) + + Lp = Dst_origin + (Y/Y[2])[:-1] return numpy.rint(Lp).astype(int).tolist() |