-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbolablanca.py
More file actions
37 lines (29 loc) · 957 Bytes
/
bolablanca.py
File metadata and controls
37 lines (29 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'''
This is how to track a white ball example using SimpleCV
The parameters may need to be adjusted to match the RGB color
of your object.
The demo video can be found at:
http://www.youtube.com/watch?v=jihxqg3kr-g
'''
print __doc__
import SimpleCV
display = SimpleCV.Display()
cam = SimpleCV.Camera()
normaldisplay = True
while display.isNotDone():
#if display.mouseRight:
# normaldisplay = not(normaldisplay)
# print "Display Mode:", "Normal" if normaldisplay else "Segmented"
img = cam.getImage().flipHorizontal()
dist = img.colorDistance(SimpleCV.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(),SimpleCV.Color.BLUE,3)
print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",circles[-1].x
if normaldisplay:
img.show()
else:
segmented.show()