Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-OpenCV,detectMultiScale输出不';t用逗号分隔x、y、h、w值_Python_Opencv_Face Detection_Face Recognition - Fatal编程技术网

Python-OpenCV,detectMultiScale输出不';t用逗号分隔x、y、h、w值

Python-OpenCV,detectMultiScale输出不';t用逗号分隔x、y、h、w值,python,opencv,face-detection,face-recognition,Python,Opencv,Face Detection,Face Recognition,我对Python编程和使用OpenCV(以及使用stackoverflow)比较陌生,但是我似乎找不到任何其他人遇到过这个问题。我正试图根据各种教程编写一个基本的人脸识别程序,但是,在这部分代码中,我对detectMultiScale的输出有一个问题 for image_path in image_paths: predict_image_pil = Image.open(image_path).convert('L') predict_image = np.array(pred

我对Python编程和使用OpenCV(以及使用stackoverflow)比较陌生,但是我似乎找不到任何其他人遇到过这个问题。我正试图根据各种教程编写一个基本的人脸识别程序,但是,在这部分代码中,我对detectMultiScale的输出有一个问题

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”实际上是一个单独值的列表。在运行这段稍加修改的代码后,很明显情况并非如此

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)
    print faces
将此打印到控制台

[[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和visual studio从源代码构建opencv,但是,我不确定这是否是原因


我正在运行WinPython 64位2.7.10.3和最新(稳定的)OpenCV版本,该版本是从源代码构建的。

问题似乎在于获取预测函数的信心。一旦我从代码中删除了“conf”,问题就解决了。

当前实现中是否有其他函数可以提供对predict函数的信心?我正在使用OpenCV-3.1.0和OpenCV contrib。我上次使用它是在一段时间之前,但当时没有其他选择。但与此同时,情况可能已经发生了变化。对不起,我帮不上忙了。