我可以使用 approxPolyDP 来改进人员检测吗?

Can I use approxPolyDP to improve the people detection?

我可以使用 approxPolyDP 来改进人物检测吗?

我正在尝试检测使用 BackgroundSubtractorMOG2 的人。所以在我收到图像的前景后,我使用这个函数获得了图像的所有轮廓:

Imgproc.findContours(contourImg, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

我迭代 contours 变量的每个元素,如果轮廓有指定的 contour area => 它是一个人

我的问题是我是否可以使用 approxPolyDP 更好地检测人物形状。

可能吗?如果可以,你能告诉我怎么做吗?

我在找到counturs之前已经使用了CLOSE morphological操作

My question is if I can detect the people shapes better ussing approxPolyDP.

虽然 "better" 有点模棱两可,但您可以使用该方法改进您的分类。从docs我们可以看出:

The functions approxPolyDP approximate a curve or a polygon with another curve/polygon with less vertices so that the distance between them is less or equal to the specified precision.

"precision" 指的是 epsilon 参数,代表 "maximum distance between the original curve and its approximation" (也来自文档)。它基本上是从弧长得到的精度参数(越低轮廓越精确)。

我们从this tutorial中可以看出,一种实现方式是:

epsilon = 0.1*cv2.arcLength(contour,True)
approx = cv2.approxPolyDP(contour,epsilon,True)

导致更好的轮廓近似。在该教程的示例中,他们使用弧长的 1% 实现了最佳轮廓,尽管您应该根据您的具体情况仔细 select 这个百分比。

通过使用这些程序,您肯定会在等高线区域上获得 更高的精度 ,这将使您能够更好地将人物与具有相似区域的其他对象正确分类。您还必须相应地修改您的分类标准 (>= some_area) 以正确区分人和非人对象,因为您拥有更精确的区域。