Unable To Detect Face And Eye With OpenCV In Python
This code is to detect face and eyes using webcam but getting this error Traceback (most recent call last): File 'D:/Acads/7.1 Sem/BTP/FaceDetect-master/6.py', line 28, in <
Solution 1:
I think it is just a problem of indentation.
roi
is out of scope when you go out of the faces
loop.
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
roi = frame[y:y+h, x:x+w]
# eyes detection runs for each face
eyes = eyeCascade.detectMultiScale(roi)
for (ex,ey,ew,eh) in eyes:
cv2.rectangle(roi,(ex,ey),(ex+ew,ey+eh), 255, 2)
Post a Comment for "Unable To Detect Face And Eye With OpenCV In Python"