我很确定自己的总体主题正确,但是没有发现任何面孔。我的代码从读取c=cv2.VideoCapture(0),即计算机的摄像机。然后,我进行了以下设置以生成面孔所在的位置。如您所见,我正在遍历不同的scaleFactors和minNeighbors,但是rect总是返回为空。我还尝试了opencv / data / haarcascades软件包中包含的四个不同的haarcascade xml文件。有小费吗?while(1): ret, frame = c.read() rects = find_face_from_img(frame)def detect(img, cascade): for scale in [float(i)/10 for i in range(11, 15)]: for neighbors in range(2,5): rects = cascade.detectMultiScale(img, scaleFactor=scale, minNeighbors=neighbors, minSize=(20, 20), flags=cv2.cv.CV_HAAR_SCALE_IMAGE) print 'scale: %s, neighbors: %s, len rects: %d' % (scale, neighbors, len(rects))def find_face_from_img(img): gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) gray = cv2.equalizeHist(gray) rects = detect(gray, cascade)
添加回答
举报
0/150
提交
取消