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

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 假设四边形大于停车位本身。有些停车线有洞/不规则。

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

我在这上面花了很多时间。对此有更好的方法吗?

是我正在玩的图像。

有帮助吗?

解决方案

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

这是一个很好的教程: opencv 腐蚀和膨胀.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top