| 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
|
from pyrobot.brain import Brain
def process(camera):
camera.apply('match', 158, 71, 48, )
match = camera.apply('match', 225 , 129 , 89 , )
if match > 50:
camera.apply('match', 188, 109, 68, )
else:
camera.apply('match', 40, 200, 56, )
camera.apply("superColor", 1, -1, -1, 0) # rgb weights, 0 = red channel
camera.apply("threshold", 0, 50) # red channel, 50 > 0
return camera.apply("blobify", 0) # red channel
# filters return values are stored in robot.camera[0].filterResults
# the process() filter only has one return value, that returned from the blobify
class VisionBrain(Brain):
def setup(self):
# get a camera that is already running and
# add a function to the filter list:
self.robot.camera[0].addFilter( process ) # process is the name of a method that takes a camera
def step(self):
# do something with the camera processed data:
print self.robot.camera[0].filterResults
def INIT(engine):
return VisionBrain('SimpleBrain', engine) |