Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong datatype for eyesCenter in facealiner #254

Open
andvikt opened this issue Jul 27, 2021 · 10 comments
Open

wrong datatype for eyesCenter in facealiner #254

andvikt opened this issue Jul 27, 2021 · 10 comments
Assignees

Comments

@andvikt
Copy link

andvikt commented Jul 27, 2021

>   	M = cv2.getRotationMatrix2D(eyesCenter, angle, scale)
E    TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type

the actual shape of eyesCenter is (np.int64, np.int64), but must be (int, int)
it can be easyly fixed by [int(x) for x in eyesCenter]

I will provide PR fixing that

andvikt added a commit to andvikt/imutils that referenced this issue Jul 27, 2021
@Wingscape
Copy link

Wow that's something why i can't fix this bug whenever i search on google. I think im gonna use haar cascade if this issue doesn't solve yet

@ariG23498
Copy link

Hey folks,

Thanks for the issue. Could you give us a reproducible bug to check? A colab notebook with the bug would do! TIA 😄

@AKSoapy29
Copy link

I can confirm that this is still an issue. I was following the face align tutorial, and kept running into this exact issue. I eventually added all of the facealigner.py code into my code and got the same error. Adding int() to the tuple fixed it:

eyesCenter = (int((leftEyeCenter[0] + rightEyeCenter[0]) // 2),
        int((leftEyeCenter[1] + rightEyeCenter[1]) // 2))

Maybe I'm using a bad version? This is what my pip reports:

Package               Version
--------------------- --------
cmake                 3.22.3
dlib                  19.23.1
imutils               0.5.4
numpy                 1.22.3
opencv-contrib-python 4.5.5.64

@vikaskookna
Copy link

Hi @ariG23498 this is still an issue as I got a ticket from a customer today about this

@ariG23498
Copy link

Tagging @abhishekthanki and @ritwikraha to this issue!

@ariskoutris
Copy link

ariskoutris commented Nov 2, 2022

I had this issue too with opencv-python 4.6.0.66 and numpy 1.19.5. Thanks @AKSoapy29 for the easy fix.

@BilalAlsharif
Copy link

det = dlib.get_frontal_face_detector()
pred = dlib.shape_predictor(r'...\shape_predictor_68_face_landmarks.dat')
alg = FaceAligner(pred, desiredFaceWidth = 256)
This tries to do face-normalisation

This makes this error 'Can't parse 'Center''

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

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

@dunland
Copy link

dunland commented Dec 25, 2022

For me, casting the eyesCenter from <class 'numpy.int64> to type <class 'int'> instead of fixed it:

in faceAligner.py:64 I did:

eyesCenter = (int((leftEyeCenter[0] + rightEyeCenter[0]) // 2),
		int((leftEyeCenter[1] + rightEyeCenter[1]) // 2))

@eze1376
Copy link

eze1376 commented May 22, 2024

For me, casting the eyesCenter from <class 'numpy.int64> to type <class 'int'> instead of fixed it:

in faceAligner.py:64 I did:

eyesCenter = (int((leftEyeCenter[0] + rightEyeCenter[0]) // 2),
		int((leftEyeCenter[1] + rightEyeCenter[1]) // 2))

This works for me! Thanks @dunland

@abhishekthanki
Copy link

abhishekthanki commented May 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests