faces = face_cascade.detectMultiScale(gray, 1, 3, 5) cv2.error: OpenCV(3.4.1) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1698: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

asked 2018-06-13 05:38:03 -0500

jhs gravatar image

updated 2018-06-13 05:46:54 -0500

berak gravatar image


import numpy as np
import cv2


face_cascade = cv2.CascadeClassifier('haarcascade_frontface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')


cap = cv2.VideoCapture(0)

while True:
   ret, img = cap.read()
   gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
   faces = face_cascade.detectMultiScale(gray, 1, 3, 5)
   for (x, y, w, h) in faces:
           cv2.rectangle(img, (x,y), (x+w, y+h), (255,0,0), 2)
           roi_gray = gray[y:y+h, x:x+w]
           roi_color = Manycam[y:y+h, x:x+w]
           eyes = eye_cascade.detectMultiScale(roi_gray)
           for (ex,ey,ew,eh) in eyes:
                   cv2.rectangle(roi_color, (ex, ey), (ex+ew, ey+eh), (0,255,0), 2)

   cv2.imshow('img',img)
   k = cv2.waitKey(30) & oxff
   if k == 27:
           break

cap.release()
cv2.destroyAllWindows()

faces = face_cascade.detectMultiScale(gray, 1, 3, 5)

cv2.error: OpenCV(3.4.1) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1698:

error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

what is happen? I want solve this problem Did you solve this problem ? please

edit retag flag offensive close merge delete

Comments

it's always the same, python users don't seem to get, that loading resources can go wrong.

berak gravatar imageberak ( 2018-06-13 05:48:25 -0500 )edit

what do you mean?

jhs gravatar imagejhs ( 2018-06-13 09:35:11 -0500 )edit