From 5bfa5b763fd432a80520da0805987ac3b9da4534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Thu, 29 Dec 2022 20:25:12 +0100 Subject: [PATCH] fix: perspective -> affine, same effect since it's an orthogonal projection --- src/bodyparts/crown.py | 8 ++++---- src/bodyparts/head.py | 8 ++++---- src/bodyparts/left_ear.py | 8 ++++---- src/bodyparts/left_eye.py | 8 ++++---- src/bodyparts/left_moustache.py | 8 ++++---- src/bodyparts/mouth.py | 8 ++++---- src/bodyparts/right_ear.py | 8 ++++---- src/bodyparts/right_eye.py | 8 ++++---- src/bodyparts/right_moustache.py | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/bodyparts/crown.py b/src/bodyparts/crown.py index 4e1ba8c..73b75f4 100644 --- a/src/bodyparts/crown.py +++ b/src/bodyparts/crown.py @@ -46,13 +46,13 @@ class Crown: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/head.py b/src/bodyparts/head.py index 649fbb6..a919917 100644 --- a/src/bodyparts/head.py +++ b/src/bodyparts/head.py @@ -46,13 +46,13 @@ class Head: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_head_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_head_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/left_ear.py b/src/bodyparts/left_ear.py index a839ace..ea12fb8 100644 --- a/src/bodyparts/left_ear.py +++ b/src/bodyparts/left_ear.py @@ -46,13 +46,13 @@ class LeftEar: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/left_eye.py b/src/bodyparts/left_eye.py index a624c2c..be36a69 100644 --- a/src/bodyparts/left_eye.py +++ b/src/bodyparts/left_eye.py @@ -46,13 +46,13 @@ class LeftEye: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/left_moustache.py b/src/bodyparts/left_moustache.py index 1eb270b..00ece3f 100644 --- a/src/bodyparts/left_moustache.py +++ b/src/bodyparts/left_moustache.py @@ -46,13 +46,13 @@ class LeftMoustache: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/mouth.py b/src/bodyparts/mouth.py index 59115fd..0e6028e 100644 --- a/src/bodyparts/mouth.py +++ b/src/bodyparts/mouth.py @@ -46,13 +46,13 @@ class Mouth: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/right_ear.py b/src/bodyparts/right_ear.py index d5a0e68..cec08d9 100644 --- a/src/bodyparts/right_ear.py +++ b/src/bodyparts/right_ear.py @@ -46,13 +46,13 @@ class RightEar: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/right_eye.py b/src/bodyparts/right_eye.py index e7f0a30..128d37d 100644 --- a/src/bodyparts/right_eye.py +++ b/src/bodyparts/right_eye.py @@ -46,13 +46,13 @@ class RightEye: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/right_moustache.py b/src/bodyparts/right_moustache.py index c847952..ba11976 100644 --- a/src/bodyparts/right_moustache.py +++ b/src/bodyparts/right_moustache.py @@ -46,13 +46,13 @@ class RightMoustache: ).astype(np.float32) # get perspective transform - transform_mat = cv2.getPerspectiveTransform( - self.bouding_box, - self.translated_box, + transform_mat = cv2.getAffineTransform( + self.bouding_box[:-1, :], + self.translated_box[:-1, :], ) # apply perspective transform to image - warped = cv2.warpPerspective( + warped = cv2.warpAffine( self.image, transform_mat, self.env.frame.shape[1::-1],