Skip to content Skip to sidebar Skip to footer

OpenCV Transform Shape With Arbitrary Contour Into Rectangle

The short question is how to transform a shape like the below one into a rectangle using OpenCV? Notes: Shape contours aren't necessarily straight lines - they could be slightly

Solution 1:

In this case you are looking to do a non-linear transformation of that image. Traditionally you would use a single transformation of the entire paper to make it into a rectangle. This can be done with only the corners. More complex correction like lens distortion you would need to pick points on the page and assert that they are supposed to be co-planar to generate your transformation matrix. Basically you need to have an understanding of the geometry in your image in order to undistort it. So the geometry you need to find is the 3 dimensional surface of the page.

In order to find the highly nonlinear geometry of your mangled piece of paper, you could take multiple images of the page and triangulate them. If you want to go this route, pick up a copy of Multiple View Geometry by Hartley and Zisserman.


Post a Comment for "OpenCV Transform Shape With Arbitrary Contour Into Rectangle"