G2A Many GEOs
SHARE
TWEET

Untitled

a guest Jul 31st, 2017 170 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. def order_points(pts):
  3.   #input format
  4.   #pts = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
  5.  
  6.   #sort points by x
  7.   tmp = sorted(pts, key=lambda point: point[0])
  8.  
  9.   #tmp[0] and tmp[1] is left point
  10.   #determine, which is top, and which is bottom by y coordinate
  11.   if tmp[0][1] > tmp[1][1]:
  12.     tl = tmp[1]
  13.     bl = tmp[0]
  14.   else:
  15.     tl = tmp[0]
  16.     bl = tmp[1]
  17.  
  18.   #do it with right tmp[2] and tmp[3]
  19.   if tmp[2][1] > tmp[3][1]:
  20.     tr = tmp[3]
  21.     br = tmp[2]
  22.   else:
  23.     tr = tmp[2]
  24.     br = tmp[3]
  25.  
  26.   return np.array([tl,tr,br,bl])
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top