面部检测返回价值无面
我使用Haar Cascade进行面部检测
faces_haar = face_cascade.detectMultiScale(image, scaleFactor=1.3, minNeighbors=4, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
,并将面部保存在此变量中
(x, y, w, h) = faces_haar[0]
,而在我
return image[y:y+h, x:x+w] , faces_haar[0]
发现任何脸部的fucntion中,我会回来,这给了我“ IndexError:Tuple Index脱离范围”的错误。 因为我没有脸。
我只有在他发现一些脸时才能返回?
I' using haar cascade for face detection
faces_haar = face_cascade.detectMultiScale(image, scaleFactor=1.3, minNeighbors=4, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
and i save the face in this variables
(x, y, w, h) = faces_haar[0]
and in my fucntion i return
return image[y:y+h, x:x+w] , faces_haar[0]
when he dont find any face gives me the error "IndexError: tuple index out of range"
because i dont have any face.
How i can return only when he find some face?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果检查列表是否不是空的,则应使用
,它将自动运行
返回无
You should use
if
to check if list is not emptyand it will automatically run
return None