Note: I am trying to make a process that can work with a general range of images, orientations, and qualities, not specific to just this image.
I understand that you can use convex hull to enclose a set of points with a polygon, and you can use one of the several algorithms to create a minimum bounding box for those points. However, I want to do what is similar to the minimum bounding box, but without limiting it to be a rectangle.
Say I have this receipt:
The convex hull:
The minimum bounding box (rotating calliper):
My Goal: (ms-paint):
As you can see the minimum bounding box doesn't quite work out, since the receipt is a trapezoid from the perspective. This only gets worse the lower the perspective. I want to have 4 points, and sharp corners, so I can't use the convex hull.
Is there an algorithm that I can use to get something similar to the convex hull, or minimum bounding box, but limited to 4 points, and any quadrilateral shape?