title: How to delete drawn lines on image in Python?
body: <p>I have drawn several lines in python (with opencv package) using mouse clicks (Every mouse click is a point which is connected) on top of an existing image, you can think of this as allowing user to select something on image.</p>
  
  <p>How would I allow to user to delete last point on image by clicking the right mouse click? This is my current code:</p>
  
  <pre><code>import numpy
  import cv2
  
  points = []
  
  def draw_point(event, x, y, flags, param):
      if event == cv2.EVENT_LBUTTONDOWN:
          cv2.circle(image, (x,y), 1, (255,0,0),-1)
          points.append((x,y))
          pts = numpy.array(points, numpy.int32)
          cv2.polylines(image,[pts],False,(255,0,0))
      elif event == cv2.EVENT_RBUTTONDOWN:
          # HOW TO DELETE?
          del points[-1]
          pts = numpy.array(points, numpy.int32)
          cv2.polylines(image,[pts],True,(255,0,0))
  
  
  
  image = cv2.imread('simple_tattoo.jpg', cv2.IMREAD_UNCHANGED)
  
  cv2.namedWindow('example', cv2.WINDOW_AUTOSIZE)
  cv2.setMouseCallback('example', draw_point)
  
  
  while(1):
     cv2.imshow('example',image)
  
     if cv2.waitKey(20) &amp; 0xFF == 27:
          break
  
  cv2.destroyAllWindows()
  
  print (points)
  </code></pre>
  
  <p>Is there perhaps an easier way to draw lines(anything) on an image?</p>