# How to spot parking space lines?

Hi, I'm trying to spot parking spaces on parking image. The orginal image below[1]:

The brick color which marks each spot is created with single red brick next to common gray brick (and so) which makes this parking lines almost unnoticeable.

After uploading CLAHE and other pre-procesinng image looks more friendly to catch lines[2]:

To simplyfy things I also highlighted lines with paint program. And finally my question is how to tune properly hough algorithm to get lines spotable? Changing theta degree leads to find only horizontal lines, only vertcal lines or mixture of horizontal, vertical and diagonal lines; but they never cover lines of parking spots[3]:

Please share with me clues how to tune up Hough for this case. We'll apreaciate diffrent ideas how to spot parking spaces lines (refering to pic[2]) too.

edit retag close merge delete

Sort by ยป oldest newest most voted

The first you can Canny And HoughLinesP

Canny(...);


Convert gray to rgb

cvtColor(.. CV_GRAY2BGR);


HoughLinesP(...);


Draw lines have detected to an Image above into new an maxtric

for (size_t i = 0; i < lines.size(); i++)
{
Vec4i l = lines[i];
line(new maxtric, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 5, CV_AA)
}


Prform erode and dilate

Mat element = getStructuringElement(CV_SHAPE_RECT, Size(3, 3));
erode(mat, mat, element);
dilate(mat, mat, element);


Use double dilate and substract their results to get mask of lines:

morphologyEx(mat, mark, CV_MOP_DILATE, element,Point(-1,-1), 3);
morphologyEx(mat, mark2, CV_MOP_DILATE, element, Point(-1, -1), 2);
result = mark - mark2;


Canny and Hough lines, this time for removing the connecting line between each parking spot.

Canny(result, mark, ...);


perform HoughLinesP on mark and draw line into mark2

HoughLinesP(mark, lines3, 1, CV_PI / 180, ,..);
for (size_t i = 0; i < lines3.size(); i++)
{
line();
}

more

Hey, appreciate your anwer. Unfortunately after Canny and Hough I get an improper lines as mentioned on point [3] in queston; even after highlighting them with artificial lines. The question is how to spot proper ones, not how to draw them later. Anyway thank you for your efford.

( 2018-09-09 10:25:57 -0600 )edit

@Michal

The line of the spot parking on your image is too blurry. I think it is difficult to do this.

( 2018-09-11 03:47:17 -0600 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Seen: 375 times

Last updated: Sep 07 '18