我想问一下关于groupRectangles函数。

我在python中编写以下代码-

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#defining the face
thresh=1
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
print faces
faces_1,weights=cv2.groupRectangles(faces, thresh)

其中vec是detectMultiscal步骤返回的recl,1是groupThreshold,eps是0.2

但这在执行时抛出了运行时错误。我试图通过使用try-except运行代码,但仍然抛出相同的错误。
Runtime Error!

Program:C:\Python27\pythonw.exe

This application has requested the Runtime to terminate it in an unusual way.

如果有人可以用python提供一些示例grouprectangle代码,那将有很大的帮助,这样我就可以使我的工作代码具有相同的格式,因为该代码的文档中我找不到任何示例。

干杯!

最佳答案

我有同样的问题。
我设法通过强制转换为“列表”来使它不崩溃(但我不知道结果是否准确):

cv2.groupRectangles(list(rectVec), thresh)

10-08 00:16