I want to creating an affine transform such that after the transform happens the image is still centered around the blue dot, and the top red dot is 45% from the top of the image, and the bottom red dot is 25% from the bottom of the image here is an example:
This is what I currently have right now:
To do the affine transform I setup the source and destination points like so:
src = [[231, 281],[283,243],[285,379]] # blue dot, top red dot, bottom red dot
dst = [[231, 281], [283, 243*0.45], [285, 379 * 0.75]]
And found the transformation matrix:
M = cv2.getAffineTransform(src, dst)
But when I printed out the matrix I got this:
M = [[ 1. -0. 0. ]
[ -2.33606605 1.32038334 449.60354104]]
Which is obviously wrong as the -2.336
appearing in M[1,0]
means that the transformation matrix is sheering in the y-direction
, therefore it was no surprise that my image ended up like this:
My question is what am I doing wrong? Am I picking the wrong points to define the affine transform?
EDIT: After trying the suggestion by @Miki this was the result