1 | initial version |
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();
}