Ask Your Question
0

How to spot parking space lines?

asked 2018-09-07 08:50:10 -0600

Michal gravatar image

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

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]: image description

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]:

image description

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.

Thank you in advice.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-07 10:49:55 -0600

monxarat gravatar image

The first you can Canny And HoughLinesP

Canny(...);

Convert gray to rgb

cvtColor(.. CV_GRAY2BGR);

perform HoughLinesP with your condition.

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();
}
edit flag offensive delete link more

Comments

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.

Michal gravatar imageMichal ( 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.

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

Question Tools

1 follower

Stats

Asked: 2018-09-07 08:50:10 -0600

Seen: 470 times

Last updated: Sep 07 '18