Skip to content

Instantly share code, notes, and snippets.

@xamox
Created April 21, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xamox/2438894 to your computer and use it in GitHub Desktop.
Save xamox/2438894 to your computer and use it in GitHub Desktop.
Object Tracking with SimpleCV (White Ball) - Minimized Version
from SimpleCV import *
cam = Camera()
while True:
img = cam.getImage().flipHorizontal()
dist = img.colorDistance(Color.BLACK).dilate(2)
segmented = dist.stretch(200,255)
blobs = segmented.findBlobs()
if blobs:
circles = blobs.filter([b.isCircle(0.2) for b in blobs])
if circles:
img.drawCircle((circles[-1].x, circles[-1].y), circles[-1].radius(),Color.BLUE,3)
img.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment