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

AttributeError: 'cv2.CascadeClassifier' object has no attribute 'detectMultiScaleWithScores' #2

Open
umitanuki opened this issue Jan 5, 2015 · 6 comments

Comments

@umitanuki
Copy link

After installing, I ran test_pipeline.py and failed.

... processing ./resources/pipeline/Fayssal_Mekdad_0002.jpg
E
======================================================================
ERROR: testPipeline (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_pipeline.py", line 30, in testPipeline
    cascade_face_aligner.detect_faces(input_folder, faces_folder)
  File "/usr/local/lib/python2.7/dist-packages/adiencealign/pipeline/CascadeFaceAligner.py", line 55, in detect_faces
    faces_file = self.face_finder.create_faces_file( input_file, is_overwrite = False, target_file = target_faces_file )
  File "/usr/local/lib/python2.7/dist-packages/adiencealign/cascade_detection/cascade_face_finder.py", line 104, in create_faces_file
    faces = self.get_faces_list_in_photo(cv2.imread(fname))
  File "/usr/local/lib/python2.7/dist-packages/adiencealign/cascade_detection/cascade_face_finder.py", line 89, in get_faces_list_in_photo
    haar_faces = self.haar_dtct.detectWithAngles(img, resolve = True)
  File "/usr/local/lib/python2.7/dist-packages/adiencealign/cascade_detection/cascade_detector.py", line 97, in detectWithAngles
    faces = self.detectMultiScaleWithScores(rot_image, scaleFactor = 1.03, minNeighbors = 20, minSize = (15,15), flags = 4)
  File "/usr/local/lib/python2.7/dist-packages/adiencealign/cascade_detection/cascade_detector.py", line 60, in detectMultiScaleWithScores
    return self._cascade_classifier.detectMultiScaleWithScores(img,
AttributeError: 'cv2.CascadeClassifier' object has no attribute 'detectMultiScaleWithScores'

----------------------------------------------------------------------
Ran 1 test in 0.051s

I don't think it has such method ever, but it looks like detectMultiScale (without WithScores)? I changed it accordingly in my local and seems to be working.

@ahaque
Copy link

ahaque commented Feb 22, 2015

In cascade_detector.py, in the detectWithAngles function, go to around line 100. You will see the function call to self.detectMultiScaleWithScores. Immediately below that, find:

for face in faces:
    xp = face[0][0]
    dx = face[0][2]
    yp = face[0][1]
    dy = face[0][3]
    score = face[1]

and replace it with:

for face in faces:
    xp = face[0]
    dx = face[2]
    yp = face[1]
    dy = face[3]
    score = 1

This fixes the problem because the self._cascade_classifier.detectMultiScale call on line 60 does not return scores. After making this change, test_pipeline.py seems to be working and generates outputs (that look correct?).

@mayankgrd
Copy link

Hi there,
I faced similar error, and solved things as mentioned. But, it does not seem that the faces are aligned anymore. Specifically, see the Fayssal_Mekdad_0002_face_0.aligned imaged under the aligned folder.

Any update on this? Though, I doubt that this might be causing problem.

Any help will be highly appreciated.

@kli-casia
Copy link

I have the same problem

@kli-casia
Copy link

@umitanuki @mayankgrd
Have you solved this problem?

@sirnicolaz
Copy link
Contributor

sirnicolaz commented Nov 25, 2016

I have found the solution: the code is using an outdated version of the method. Just go to line 60 of cascade_detector.py and turn detectMultiScaleWithScores into detectMultiScale

@Lokesh3152
Copy link

i cant find cascade detector. i installed through conda can u help me out

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

6 participants