Ask Your Question

Why does faceCascade.detectMultiScale abort on call?

asked 2017-06-10 20:05:33 -0500

Bazmundi gravatar image

updated 2017-06-10 20:07:23 -0500

The code is:

import cv2
import sys

cascPath = sys.argv[1]
faceCascade = cv2.CascadeClassifier(cascPath)

video_capture = cv2.VideoCapture(1)

while True:
    # Capture frame-by-frame
    ret, frame =

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = faceCascade.detectMultiScale(
        minSize=(30, 30),

    # Draw a rectangle around the faces
    for (x, y, w, h) in faces:
        cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)

    # Display the resulting frame
    cv2.imshow('Video', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):

# When everything is done, release the capture

Code was from

The original code did not work because of deprication of which is replaced with cv2.CASCADE_SCALE_IMAGE from guidance at

However, cv::CascadeClassifier::detectMultiScale causes exception with assertion (!empty()) at cascadedetect.cpp line 1681

I am using windoze 10, OpenCV 3.2, Python 2.7.9 64bit (stackless)

Any ideas please? It is a fresh install of OpenCV binaries.

Cheers, B

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2017-06-10 20:22:14 -0500

Bazmundi gravatar image

DOH. Answer is make sure you set the path to the xml haarcascade descriptor. The error is not very descriptive but it turns out it means there was no xml file at file path provided when running code.

edit flag offensive delete link more

answered 2017-10-30 20:41:39 -0500

supra56 gravatar image

video_capture = cv2.VideoCapture(0)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-06-10 20:05:33 -0500

Seen: 620 times

Last updated: Oct 30 '17