gpt4 book ai didi

python - opencv 3 中缺少 detectMultiScale 函数

转载 作者:太空宇宙 更新时间:2023-11-03 23:12:15 25 4
gpt4 key购买 nike

级联分类器报错:

  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

最佳答案

我正在使用 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

关于python - opencv 3 中缺少 detectMultiScale 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47244667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com