Guest User

Untitled

a guest
May 22nd, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. img = cv2.imread('IMG_20180522_211242_2.jpg')
  6. pts1 = np.float32([[58,642],[147,627],[83,733],[168,716],[2320,2654],[2291,2566],[2238,2675],[2211,2588]])
  7. pts2 = np.float32([[50,50],[150,50],[50,150],[150,150],[2100-50, 2970-50],[2100-50,2970-150],[2100-150,2970-50],[2100-150,2970-150]])
  8. size = (2100,2970)
  9.  
  10. M, mask = cv2.findHomography(pts1,pts2)
  11. dst = cv2.warpPerspective(img,M,size)
  12.  
  13. plt.subplot(121),plt.imshow(img),plt.title('Input')
  14. plt.subplot(122),plt.imshow(dst),plt.title('Output')
  15. plt.show()
Add Comment
Please, Sign In to add comment