From 97ba97638d72931730eb84f743d2541ca113a55e Mon Sep 17 00:00:00 2001 From: Y <35826375+BeGentleman@users.noreply.github.com> Date: Sat, 2 Apr 2022 17:09:26 +0800 Subject: [PATCH] =?UTF-8?q?Fix=E3=80=90wrong=20type=E3=80=91about=20eyesCe?= =?UTF-8?q?nter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error Info:【TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type】 Cause by: eyesCenter's element's type is numpy.int64, which is need an int type Solved by: change numpy.int64 into int type sources: eyesCenter = ((leftEyeCenter[0] + rightEyeCenter[0]) // 2, (leftEyeCenter[1] + rightEyeCenter[1]) // 2) -> eyesCenter = (int((leftEyeCenter[0] + rightEyeCenter[0]) // 2), int((leftEyeCenter[1] + rightEyeCenter[1]) // 2)) --- imutils/face_utils/facealigner.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imutils/face_utils/facealigner.py b/imutils/face_utils/facealigner.py index 6c3fe83..e2867ba 100644 --- a/imutils/face_utils/facealigner.py +++ b/imutils/face_utils/facealigner.py @@ -61,8 +61,7 @@ def align(self, image, gray, rect): # compute center (x, y)-coordinates (i.e., the median point) # between the two eyes in the input image - eyesCenter = ((leftEyeCenter[0] + rightEyeCenter[0]) // 2, - (leftEyeCenter[1] + rightEyeCenter[1]) // 2) + eyesCenter = (int((leftEyeCenter[0] + rightEyeCenter[0]) // 2), int((leftEyeCenter[1] + rightEyeCenter[1]) // 2)) # grab the rotation matrix for rotating and scaling the face M = cv2.getRotationMatrix2D(eyesCenter, angle, scale)