how to limit number of faces detected by haar cascades

放肆的年华 提交于 2019-12-11 02:48:02

问题


I am using Haar cascade in an emotion detection system. Every video input I am giving to the model has only one face in it (It is a requirement). When I run Haar cascade model to detect faces, it has some false positives. Since I have only one face in the video, I want to take the most positive area detected and ignore all other detection. Is there a way to do that?


回答1:


when you are calling detectMultiScale function, set the minNeighbours value to a high value to avoid false positives. Also, you can set the minSize parameter to specify a minimum size of face to be detected. Here is what I am using for face detection using a webcam.

faces = faceCascade.detectMultiScale(
            gray,
            scaleFactor=1.2,
            minNeighbors=10,
            minSize=(64,64),
            flags=cv2.CASCADE_SCALE_IMAGE
        )


来源:https://stackoverflow.com/questions/52288066/how-to-limit-number-of-faces-detected-by-haar-cascades

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!