def get_points(event,x,y,flags,param):
global lpnts,rpnts
if event == cv2.EVENT_LBUTTONDOWN:
lpnts = np.append(lpnts, np.array([[x, y]]), axis=0)
cv2.polylines(img, [lpnts], False, (0, 0, 255))
if event == cv2.EVENT_RBUTTONDOWN:
rpnts = np.append(rpnts, np.array([[x, y]]), axis=0)
cv2.polylines(img, [rpnts], False, (255, 0, 0))
if rpnts.size>2:
check(lpnts, rpnts[-1], rpnts[-2])
#check if the new point crosses a line
评论列表
文章目录