alyssaq / face_morpher

:angel: Morph faces with Python, Numpy, Scipy
886 stars 233 forks source link

"Invalid HAAR feature" and no face in image error #59

Open jstray opened 5 years ago

jstray commented 5 years ago

Attempting to run facemorpher in a docker container as described in the readme,

root@6411e86f84bd:/# facemorpher --src=/images/alyssa.jpg --dest=/images/ian.jpg --plot
Failed finding face points:  cascadedetect.cpp(569) : Unspecified error : > Invalid HAAR feature (expected: 'rw.r.x + rw.r.width <= W'), where
>     'rw.r.x + rw.r.width' is 15
> must be less than or equal to
>     'W' is 12

No face in /images/alyssa.jpg
Failed finding face points:  cascadedetect.cpp(569) : Unspecified error : > Invalid HAAR feature (expected: 'rw.r.x + rw.r.width <= W'), where
>     'rw.r.x + rw.r.width' is 15
> must be less than or equal to
>     'W' is 12

No face in /images/ian.jpg
Traceback (most recent call last):
  File "/usr/local/bin/facemorpher", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/facemorpher/morpher.py", line 149, in main
    args['--plot'], args['--background'])
  File "/usr/local/lib/python3.7/site-packages/facemorpher/morpher.py", line 134, in morpher
    src_img, src_points = next(images_points_gen)
StopIteration

The inputs are jpg files that open fine, and I've even grabbed alyssa.jpg from the README to ensure that my particular face images are not the problem.

akamatsu commented 5 years ago

I got the same error and found the solution:

change from facemorpher import locator to import locator

at line34 of morphed.py

aanno commented 4 years ago

I had this as well and tried what @akamatsu said - but his suggestion is not working for me. From the example and this stackoverflow I would conclude that there should not be any hair - only plain faces to make it work. I'm not into opencv to have any clue if this could be improved...

aanno commented 4 years ago

I tried this once more and what @akamatsu is working if you checkout the git repo, i.e. if you don't use facemorpher installed from pip. No idea why this is the case, though...