I'm trying to work with Python, opencv and simplecv. I want to capture an image using a camera and then draw a 'freeform' 'filled' area over the captured image using Mouse. Can somebody please help me accomplish this. Here is what I have done till now:
from SimpleCV import Camera, Display, Image, Color
cam = Camera()
display = Display()
img = cam.getImage()
img.save(display)
while not display.isDone():
if display.mouseLeft:
img.dl().circle((display.mouseX, display.mouseY), 4, Color.WHITE, filled=True)
img.save(display)
img.save("draw.png")
I can draw over the captured Image, but only with circles. That too are placed far too wide if I draw with normal speed. Here's how it looks:
Whereas I am trying to achieve something like this:
Can somebody help me out?
Keep mouse position on list and draw polygon:
from SimpleCV import Camera, Display, Image, Color
cam = Camera()
display = Display()
img = cam.getImage()
img.save(display)
points = []
while not display.isDone():
if display.mouseLeft:
point = (display.mouseX, display.mouseY)
points.append( point )
if len(points) > 2:
img.dl().polygon(points, filled=True, color=Color.RED)
img.dl().circle(point, 4, Color.WHITE, filled=True)
img.save(display)
img.save("draw.png")
Read SimpleCV doc: Drawing on Images in SimpleCV