gpt4 book ai didi

python - OpenCv, Python - 打印第一个发现的嘴巴

转载 作者:太空宇宙 更新时间:2023-11-03 21:51:58 24 4
gpt4 key购买 nike

我正在对一组按顺序加载的静态图像运行人脸检测算法。我只想打印第一个发现的嘴巴,以避免大量误报。我目前有这个:

for img in glob.glob('*'):

cvImg = cv2.imread(img,0)
if cvImg is not None:
images.append(cvImg)
print len(images)
for img in images:
(...)
mouths = mouthCascade.detectMultiScale(roiMouth, 1.3, 5)
for mouth in mouths:
(mx, my, mw, mh) = mouth[0]
cv2.rectangle(roiMouth, (mx, my), (mx+mw, my+mh), (0, 45, 55), 2)
countMount = countMount + 1

但我总是遇到同样的错误:

TypeError: 'numpy.int32' object is not iterable

在线 (mx, my, mw, mh) = mouth[0]。我只是找不到正确的方法来做到这一点!

最佳答案

mouth 是一个矩形列表。 (mx, my, mw, mh) = mouth 应该可以完成这项工作。

网上有很多教程: http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html

关于python - OpenCv, Python - 打印第一个发现的嘴巴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40833431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com