00001 import numpy as np 00002 00003 SAME_OBJ_THRESH = 0.03 00004 00005 def dist(p1, p2): 00006 p1 = np.array(p1) 00007 return np.sum(np.sqrt((p1-p2)**2)) 00008 00009 def sameObject(p1, p2): 00010 return dist(p1,p2) < SAME_OBJ_THRESH 00011 00012 def closestPoint(pts, pt): 00013 # which point in pts is the closest to pt? 00014 distances = [dist(pp,pt) for pp in pts] 00015 return pts[np.argmin(distances)]