Ask Your Question
0

python sample script error : AttributeError: module 'cv2' has no attribute 'CascadeClassifire' (OpenCV 3.1, python 3)

asked 2016-12-17 05:00:23 -0600

Rahul9762 gravatar image

updated 2016-12-17 05:14:11 -0600

berak gravatar image

i am working on face recognition system here is my code

detector = cv2.CascadeClassifire("C:/Users/Rahul/Desktop/OpenC/OpenCv3.1/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml")

scale_factor = 1.2
min_neighbors = 5
min_size =(30,30)
biggest_only = True
flags = cv2.CASCADE_FIND_BIGGEST_OBJECT|cv2.CASCADE_DO_ROUGH_SEARCH if  biggest_only else cv2.CASCADE_SCALE_IMAGE
faces_coord = detector.detectMultiScale(frame,scaleFactor=scale_factor,minNeighbors=min_neighbors,minSize=min_size,flags=flags)
print ("Type: " + str(type(faces_coord)))
print (faces_coord)
print ("Length: " + str(len(faces_coord)))
for (x, y, w, h) in faces_coord : cv2.rectangle(frame,(x,y),(x+w ,y+h),(150,150,0),8)
plt.show(frame)

output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-13e571300b67> in <module>()
----> 1 detector = cv2.CascadeClassifire("C:/Users/Rahul/Desktop/OpenC/OpenCv3.1/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml")
      2 
      3 scale_factor = 1.2
      4 min_neighbors = 5
      5 min_size =(30,30)

AttributeError: module 'cv2' has no attribute 'CascadeClassifire'
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-17 05:09:41 -0600

berak gravatar image

simple typo ;)

cv2.CascadeClassifier()
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-17 05:00:23 -0600

Seen: 4,701 times

Last updated: Dec 17 '16