Removal of vertical HoughLines/Detection of Horizontal HoughLines only
computer-vision, image-processing, opencv
Solution
To remove vertical line
First find the angle for each line using the equation
`double Angle = atan2(y2 - y1, x2 - x1) * 180.0 / CV_PI;`
Just ignore the line which has angle 90 degree(vertical line).
Done !.
Problem
I wish to ask if there is a method to detect only the nearly horizontal Hough Lines or ignoring those nearly vertical Hough Lines? My code for the HoughLine now is as shown: ``` HoughLinesP(imagec, lines, 80, CV_PI/2, CV_THRESH_OTSU|CV_THRESH_BINARY, 25, 7); for(size_t i = 0; i < lines.size(); i++) { Vec4i l = lines[i]; line(imagec, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255,255,255), 8, 8); line(imagelines, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255,255,255), 8, 8); //draw on black image as well } ``` However in the image, I am seeking only to detect horizontal lines, or at least near horizontal lines like by 2 to 4 cm. I am using `CV_PI/2` for the theta parameter in the HoughLineP, hence the vertical lines/ near vertical lines are detected too. Any suggestions, code samples, etc will be greatly appreciated. Thanks.