如何解决'cv2.CascadeClassifier'对象的描述符'detectMultiScale'不适用于'numpy.ndarray'对象
导入cv2 导入label_image
大小= 4
我们加载xml文件
classifier = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
webcam = cv2.VideoCapture(0)#使用连接到PC的默认WebCam。
为True时: (rval,im)= webcam.read() im = cv2.flip(im,1,0)#翻转以充当镜子
# Resize the image to speed up detection
mini = cv2.resize(im,(int(im.shape[1]/size),int(im.shape[0]/size)))
# detect MultiScale / faces
faces = cv2.CascadeClassifier.detectMultiScale(mini)
# Draw rectangles around each face
for f in faces:
(x,y,w,h) = [v * size for v in f] #Scale the shapesize backup
cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),4)
#Save just the rectangle faces in SubRecFaces
sub_face = im[y:y+h,x:x+w]
FaceFileName = "test.jpg" #Saving the current image from the webcam for testing.
cv2.imwrite(FaceFileName,sub_face)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。