Reputation: 405
I am working on a openCV project, trying to detect parking spaces and extract the ROI(Region of Interest) from an image for further vehicle detection. The image provided will consist of all empty parking spaces. I have read several posts and tutorials about this. So far, the approach I have tried are:
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.
I guess the problem with this approach is when I do findContours()
, it finds irregular and longer contours which causes approxPolyDP
to assume quadrilaterals larger than the parking space itself. Some parking lines have holes/irregularity.
I have also tried goodFeaturesToTrack()
and it gives corners quite efficiently, but the points stored in the output are in arbitrary order and I think it is going to be quite rigorous to extract quadrilaterals/rectangles from it.
I have spent quite good hours on this. Is there any better approach to this?
This is the image I am playing with.
Upvotes: 2
Views: 2617
Reputation: 12544
Try using dilate
on the thresholded image to make the holes disappear.
Here is a good tutorial on it: opencv erode and dilate.
Upvotes: 1