I am making my own document scanner pipeline, this is good to note since image-specific methods of finding corners/contours..etc tend to be ineffective for a range of different images. I have found the best contour of the document and have retrieved an array of lines and their corresponding intersections.
Image with contour:
I am trying to narrow down all the lines/intersections to best fit the original contour, so I can get my 4 corner points of the document. I have tried narrowing it down based on the inner-angle of the intersections, then picking the best 4 intersections.
Image with line intersections with 90°(+-10°) interior angles (Green are the 4 best angles):
As you can see, the outcome is not ideal, I can make a rectangle with the green lines, and while it's the closest to a true rectangle, it's not the closest to the previous contour around the receipt.
What methods can I use to further narrow this down to pick intersections that better represent the shape of the original contour?
Reference Images:
Original Image:
Edged: