-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblob_test1.py
More file actions
36 lines (24 loc) · 919 Bytes
/
blob_test1.py
File metadata and controls
36 lines (24 loc) · 919 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
from SimpleCV import Camera, Display, Image, Display, DrawingLayer, Color, ColorModel
from time import sleep
myCamera = Camera(prop_set={'width' : 320, 'height' : 240})
#redImage = Image("red.jpg")
#redCrop = redImage.crop(0,0,320,240)
myDisplay = Display(resolution=(320, 240))
while not myDisplay.isDone():
frame = myCamera.getImage().colorDistance(Color.RED)
negative = frame.colorDistance(Color.WHITE)
#cm = ColorModel()
#cm.add(Color.BLACK)
#cup = cm.threshold(frame)
blobs = negative.findBlobs(threshval=(210,210,210),minsize=10)
#cups = blobs.filter([b.isRectangle(0.5) for b in blobs])
for b in blobs:
b.drawOutline(color=Color.RED)
#blobs are returned in order of area, smallest first
print(blobs)
#myDrawingLayer = DrawingLayer((frame.width,frame.height))
#myDrawingLayer.sprite(cup)
#frame.addDrawingLayer(myDrawingLayer)
#frame.applyLayers()
negative.save(myDisplay)
sleep(5)