Ask Your Question

Revision history [back]

OpenCV 3 - Python's detectMultiScale3 fails in clipObjects

Using OpenCV 3.0.0 and Python 3.4.3, I'm getting an error running detectMultiScale3. Specifically the error is:

cascadedetect.cpp:1597: error: (-215) a->size() == n in function clipObjects

Which appears to simply be an assertion check in the C++ source for clipObjects, though I don't know why it would be failing. I'm testing it with the code found at the "Face Detection using Haar Cascades" OpenCV tutorial, but simply changing which version of the detectMultiScale is being used. Anyone know why I might be getting this error and how I can fix it? Thank you much.

detectMultiScale3 Documentation


import numpy as np
import cv2

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

img = cv2.imread('face.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

faces, rejectLevels, levelWeights = face_cascade.detectMultiScale3(gray, 1.3, 5)
for (x,y,w,h) in faces:
    roi_gray = gray[y:y+h, x:x+w]
    roi_color = img[y:y+h, x:x+w]
    eyes = eye_cascade.detectMultiScale(roi_gray)
    for (ex,ey,ew,eh) in eyes: