Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers. Note that due to large amounts of spam attempts, your first three posts will be manually moderated, so please be patient.
Because of un-manageable amounts of spam despite our use of CAPTCHAs, email authorization, and other tools, we have discontinued this forum (see the 700k+ registered users with validated email addresses at right?). Please email us any questions or post bug reports and feature requests on GitHub at https://github.com/jevois -- The content below remains available for future reference.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Unable to use lbpcascade for facial detection in python

0 votes

I have been trying to use the lbpcascade approach to detecting faces using the JeVois camera. I have been following the tutorial from the link below, but I can't seem to transfer the code over to the camera without it crashing. The main error it gives me is "(-215) !empty() in function detectmultiscale", and I have been told that this means you don't have the correct file path in the calling of "detectmultiscale". However I feel that my file paths are sound.

        face_cascade = cv2.CascadeClassifier('jevois/share/facedetector/lbpcascade_frontalface.xml')
        gray = cv2.imread("jevois/share/facedetector/rooster.jpg")
        faces = face_cascade.detectMultiScale(gray, 1.2, 5);
 

These are the lines of code in question, and I have added the "lbpcascade_frontalface.xml" in correct directory, as well as the "rooster.jpg". Any help for how to accomplish facial detection in python with the JeVois camera specifically would be much appreciated. I say specifically because my problem lies in the altering of the code from online tutorials, to make it compatible with the JeVois camera. So I don't feel that links to tutorials that teach you how to do facial detection with other hardware will be of much use to me. Thank you for your time!

asked Mar 20, 2018 in Programmer Questions by hamac2003 (400 points)

1 Answer

+1 vote
 
Best answer
Can you confirm that your paths are ok, for example by first writing a python module that does the cv2.imread() as you do it and then writes a string on the output image with the dimensions of the resulting image? You would just modify the PythonSandbox module to add that imread command. It seems that maybe you should add a leading / to all your paths to make them absolute:

/jevois/share/...

Looking for your error message on google leads to this:

https://stackoverflow.com/questions/30508922/error-215-empty-in-function-detectmultiscale

which also suggests a path issue.
answered Mar 20, 2018 by JeVois (46,580 points)
selected Mar 21, 2018 by hamac2003
Thank you for your help! I changed the file paths from "jevois/share" to "/jevois/share", and that fixed my problem.
...