def onInit(self): self.curFrame = 0 avg.logger.info("Creating camera:") avg.logger.info("driver=%(driver)s device=%(device)s" % self.optdict) avg.logger.info( "width=%(width)d height=%(height)d pixelformat=%(pixelFormat)s" % self.optdict) avg.logger.info( "unit=%(unit)d framerate=%(framerate)d fw800=%(fw800)s" % self.optdict) self.canvas = player.createCanvas(id="canvas", size=self.size) self.camNode = avg.CameraNode(driver=self.optdict["driver"], device=self.optdict["device"], unit=self.optdict["unit"], fw800=self.optdict["fw800"], framerate=self.optdict["framerate"], capturewidth=self.optdict["width"], captureheight=self.optdict["height"], pixelformat=self.optdict["pixelFormat"], parent=self.canvas.getRootNode()) if not self.optdict["noinfo"]: self.infoText = ( "Driver=%(driver)s (dev=%(device)s unit=%(unit)d) " "%(width)dx%(height)d@%(framerate)f" % self.optdict) avg.WordsNode(text=self.infoText, color="ff3333", pos=(5, 5), fontsize=14, rawtextmode=True, parent=self.canvas.getRootNode()) self.frameText = avg.WordsNode(color="ff3333", pos=(5, 25), fontsize=14, parent=self.canvas.getRootNode()) else: self.frameText = None self.canvasImage = avg.ImageNode(href="canvas:canvas", size=self.size, parent=self) if self.capture: self.videoWriter = avg.VideoWriter(self.canvas, "camera.mov", 60, 3, 5, True) self.setupKeys() self.camNode.play() player.setTimeout(100, self.checkCamera)
def onInit(self): avg.RectNode(size=(self.__optWidth, self.__optHeight), fillcolor="FF0000", fillopacity=1, strokewidth=0, parent=self) self.__camNode = avg.CameraNode(capturewidth=self.__optWidth, captureheight=self.__optHeight, width=self.__optWidth, height=self.__optHeight, parent=self, **self.__optsCam) self.__camNode.play() self.__filter = avg.ChromaKeyFXNode() self.__camNode.setEffect(self.__filter) self.__filter.color = "0000FF" self.__filter.htolerance = 0.05 self.__filter.stolerance = 1.0 self.__filter.ltolerance = 1.0 self.__filter.softness = 0.0 self.__createGUI()