opencv 3

时间:2017-11-12 01:48:34

标签: python opencv

级联分类器给出错误:

  cv2.error: /Users/jenkins/miniconda/1/x64/conda-bld/work/opencv-3.1.0/modules/objdetect/src/cascadedetect.cpp:1639: 
  error: (-215) !empty() in function detectMultiScale()

代码:

imggray=cv2.imread('frame1.jpg',cv2.IMREAD_GRAYSCALE)
imgnew=cv2.equalizeHist(imggray)
print imgnew
# cascade_fn = args.get('--cascade',"../../data/haarcascades/haarcascade_frontalface_default.xml")
face_cascade = cv.CascadeClassifier('./../data/haarcascades/haarcascade_frontalface_default.xml')
print face_cascade
faces = face_cascade.HaarDetectObjects(imgnew)
for (x,y,w,h) in faces:
    cv2.rectangle(imgnew,(x,y),(x+w,y+h),(255,0,0),2)
    roi_gray = imggray[y:y+h, x:x+w]
    roi_color = imgnew[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.imwrite('Frame2.jpg',imgnew)

按照此博客文章中的步骤查找opencv中可用的功能

https://www.pyimagesearch.com/2015/08/31/how-to-find-functions-by-name-in-opencv/

function list

1 个答案:

答案 0 :(得分:0)

我正在使用OpenCV 3.3

>>> cv2.__version__
'3.3.0-dev'
>>> x = cv2.CascadeClassifier()
>>> x.detectMultiScale
<built-in method detectMultiScale of cv2.CascadeClassifier object at 0x7fea612cc0f0>

我喜欢这个:

enter image description here

然后我明白了: enter image description here