I was wondering if there is a function in OpenCV to straighten a region in an image.
If I have an image that is just skewed, the getPerspectiveTransform and warpPerspective functions do a good job to straighten it, like shown in Figure 1.
However, if the card/document in the picture is kind of curved or folded, getPerspectiveTransform and warpPerspective were not enough to solve the problem, because they end up cropping information at the bottom and they leave background at the top (Figure 2).
I’m able to find the contour of the card/document. I was wondering if there is a function that could help me achieve the desired output shown in Figure 3.
I would really appreciate if anyone could guide or suggest me a way to solve this problem!