error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' code example

Example 1: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

This error happened because the image didn't load properly.
So you have problem with the previous line cv2.imread my suggestion is :

check if the images exist in the path you give

check the count variable if he have valid number

Example 2: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')

Example 3: error: (-215:assertion failed) !empty() in function 'cv::cascadeclassifier::detectmultiscale'

cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_fullbody.xml')
cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')

Tags:

Misc Example