def __init__(self, robot, visionSystem=None, tcp=1): """ """ self.robot = robot self.robot.setRemoteControl("Raw Cam Server", "on") time.sleep(1) self._dev = AiboCam(self.robot.host, self.robot.PORT["Raw Cam Server"], tcp) # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() self.data = CBuffer(self._cbuf) self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Aibo Camera View", async=1) self.subtype = "aibo" self.data = CBuffer(self._cbuf)
def __init__(self, robot, width=80, height=60, depth=3, visionSystem=None): """ """ self.robot = robot self.width = width self.height = height self.depth = depth self._dev = Robocup(self.width, self.height, self.depth) # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() # ------------------------------------------------- # outer boundaries: Top, Left, Right, Bottom # inner lines: top, left, right, bottom # pentalty box: 1pleft, 2pright # from page 31 of the Robocup Soccer Simulator manual: self.lines = { "top": ["lt", "ct", "rt"], "left": ["lt", "glt", "gl", "glb", "lb"], "bottom": ["lb", "cb", "rb"], "right": ["rb", "grb", "gr", "grt", "rt"], "Top": [ "tl50", "tl40", "tl30", "tl20", "tl10", "t0", "tr50", "tr40", "tr30", "tr20", "tr10" ], "Left": ["lt30", "lt20", "lt10", "l0", "lb30", "lb20", "lb10"], "Bottom": [ "bl50", "bl40", "bl30", "bl20", "bl10", "b0", "br50", "br40", "br30", "br20", "br10" ], "Right": ["rt30", "rt20", "rt10", "r0", "rb30", "rb20", "rb10"], "center": ["t0", "ct", "c", "cb", "b0"], "1pleft": ["plt", "plc", "plb"], "2pright": ["prt", "prc", "prb"], "a": ["plt", "lt20"], # draw pentalty box sides "A": ["plb", "lb20"], # draw pentalty box sides "z": ["prt", "rt20"], # draw pentalty box sides "Z": ["prb", "rb20"], # draw pentalty box sides } self.data = CBuffer(self._cbuf) self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Robocup Camera View") self.subtype = "robocup" self.data = CBuffer(self._cbuf)
def __init__(self, host, port, visionSystem=None): """ """ self._dev = PlayerCam(host, port) # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() self.data = CBuffer(self._cbuf) self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Player Camera View") self.subtype = "player" self.data = CBuffer(self._cbuf)
def __init__(self, width, height, depth=3, device='/dev/video0', channel=1, title=None, visionSystem=None, visible=1): """ Device should be the name of the capture device in the /dev directory. This is highly machine- and configuration-dependent, so make sure you know what works on your system Channel - 0: television; 1: composite; 2: S-Video """ if width < 48: raise ValueError, "width must be greater than 48" if height < 48: raise ValueError, "height must be greater than 48" self.deviceFilename = device self.handle = None self._cbuf = None try: self._dev = V4L2(device, width, height, depth, channel) self._dev.setRGB(2, 1, 0) except: print "v4l2: grab_image failed!" # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() # ------------------------------------------------- if title == None: title = self.deviceFilename self.rgb = (2, 1, 0) # offsets to BGR self.format = "BGR" Camera.__init__(self, width, height, depth, title=title, visible=visible, async=0) # this overwrites _dev! self.rgb = (2, 1, 0) # offsets to BGR self.format = "BGR" self.subtype = "video4linux2" self.source = device self.data = CBuffer(self._cbuf)
def __init__(self, robot, camera=None, depth=3, visionSystem=None): """ """ self.robot = robot # if no camera given, we'll try a blobfinder if camera == None: # is there a default one? try: self.blobfinder = self.robot.blobfinder[0] except AttributeError: # no,then we'll try to start one: self.blobfinder = self.robot.startDevice('blobfinder') else: # else, you better have supplied a name, like "blobfinder0" self.blobfinder = camera self._devBlobFinder = self.blobfinder._dev while self._devBlobFinder.width == 0: pass self.width, self.height = self._devBlobFinder.width, self._devBlobFinder.height self.depth = depth self._dev = Blob(self.width, self.height, self.depth) # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() # ------------------------------------------------- self.data = CBuffer(self._cbuf) self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Blob Camera View") self.requires = ["blobfinder"] self.subtype = "blob" self.source = "%s[%d]" % (self.blobfinder.type, self.blobfinder.index) self.data = CBuffer(self._cbuf)
def __init__(self, robot, visionSystem=None, tcp=1): """ """ self.robot = robot self._dev = RovioCam(self.robot.theurl, 80, tcp) # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() self.data = CBuffer(self._cbuf) self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Rovio Camera View", async=1) self.subtype = "rovio" self.data = CBuffer(self._cbuf)
def __init__(self, width, height, depth): self.width = width self.height = height self.depth = depth self._dev = Fake("", self.width, self.height, self.depth) self.vision = VisionSystem() self.vision.registerCameraDevice(self._dev) self._cbuf = self.vision.getMMap() # ------------------------------------------------- self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Fake Camera View") self.subtype = "simulated" self.data = CBuffer(self._cbuf)
def __init__(self, robot, visionSystem): self.robot = robot self.width = 320 self.height = 240 self.depth = 3 self._dev = Fake("", self.width, self.height, self.depth) self.vision = VisionSystem() self.vision.registerCameraDevice(self._dev) self._cbuf = self.vision.getMMap() # ------------------------------------------------- self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Rovio Camera View") self.subtype = "rovio" self.data = CBuffer(self._cbuf)
def __init__(self, camera, splits, quad, rot = 0): """ Can split a camera 2 or 4 ways. """ self._camera = camera self._splits = splits self._quad = quad self._dev = Fourway( self._camera._dev, splits, quad, rot) self.vision = VisionSystem() self._dev.setRGB(camera.rgb[0], camera.rgb[1], camera.rgb[2]) self.rgb = camera.rgb self.format = camera.format self.vision.registerCameraDevice(self._dev) self._cbuf = self.vision.getMMap() ## ------------------------------------------------- Camera.__init__(self, self._dev.getWidth(), self._dev.getHeight(), self._dev.getDepth(), "Quad #%d" % quad) self.data = CBuffer(self._cbuf)
def __init__(self, leftcamera, rightcamera): """ Stereo Vision. """ self._leftcamera = leftcamera self._rightcamera = rightcamera self._dev = Stereo(self._leftcamera._dev, self._rightcamera._dev) self.vision = VisionSystem() self._dev.setRGB(leftcamera.rgb[0], leftcamera.rgb[1], leftcamera.rgb[2]) self.rgb = leftcamera.rgb self.format = leftcamera.format self.vision.registerCameraDevice(self._dev) self._cbuf = self.vision.getMMap() ## ------------------------------------------------- Camera.__init__(self, self._dev.getWidth(), self._dev.getHeight(), self._dev.getDepth(), "Stereo Camera") self.data = CBuffer(self._cbuf)
def __init__(self, width, height, depth=3, device='/dev/bt848fg0', title=None, visionSystem=None): """ Device should be the name of the capture device in the /dev directory. This is highly machine- and configuration-dependent, so make sure you know what works on your system """ if width < 48: raise ValueError("width must be greater than 48") if height < 48: raise ValueError("height must be greater than 48") self.deviceFile = device self.handle = None self._cbuf = None try: self._dev = BT848(device, width, height, depth) self._dev.setRGB(2, 1, 0) except: print("bt848: grab_image failed!") # connect vision system: -------------------------- self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() # ------------------------------------------------- if title == None: title = self.deviceFile self.rgb = (2, 1, 0) # offsets to BGR self.format = "BGR" Camera.__init__(self, width, height, depth, title=title) self.subtype = "bt848" self.source = device self.data = CBuffer(self._cbuf)
def __init__(self, pattern=None, start=0, stop=19, char="?", interval=1.0, visionSystem=None, verbose=0): """ pattern is a filename with indicators on where to put digits for the sequence. Absolute or relative filenames can be used. For example, 'image???-.ppm' would start at 'image000.ppm' and continue up to stop. char is the character that should be replaced in the pattern. interval = how often do I get new image As an example, to load som-0.ppm through som-19.ppm, we could call FakeCamera('vision/snaps/som-?.ppm', 0, 19) """ if pattern == None: pattern = "vision/snaps/som-?.ppm" self.pattern = pattern self.stop = stop self.start = start self.current = start self.setUpdateInterval(interval) self.verbose = verbose self.lastUpdate = 0 #create a matchdata object that we will store self.match = re.search(re.escape(char) + "+", pattern) #create a format string that we can use to replace the #replace characters if self.match: self.fstring = "%%0%dd" % len(self.match.group()) currname = self.pattern[:self.match.start()] + \ self.fstring % self.current + \ self.pattern[self.match.end():] else: currname = self.pattern if system.file_exists(currname): self.path = '' elif system.file_exists(os.getenv('PYROBOT') + "/" + currname): self.path = os.getenv('PYROBOT') + "/" else: raise ValueError("file not found: '%s'" % currname) if self.verbose: print("info: reading file '%s'..." % (self.path + currname)) self._dev = Fake(self.path + currname) # connect vision system: -------------------------- if visionSystem: self.vision = visionSystem self.vision.registerCameraDevice(self._dev) self.width = self.vision.getWidth() self.height = self.vision.getHeight() self.depth = self.vision.getDepth() self._cbuf = self.vision.getMMap() else: self.vision = None self.width = 0 self.height = 0 self.depth = 0 self._cbuf = None # ------------------------------------------------- self.rgb = (0, 1, 2) # offsets to RGB self.format = "RGB" Camera.__init__(self, self.width, self.height, self.depth, "Fake Camera View") self.subtype = "simulated" self.source = self.pattern self.data = CBuffer(self._cbuf) self.oldStart = None self.oldStop = None