0

This tries to do face-normalisation

This makes this error Can't parse 'Center'

import cv2
import dlib
from imutils.face_utils import FaceAligner
import matplotlib.pyplot as plt

det = dlib.get_frontal_face_detector()
pred = dlib.shape_predictor(r'...\shape_predictor_68_face_landmarks.dat')

alg = FaceAligner(pred, desiredFaceWidth = 256)

frame = cv2.imread('img.jpg')
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
rect = detector(gray,1)[0]
faceAligned = aligner.align(frame, gray, rect)

The error comes from the aligner

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\imgphon\landmark.py:94, in get_norm_face(frame, detector, predictor, aligner)
     89 rect = detector(gray,1)[0]
     91 # align face
     92 # TODO fork imutils, change this function to rotate and return the landmarks used for alignment; 
     93 # replace current marks_np
---> 94 faceAligned = aligner.align(frame, gray, rect)
     96 return faceAligned

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\imutils\face_utils\facealigner.py:68, in FaceAligner.align(self, image, gray, rect)
     64 eyesCenter = ((leftEyeCenter[0] + rightEyeCenter[0]) // 2,
     65     (leftEyeCenter[1] + rightEyeCenter[1]) // 2)
     67 # grab the rotation matrix for rotating and scaling the face
---> 68 M = cv2.getRotationMatrix2D(eyesCenter, angle, scale)
     70 # update the translation component of the matrix
     71 tX = self.desiredFaceWidth * 0.5

TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • Please copy-paste the full error message into the post, including the stack trace. See [mre]. – Cris Luengo Nov 06 '22 at 14:14
  • @CrisLuengojust this is error: TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type – user20003920 Nov 06 '22 at 14:20
  • **[mre] is required.** -- this is a bug in `imutils`. please contact Adrian Rosebrock to file a bug report. -- what's the value of `type(eyesCenter)`, what's the value of `type(eyesCenter[0])`? it should be a tuple of floats. – Christoph Rackwitz Nov 06 '22 at 20:26
  • @ChristophRackwitzmy python skills is basic. Do you mean to convert the image,for example, into uint8? Is there a hacky way to sort this problem out? I badly need it. – user20003920 Nov 06 '22 at 21:12
  • https://github.com/PyImageSearch/imutils/issues – Christoph Rackwitz Nov 07 '22 at 10:42

0 Answers0