我正在进行一个openCV项目,试图检测 parking 位并从图像中提取ROI(感兴趣区域),以进行进一步的车辆检测。提供的图像将包含所有空的 parking 位。我已经阅读了一些有关此的文章和教程。到目前为止,我尝试过的方法是:

1.Convert image to grayscale using `cvtColor()`
2.Blur the image using `blur()`
3.Threshold the image to get edges  `threshold()`
4.Find image contours using findContours()
5.Finding all convex contours using `convexHull()`
6.Approx polygonal regions using `approxPolyDP()`
7.Get the points for the result from 5, if total number of points =4.
  Check for area and angle.

我猜这种方法的问题是当我执行findContours()时,它发现不规则且更长的轮廓,这导致approxPolyDP假定四边形大于 parking 位本身。一些 parking 线有孔/不规则。

我也尝试过goodFeaturesToTrack(),它可以非常有效地给出角,但是存储在输出中的点是任意顺序的,我认为从中提取四边形/矩形将非常严格。

我在此上花了很多时间。有什么更好的办法吗?

This是我正在玩的图像。

最佳答案

尝试在带阈值的图像上使用dilate以使孔消失。

这是一个很好的教程:opencv erode and dilate

07-24 13:21