-2

Here's my code:

import cv2 as c

face_cascade = c.CascadeClassifier(r"haracascade_frontalface.xml")
img  = c.imread(r"D:\cODE\Python_Only\CV2\Files\photo.jpg" )
grey_image = c.cvtColor(img , c.COLOR_BGR2GRAY)

faces = face_cascade.detectMultiScale(
    grey_image ,
    scaleFactor = 1.05,
    minNeighbors = 5
)

print(faces)

Error:

Traceback (most recent call last):
File "d:\\cODE\\Face_Detector.py", line 8, in \<module\>
faces = face_cascade.detectMultiScale(
cv2.error: OpenCV(4.5.5) D:\\a\\opencv-python\\opencv-python\\opencv\\modules\\objdetect\\src\\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

I don't know what to do know next, I'm still a beginner right now!

beaker
  • 16,331
  • 3
  • 32
  • 49
  • Please try absolute path for c.CascadeClassifier(r"haracascade_frontalface.xml") – Micka Mar 27 '22 at 16:06
  • 1
    Does this answer your question? [Face detection using Cascade Classifier in opencv python](https://stackoverflow.com/questions/30857908/face-detection-using-cascade-classifier-in-opencv-python) – Christoph Rackwitz Mar 27 '22 at 17:43
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Henrique Branco Mar 27 '22 at 20:14
  • @ChristophRackwitz , Thanks to you for trying to help me out , I'm very Thankful to you – Yatharth Saini 9A Mar 28 '22 at 16:07
  • @HenriqueBranco , hey bro, thanks for the time you gave to understand my problem, i'll never forget your gratefulness! – Yatharth Saini 9A Mar 28 '22 at 16:09

1 Answers1

1

just do this=

Please try absolute path for c.CascadeClassifier(r"haracascade_frontalface.xml") 

thanks, @Micka