johnwmillr / Facer

Simple (🤞) face averaging (🙂) in Python (🐍)
MIT License
79 stars 11 forks source link

cv2 error #17

Open delray opened 2 months ago

delray commented 2 months ago

Hi, Just trying your example code and I get :

Starting face averaging for 10 faces.
Image 1 / 10
Traceback (most recent call last):
  File "D:\Facer\facer.py", line 13, in <module>
    average_face = facer.create_average_face(faces, landmarks, save_image=True)
  File "D:\Facer\facer\facer.py", line 224, in create_average_face
    dt = calculateDelaunayTriangles(rect, np.array(pointsAvg))
  File "D:\Facer\facer\utils.py", line 62, in calculateDelaunayTriangles
    subdiv.insert((p[0], p[1]))
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\subdivision2d.cpp:288: error: (-211:One of the arguments' values is out of range)  in function 'cv::Subdiv2D::locate'

Anyone with ideas about this one?

johnwmillr commented 2 months ago

Does the code work for you on some images but not others? Or do you get this error no matter what? It could be specific to the image you're running the code on.

delray commented 2 months ago

I tried looking into that and deleted a few. Should they be the same pixel dimensions? Otherwise, they all have csv landmark files created for them, and all have 67 lines in them, so it seems like it should be OK.

johnwmillr commented 2 months ago

If you don't mind uploading an example image that's producing the error, that will help with debugging.

delray commented 2 months ago

sure, I was using these two...also included the .csl files in case that is helpful. thanks so much!

3994169c8d6bbf39265d1618b1c7f60f 3994169c8d6bbf39265d1618b1c7f60f_landmarks_0.csv 20231222111228-6585b9ff46236751c52f3251jpeg 20231222111228-6585b9ff46236751c52f3251jpeg_landmarks_0.csv

delray commented 2 months ago

Any ideas on why i might be getting that error?

johnwmillr commented 1 month ago

Hi there, I'm just now getting a chance to take a look. I took screenshots of the two images you provided and ran facer on them without issue.

image

The fact that a screenshot worked for me potentially suggests that it's the format your image is saved in, rather than the specific content of the image (i.e. the arrangement of the face) that is causing problems.

It also looks like the landmarks you provided are correctly identifying the face. You could try updating to a newer version of Open CV and dlib. I'm not sure what else to suggest given that I can't reproduce your error.

image