def __init__(self, processFunction = None, forceOpenCv = False, displaySurface=None, show=True, **argd): self.__dict__.update(**argd) super(VideoCapturePlayer, self).__init__(**argd) logging.debug("Initializing Video Capture Class") self.processFunction = processFunction self.processRuns = 0 self.show = show self.display = displaySurface if self.display is None: if show is True: # create a display surface. standard pygame stuff self.display = pygame.display.set_mode( self.size, 0 ) else: pygame.display.init() #pygame.display.set_mode((0,0),0) self.display = pygame.surface.Surface(self.size) if forceOpenCv: import camera else: import pygame.camera as camera camera.init() # gets a list of available cameras. self.clist = camera.list_cameras() if not self.clist: raise ValueError("Sorry, no cameras detected.") logging.info("Opening device %s, with video size (%s,%s)" % (self.clist[0],self.size[0],self.size[1])) # creates the camera of the specified size and in RGB colorspace if not forceOpenCv: try: self.camera = camera.Camera(self.clist[0], self.size, "RGB") # starts the camera self.camera.start() except: logging.debug("Ignoring that pygame camera failed - we will try opencv") forceOpenCv = True del camera import camera self.clist = camera.list_cameras() if forceOpenCv: logging.debug("Trying to open the OpenCV wrapped camera") self.camera = camera.Camera(self.clist[0], self.size, "RGB", imageType="pygame") self.camera.start() logging.info("Waiting for camera...") self.waitForCam() logging.info("Camera ready.") self.clock = pygame.time.Clock() self.processClock = pygame.time.Clock() # create a surface to capture to. for performance purposes, you want the # bit depth to be the same as that of the display surface. self.snapshot = pygame.surface.Surface(self.size, 0, self.display)
def __init__(self, processFunction=None, forceOpenCv=False, displaySurface=None, show=True, **argd): self.__dict__.update(**argd) super(VideoCapturePlayer, self).__init__(**argd) logging.debug("Initializing Video Capture Class") self.processFunction = processFunction self.processRuns = 0 self.show = show self.display = displaySurface if self.display is None: if show is True: # create a display surface. standard pygame stuff self.display = pygame.display.set_mode(self.size, 0) else: pygame.display.init() #pygame.display.set_mode((0,0),0) self.display = pygame.surface.Surface(self.size) if forceOpenCv: import camera else: import pygame.camera as camera camera.init() # gets a list of available cameras. self.clist = camera.list_cameras() if not self.clist: raise ValueError("Sorry, no cameras detected.") logging.info("Opening device %s, with video size (%s,%s)" % (self.clist[0], self.size[0], self.size[1])) # creates the camera of the specified size and in RGB colorspace if not forceOpenCv: try: self.camera = camera.Camera(self.clist[0], self.size, "RGB") # starts the camera self.camera.start() except: logging.debug( "Ignoring that pygame camera failed - we will try opencv") forceOpenCv = True del camera import camera self.clist = camera.list_cameras() if forceOpenCv: logging.debug("Trying to open the OpenCV wrapped camera") self.camera = camera.Camera(self.clist[0], self.size, "RGB", imageType="pygame") self.camera.start() logging.info("Waiting for camera...") self.waitForCam() logging.info("Camera ready.") self.clock = pygame.time.Clock() self.processClock = pygame.time.Clock() # create a surface to capture to. for performance purposes, you want the # bit depth to be the same as that of the display surface. self.snapshot = pygame.surface.Surface(self.size, 0, self.display)
#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW #log# opts = Struct({'__allownew': True, 'logfile': 'ipython-logs/VidCapTest.py'}) #log# args = [] #log# It is safe to make manual edits below here. #log#----------------------------------------------------------------------- _ip.system("ls -F ") _ip.magic("pwd ") import camera cam = camera.Camera('pygame') im = cam.get_image() camera.list_cameras() camera.size #?camera.list_cameras camera.list_cameras() im = cam.get_image() #?im = cam.get_image? #?cam.get_image? cam.imageType cam.imageType == "pygame" a = camera.hg.cvQueryFrame(cam.capture) a #?a a = camera.hg.cvQueryFrame(cam.capture) cam.capture #?cam.capture cam = camera.Camera('pygame') cam a = [2] a.si len(a)