| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from pyrobot.brain import Brain
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('match', 158 , 71 , 48 , )
self.robot.camera[0].addFilter('match', 225 , 129 , 89 , )
self.robot.camera[0].addFilter('match', 188 , 109 , 68 , )
self.robot.camera[0].addFilter("superColor", 1, -1, -1, 0) # rgb weights, 0 = red channel
self.robot.camera[0].addFilter("threshold", 0, 50) # red channel, 50 > 0
self.robot.camera[0].addFilter("blobify", 0) # red channel
# filters return values in robot.camera[0].filterResults
def step(self):
# do something with the camera processed data:
print self.robot.camera[0].filterResults
def INIT(engine):
return VisionBrain('SimpleBrain', engine) |