HoughLinesP not detecting all lines

asked 2013-08-30 02:47:03 -0600

Hi, I am attempting to detect all straight lines in an image using HoughLinesP. I believe I am not detecting all lines because Canny in not returning the lines as straight lines but rather wiggly version of them so HoughLinesP is failing to detect them. Here is my current implementation.

// myMat is 576 x 384
cv::cvtColor(myMat, myMat, CV_BGR2GRAY);
cv::equalizeHist(myMat, myMat);
cv::GaussianBlur(myMat, myMat, cv::Size(3, 3), 10);
float cannyAmount = 30;
cv::Canny(myMat, myMat, cannyAmount, 2 * cannyAmount, 3);
std::vector<cv::Vec4i> lines;
HoughLinesP(inputMat, lines, 1, CV_PI/180, 30, 10, 10 );

If anyone could give me some guidance on how to detect all straight lines in would be highly appreciated.

Thank you

edit retag flag offensive close merge delete



There is no straightforward solution for detecting ALL lines. Simply because a computer doesn't see an image like humans do but as a series of pixel values. Each algorithm has it's fallbacks, expecially canny edge detector which is based on gradients, but pixelated structures create gradients also :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-30 03:47:28 -0600 )edit

I guess you should read this chapter of a very interesting book I have found.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-30 03:50:32 -0600 )edit