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

haarcascades error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' #13

Open
ZaccD0099 opened this issue Mar 27, 2021 · 0 comments

Comments

@ZaccD0099
Copy link

Continue getting this error for drone face tracking course, I think it is due to the file. Any ideas?

My Code:

import cv2
import numpy as np

def findFace(img):
faceCascade = cv2.CascadeClassifier('Resources/haarcascade_frontalface_default.xml')
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(imgGray,1.1,8)

myFaceListC = []
myFaceListArea = []

for (x,y,w,h) in faces:
    cv2.rectangle(img,(x,y),(x + w, y + h),(0,0,255),2)

cap = cv2.VideoCapture(0)

while True:
_, img = cap.read()
findFace(img)
cv2.imshow("Output",img)
cv2.waitKey(1)

Error:

File "C:/Users/zachd/PycharmProjects/droneproject2/venv/Face Tracking.py", line 20, in
findFace(img)
File "C:/Users/zachd/PycharmProjects/droneproject2/venv/Face Tracking.py", line 7, in findFace
faces = faceCascade.detectMultiScale(imgGray,1.1,8)
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

[ WARN:1] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\videoio\src\cap_msmf.cpp (434) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback

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

1 participant