Raspberry Pi 4 Model B ==> AttributeError: module 'cv2' has no attribute 'CascadeClassifier'

51 Views Asked by At

I would like to try face detection but I face the following issue:

face_cascade = cv2.CascadeClassifier(haar_file) 
                   ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'cv2' has no attribute 'CascadeClassifier'

I have the following system installed:

  • python3 -V ==> 3.11.2
  • cv2.version ==> 4.9.0-dev
  • Raspberry Pi 4 Model B
  • Pi OS Bookworm (12)
  • LONG_BIT 64
  • haarcascade_frontalface_default.xml ==> in the same directory where I call my file.py

In fact I reduced the code to only two lines to limit the possible issues:

import cv2
face_cascade = cv2.CascadeClassifier(haarcascade_frontalface_default.xml)
0

There are 0 best solutions below