我对用Python编程和使用OpenCV(以及使用stackoverflow)相对比较陌生,但是我似乎找不到其他人遇到过这个问题。我正在尝试编写一个基本的人脸识别程序,基于各种教程,然而,我有一个问题的输出检测多尺度在这部分代码。在
for image_path in image_paths:
predict_image_pil = Image.open(image_path).convert('L')
predict_image = np.array(predict_image_pil, 'uint8')
faces = faceCascade.detectMultiScale(predict_image)
for (x, y, w, h) in faces:
nbr_predicted, conf = recognizer.predict(predict_image[y: y + h, x: x + w])
nbr_actual = int(os.path.split(image_path)[1].split(".")[0].replace("subject", ""))
每当我运行这个程序时,我反复收到一个“TypeError:'int'object is not iterable”错误,这导致我检查“faces”实际上是一个单独值的列表。运行这段稍作修改的代码后,很明显情况并非如此。在
^{pr2}$打印到控制台
[[108 55 154 154]]
[[116 62 152 152]]
[[ 95 76 139 139]]
[[118 57 152 152]]
[[107 53 152 152]]
[[ 32 59 153 153]]
[[101 84 137 137]]
[[ 92 53 152 152]]
[[ 85 77 141 141]]
[[ 96 55 156 156]]
[[108 69 145 145]]
[[ 94 47 159 159]]
[[112 83 137 137]]
[[ 56 68 149 149]]
[[103 77 142 142]]
它似乎在打印XYWH坐标,而没有用逗号分隔它们,这会是打字错误的原因吗?在
如果不是,是什么导致了这个问题?我可能遗漏了一些很明显的东西。为了得到faces模块,我不得不使用cmake和visualstudio从源代码构建opencv,但是,我不确定这是否是原因。在
我运行的是winpython64bit 2.7.10.3和最新的(稳定的)OpenCV版本。在
获得信心的问题似乎是预测的功能。一旦我从代码中删除了“conf”,这个问题就解决了。在
相关问题 更多 >
编程相关推荐