0

I have the location of the 4 corners of the element but I want to straighten it My image looks like this representation:

From misaligned to aligned element

The said element is in an image so I'd like to apply the alignment to the whole image.

Mush
  • 23
  • 8

1 Answers1

0

What you are searching for is a homography Transformation.

First you need the positions of your 4 corner points of the image and then your have to define the destination of those 4 points. In your case it would be the image boundaries. If you have your destination points, you can call the function H, mask = cv.findHomography(srcPoints, dstPoints)(see documentation in calib3d module).

The matrix H describes the transformation from your source image to the destination image. Next you need to apply the Matrix H on your image which can be done with the function dst = cv.warpPerspective(srcImage, destImage,H) (see documentation of this function here).

If you want to do more stuff with the homography matrix, see OpenCv Homography tutorial with example code

Ph1llip2
  • 141
  • 4