Skip to content

wrong datatype for eyesCenter in facealiner #254

Open

Description

@andvikt
>   	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

Activity

  1. added a commit that references this issue on Jul 27, 2021
    6928183
  2. Wingscape commented on Dec 28, 2021

    @Wingscape

    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

  3. ariG23498 commented on Jan 27, 2022

    @ariG23498

    Hey folks,

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

  4. akapsch commented on Apr 13, 2022

    @akapsch

    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
    
  5. vikaskookna commented on Jul 14, 2022

    @vikaskookna

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

  6. ariG23498 commented on Jul 19, 2022

    @ariG23498

    Tagging @abhishekthanki and @ritwikraha to this issue!

  7. ariskoutris commented on Nov 2, 2022

    @ariskoutris

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

  8. BilalAlsharif commented on Nov 6, 2022

    @BilalAlsharif

    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

  9. dunland commented on Dec 25, 2022

    @dunland

    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))
  10. erfan-zekri commented on May 22, 2024

    @erfan-zekri

    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

  11. abhishekthanki commented on May 22, 2024

    @abhishekthanki
  12. SanjithKumar2 commented on Nov 20, 2025

    @SanjithKumar2

    Why has the issue not been corrected still it's nearly 4 years...

  13. abhishekthanki commented on Nov 20, 2025

    @abhishekthanki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions