def order_points(pts):
x_sorted = pts[np.argsort(pts[:,0]),:]
left_most = x_sorted[:2,:]
right_most = x_sorted[2:,:]
left_most = left_most[np.argsort(left_most[:,1]), :]
(tl, bl) = left_most
D = dist.cdist(tl[np.newaxis], right_most, 'euclidean')[0]
(br, tr) = right_most[np.argsort(D)[::-1],:]
return np.array([tl, tr, br, bl], dtype='int32')
评论列表
文章目录