def annotate_mouse_callback(event, x, y, flags, annotator):
winName = annotator.winName
# If adding a bounding box:
if annotator.editing:
# Set top left corner of rectangle:
if event == cv2.EVENT_LBUTTONDOWN:
annotator.rect_tl = (x, y)
# Set bottom right corner of rectangle:
elif event == cv2.EVENT_RBUTTONDOWN:
annotator.rect_br = (x, y)
# If deleting a bounding box:
elif annotator.deleting:
if event == cv2.EVENT_LBUTTONDOWN:
print 'Delete at {}'.format((x, y))
annotator.delete_rectangles_at_point((x, y))
annotator.deleting = False
annotator.update_display()
评论列表
文章目录