Rodrigo Guinea
Rodrigo Guinea

Reputation: 328

Use getPerspectiveTransform to obtain transformation matrix and then use it to transform a single point into warped space

I have the following image:

enter image description here

As you can see, there is a green point there with coordinates (x1,y1). Next, I identify some reference and target points in order to get the corresponding perspective transformation matrix using:

matrix = cv2.getPerspectiveTransform(referencePoints, targetPoints)

How should I use that matrix to transform just the (x1,y1) point into a new point (x2,y2) with the new perspective.

enter image description here

As an additional example, imagine you have two points in the original image with a distance d1 between them, but you want the true distance d2 between those two points. Then, you should transform both points into the new space (with a birds eye perspective) and calculate the distance again.

In particular, the transformation matrix is:

matrix = array([[ 3.51546299e+00,  1.70317103e+01,  3.42045887e+02],
                [-9.18633633e-01,  1.31323789e+01,  1.77154086e+03],
                [ 2.00130923e-06,  2.07269593e-03,  1.00000000e+00]])

And the point I want to transform is:

A = [303.7355, 1101.029]

Thank you

Upvotes: 1

Views: 1354

Answers (0)

Related Questions