Ask Your Question

Revision history [back]

You did not declare the input image (img).
cv2.imread("input.png")//-->must this line be img = cv2.imread("input.png")

tps = cv2.createThinPlateSplineShapeTransformer()
pts1 = [(10, 10), (100, 100), (50, 100), (200, 30), (60, 20), (150, 200), (120, 90)]
pts2 = [(15, 5), (110, 105), (55, 105), (190, 35), (70, 20), (155, 205), (115, 95)]

img = cv2.imread("input.png")

matches = [cv2.DMatch(i, i, 0) for i in range(7)]
tps.estimateTransformation(np.array(pts1).reshape((-1, 7, 2)), np.array(pts2).reshape((-1, 7, 2)), matches)
dst = tps.warpImage(img)
cv2.imwrite('warped.png', dst)