import cv2
import numpy as np
import matplotlib.pyplot as plt
tps = cv2.createThinPlateSplineShapeTransformer()
sshape = np.array ([[67, 90], [206, 90], [67, 228], [206, 227]], np.float32)
tshape = np.array ([[64, 63], [205, 122], [67, 263], [207, 192]], np.float32)
sshape = sshape.reshape (1, -1, 2)
tshape = tshape.reshape (1, -1, 2)
matches = list ()
matches.append (cv2.DMatch (0, 0, 0))
matches.append (cv2.DMatch (1,1,0))
matches.append (cv2.DMatch (2, 2, 0))
matches.append (cv2.DMatch (3, 3, 0))
tps.estimateTransformation (tshape, sshape, matches)
ret, tshape = tps.applyTransformation (sshape)
img = cv2.imread ('tiger.jpg', 1)
out_img = tps.warpImage (img)
plt.imshow(cv2.cvtColor(out_img, cv2.COLOR_BGR2RGB))
plt.show()
cv2.waitKey(0)