Python 双眼重叠的人脸检测
所以我做了一个小脚本,跟踪脸部,然后搜索两只眼睛,然后搜索每只眼睛,左右 问题是,即使是左和右,它也会重叠Python 双眼重叠的人脸检测,python,simplecv,haar-classifier,eye-tracking,Python,Simplecv,Haar Classifier,Eye Tracking,所以我做了一个小脚本,跟踪脸部,然后搜索两只眼睛,然后搜索每只眼睛,左右 问题是,即使是左和右,它也会重叠 i = Camera().getImage() face = i.findHaarFeatures("face.xml") if face != None: face = face[0].boundingBox() face = i.crop(face) twoeyes = face.findHaarFeatures("two_eyes_big.xml")
i = Camera().getImage()
face = i.findHaarFeatures("face.xml")
if face != None:
face = face[0].boundingBox()
face = i.crop(face)
twoeyes = face.findHaarFeatures("two_eyes_big.xml")
if twoeyes != None:
righteye = face.findHaarFeatures('right_eye.xml')
lefteye = face.findHaarFeatures('lefteye.xml')
if righteye != None and lefteye != None:
print righteye,lefteye
righteye = righteye[0].draw()
lefteye = lefteye[0].draw()
face.show()
印刷品显示:
[SimpleCV.Features.Detection.HaarFeature at (61,67)] [SimpleCV.Features.Detection.HaarFeature at (60,65)]
我试着用脸修剪脸。boundingBox(两只眼睛)和他们搜索左右,但它总是给我(没有,没有)
另外,当FindHarFeatures(“face.xml”)给了我不止一张脸时,我也遇到了一个问题,我通过选择列表中的第一张来克服这个问题,但我想选择其中最大的一个,如何比较两个功能的大小
最后,有没有更好的方法来查找其他功能中的某个功能,而不是使用crop和if语句'something!=没有
顺便说一句,我使用的是相机的原始图像,用对比度、饱和度、findedges或其他方法来更好地找到特征是否更好 以下代码将用于检测ROI(感兴趣区域)降低的眼睛,即人脸 我也在使用裁剪技术来减小ROI
img = Camera().getImage()
face = img.findHaarFeatures("face.xml")
if face: #checks for non empty feature set
face = face.sortArea() #sorting all detected faces by area
face = face[-1] #picking the largest face
face = img.crop(face) #crops face from the image
leftEye = face.findHaarFeatures("lefteye.xml")
leftEye.draw()
rightEye = face.findHaarFeatures("right_eye.xml")
rightEye.draw()
face.show()
右眼和左眼的检测都会给出重叠的结果,因为它们最终都会检测到右眼和左眼
要利用这一点,您可以利用两种结果的平均值来制作一双眼睛
我已经在网络摄像头的原始视频流中尝试了上述方法,未经处理的视频流效果不错