Already using HoughLinesP for detecting lines in the image, but the issue is it detects only straight, clean lines and misses out rest
here's the code
int threshold = 80;
double minLineSize = 100;
double lineGap = 10;
double theta=Math.PI / 180;
Imgproc.HoughLinesP(edges, lines, 1, theta, threshold, minLineSize, lineGap);
when it is applied on the below image
https://i.stack.imgur.com/2HFFY.png
The lines identified can be seen as below
https://i.stack.imgur.com/loc4k.png
As you can see the actual lines(Document boundary) I wanted to detect are being skipped.
Steps I followed
- Changed to grayscale
- Applied canny edge detection
- findContour
- If contour with appropriate area is not found, trying to find large lines & build the boundary manually
- Issue i'm facing is that the houghlinesP is not detecting required lines and hence I'm unable to design my document boundary
Please suggest any other method to detect lines, and since I will use this code as a generalized one, I will not be able to modify the threshold & other values once I have configured.
I have also referred many other similar questions in stackoverflow but most of them suggest to use HoughLines but with different parameter values.
One of the question I found similar to my issue, but no answer.
Detecting incomplete rectangles (missing corners/ short endges) in OpenCV
Dark White lines are the ones detecting by HoughLinesP method
Also find below other sample images where the lines are being detected wrongly
https://i.stack.imgur.com/fWjti.png