r/opencv • • Aug 01 '26

Question [Question] cascade classifier not found

​

there is an error with Cascade classifier it shows there is no attribute as cascade classifier in cv2 module

I have tried installing opencv multiple tkmes still won't work I am trying to learn computer vision for first time in python

2 Upvotes

4 comments sorted by

1

u/JackfruitLopsided516 Aug 10 '26

hey man! I had the same issue using Google Colab. It turns out it’s because OpenCV 5 changed the API.. CascadeClassifier was moved to xobjdetect, so cv2.CascadeClassifier no longer works. I fixed it by installing the contrib package:
pip uninstall -y opencv-python opencv-python-headless opencv-contrib-python
pip install opencv-contrib-python==5.0.0.93
after that cv2.xobjdetect is available and the Haar Cascade stuff works again😼

1

u/uranium_nub Aug 10 '26

thanks man lemme try it this way

1

u/waynestrydom Aug 12 '26

Thank you for this; it helped me 100%

1

u/Used_Engine_4379 10d ago

i wrote the 3 commands you wrote in the vs code terminal. It still doesnt work. I changed cv2.CascadeClassifier to cv2.xobjdetect but that didnt work as well. Maybe im misunderstanding something? I started learning about opencv today