Canny
algorithm to create a binary image and then use the HoughLinesP
function detects line in binary image.
First we take the bird eye view image of straight labe for processing.
When the HoughLinesP
is applied we get following resulting lines:
Then we take a curved lane image
When the HoughLinesP
is applied we get following resulting lines:
Here is the code.
int hough(const char *input_path, const char *output_path) { Mat src_o, src, dst; src_o = imread(input_path); cvtColor(src_o, src, CV_BGR2GRAY ); Canny(src, dst, 200, 255, 3 ); vectorlines; HoughLinesP(dst, lines, 1, CV_PI/180, 20, 10, 20 ); std::map candidate; for( size_t i = 0; i < lines.size(); i++ ) { line( src_o, Point(lines[i][0], lines[i][1]), Point(lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8 ); } imwrite(output_path, src_o); return 0; }
Next step is to take the lines and calculate the lane midpoint.