Skip to content

Instantly share code, notes, and snippets.

@vshivam
Created September 8, 2012 07:02
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 vshivam/3672457 to your computer and use it in GitHub Desktop.
Save vshivam/3672457 to your computer and use it in GitHub Desktop.
White Ball Tracker
from SimpleCV import *
import time
points = []
cam = Camera(0)
display = Display()
while display.isNotDone():
img = cam.getImage().flipHorizontal()
white_ball = img.colorDistance(Color.WHITE)
only_white = img - white_ball
blobs = only_white.findBlobs()
if blobs:
for b in blobs:
if b.isCircle(0.2):
loc = (b.x,b.y)
img.drawCircle(loc,b.radius(),Color.RED,2)
points.append(loc)
img.drawPoints(points,Color.BLUE,2,-1)
img.show()
time.sleep(0.001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment