From eb2cf131d58af6f404d7dafa0457db54fadff7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Thu, 12 Jan 2023 08:19:56 +0100 Subject: [PATCH] Revert "fix: perspective -> affine, same effect since it's an orthogonal projection" This reverts commit 5bfa5b763fd432a80520da0805987ac3b9da4534. --- 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 ++++---- src/main.py | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/bodyparts/crown.py b/src/bodyparts/crown.py index 73b75f4..4e1ba8c 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/head.py b/src/bodyparts/head.py index a919917..649fbb6 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_head_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_head_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 ea12fb8..a839ace 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 be36a69..a624c2c 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 00ece3f..1eb270b 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/bodyparts/mouth.py b/src/bodyparts/mouth.py index 0e6028e..59115fd 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 cec08d9..d5a0e68 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 128d37d..e7f0a30 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( 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 ba11976..c847952 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.getAffineTransform( - self.bouding_box[:-1, :], - self.translated_box[:-1, :], + transform_mat = cv2.getPerspectiveTransform( + self.bouding_box, + self.translated_box, ) # apply perspective transform to image - warped = cv2.warpAffine( + warped = cv2.warpPerspective( self.image, transform_mat, self.env.frame.shape[1::-1], diff --git a/src/main.py b/src/main.py index 82463d9..1d322dd 100644 --- a/src/main.py +++ b/src/main.py @@ -24,7 +24,7 @@ if __name__ == "__main__": # setup logging format logging.basicConfig( level=logging.INFO, - format="%(asctime)s %(name)s %(levelname)-8s %(message)s", + format="%(asctime)s %(name)s %(levelname)-8s %(message)s", datefmt="(%F %T)", )