Skip to content

Instantly share code, notes, and snippets.

@Nithilaa
Created October 28, 2021 06:40
Show Gist options
  • Save Nithilaa/8ab79b4bce19ccb5eb14effeac750601 to your computer and use it in GitHub Desktop.
Save Nithilaa/8ab79b4bce19ccb5eb14effeac750601 to your computer and use it in GitHub Desktop.
import numpy as np
img = cv2.imread('perspective transformation.jpg', 1)
cv2.imshow("Perspective Transformation Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
rows, cols, ch = img.shape
pt1 = np.float32([[219,209],[612,8],[380,493],[785,271]])
pt2 = np.float32([[0,0],[500,0],[0,400],[500,400]])
matrix_aff = cv2.getPerspectiveTransform(pt1,pt2)
dst = cv2.warpPerspective(img,matrix_aff,(cols,rows))
cv2.imshow("Perspective Transformation", dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment