def _setupCamera(self): self._cap = gp.Camera() logging.info('Supported operations: %s', self._cap.supported_operations) try: # make sure camera format is not set to raw imgfmt = 'Large Fine JPEG' self._imgfmt = self._cap.config['imgsettings']['imageformat'].value if 'raw' in self._imgfmt.lower(): self._cap.config['imgsettings']['imageformat'].set(imgfmt) self._imgfmtsd = ( self._cap.config['imgsettings']['imageformatsd'].value) if 'raw' in self._imgfmtsd.lower(): self._cap.config['imgsettings']['imageformatsd'].set(imgfmt) # make sure autopoweroff is disabled # this doesn't seem to work # self._autopoweroff = int( # self._cap.config['settings']['autopoweroff'].value) # if self._autopoweroff > 0: # self._cap.config['settings']['autopoweroff'].set("0") except BaseException as e: logging.warn('Error while changing camera settings: {}.'.format(e)) # print current config self._printConfig(self._cap.config)
def __init__(self, photo_directory, tmp_directory, **kwargs): """ :param photobooth: app instance :param kwargs: """ self.cam = gp.Camera() self._photo_directory = photo_directory self._tmp_directory = tmp_directory
def pile(): cam = gp.Camera() # capture preview, because focus can only be adjusted after capturing a preview #cam.get_preview() #cam.capture(to_camera_storage=True) cam.config['actions']['manualfocusdrive'] = 1000
def __init__(self, picture_size, preview_size, zoom=30): if not gphoto_enabled: raise CameraException("No gphoto module") Camera.__init__(self, picture_size, preview_size, zoom, type='dslr') # Print the capabilities of the connected camera try: self.cam = gp.Camera() except gpErrors.UnsupportedDevice as e: raise CameraException("Can not initialize gphoto camera: " + str(e))
def _setupCamera(self): self._cap = gp.Camera() logging.info('Supported operations: %s', self._cap.supported_operations) imageformat = self._cap.config['imgsettings']['imageformat'].value if 'raw' in imageformat.lower(): raise RuntimeError('Camera file format is set to RAW') self._printConfig(self._cap.config)
def __init__(self, interval, path): self.path = path self.interval = interval self.count = 0 self.buttons = buttons.buttons(35, 40, 38) self.display = display.Display() self.web_start = False try: print(gphoto.list_cameras()) self.camera = gphoto.Camera() print(self.camera.supported_operations) self.camera_connected = True except AttributeError: print("Please Connect a Camera")
def __init__(self, interval, path): self.path = path self.interval = interval self.count = 0 self.timelapse_on = False try: print(gphoto.list_cameras()) self.camera = gphoto.Camera() print(self.camera.supported_operations) self.camera_connected = True except AttributeError: print("Please Connect a Camera") except Exception: print("Unknown error")
def __init__(self, picture_size): self.picture_size = picture_size # Print the capabilities of the connected camera try: if gphoto2cffi_enabled: self.cap = gp.Camera() elif piggyphoto_enabled: self.cap = gp.camera() print(self.cap.abilities) else: print(self.call_gphoto("-a", "/dev/null")) except CameraException as e: print('Warning: Listing camera capabilities failed (' + e.message + ')') except gpExcept as e: print('Warning: Listing camera capabilities failed (' + e.message + ')')
def __init__(self, resolution=(10000, 10000), camera_rotate=False): self.resolution = resolution # XXX Not used for gphoto? self.rotate = camera_rotate self.gphoto2cffi_buggy_capture = False # Work around bug in capture()? # Print the capabilities of the connected camera try: if gphoto2cffi_enabled: try: print "Connecting to camera using gphoto2cffi" self.cap = gp.Camera() print(self.cap.status) print(self.cap.supported_operations) except gp.errors.GPhoto2Error as e: print('Error: Could not open camera (' + e.message + ')') print( 'Make sure camera is turned on and plugged in, then restart this program.' ) raise e except gp.errors.UnsupportedDevice as e: print('Error: Could not open camera (' + e.message + ')') print( 'Make sure camera is turned on and plugged in, then restart this program.' ) raise e elif piggyphoto_enabled: print "Connecting to camera using piggyphoto" self.cap = gp.camera() print(self.cap.abilities) else: print "Connecting to camera using command line gphoto2" print(self.call_gphoto("-a")) except CameraException as e: if "not found" in e.message: print( "Could not find the 'gphoto2' command. Try: sudo apt-get install gphoto2" ) exit(1) else: print('Warning: Listing camera capabilities failed (' + e.message + ')') except gpExcept as e: print('Warning: Listing camera capabilities failed (' + e.message + ')')
def __init__(self, picture_size): global fake_enabled self.picture_size = picture_size # Print the capabilities of the connected camera try: if gphoto2cffi_enabled: self.cap = gp.Camera() Logger.success(__name__,"{0} Connected".format(self.cap.model_name) ) elif piggyphoto_enabled: self.cap = gp.camera() print(self.cap.abilities) else: print(self.call_gphoto("-a", "/dev/null")) except CameraException as e: Logger.warning(__name__,"Camera Error, Proceed with Fake Camera Mode...") fake_enabled = True except gpExcept as e: Logger.warning(__name__,"Camera Error, Proceed with Fake Camera Mode...") fake_enabled = True
try: from rtiacquire import camera cap = camera.Camera() t = time() for i in range(frames): (data, length) = cap.preview() t = time() - t print("RTIacquire preview FPS: %f" % (frames / t)) cap.release() except: pass try: import gphoto2cffi cap = gphoto2cffi.Camera() t = time() for i in range(frames): data = cap.get_preview() t = time() - t print("gphoto2cffi preview FPS: %f" % (frames / t)) cap = None except: pass try: import piggyphoto import pygame cap = piggyphoto.camera() t = time() for i in range(frames):
import time import gphoto2cffi as gp gp.list_cameras()[0] cam = gp.Camera() cam._get_config()['actions']['viewfinder'].set(True) for i in range(20): t0 = time.time() pic = cam.get_preview() print(str(int((time.time() - t0) * 100))) #first frame takes 2 seconds cam._get_config()['actions']['viewfinder'].set(False) #also takes 2 seconds cam._get_config()['actions']['eosremoterelease'].set('Press Half') time.sleep(1) cam._get_config()['actions']['eosremoterelease'].set('Release Full') cam._get_config()['actions']['viewfinder'].set(True) time.sleep(1) cam._get_config()['actions']['eosremoterelease'].set('Immediate') cam._get_config()['actions']['eosremoterelease'].set('Release Full') cam._get_config()['actions']['eosremoterelease'].set('Press Half') cam._get_config()['actions']['viewfinder'].set(False) cam._get_config()['actions']['manualfocusdrive'].set('Near 1') #triggers focus (which is bad) cam._get_config()['actions']['autofocusdrive'].set(False)
#!/usr/bin/python # Testing gphoto2cffi fps import gphoto2cffi as gp import pygame from PIL import Image import StringIO # Ugh. PIL wants stdio methods. (Maybe use scipy?) pygame.init() pygame.display.set_caption('CFFItest') screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) i = pygame.display.Info() size = (i.current_w, i.current_h) screen.fill((0, 0, 0)) pygame.display.update() cap = gp.Camera() from time import time t = time() frames = 100 for i in range(frames): jpegstring = cap.get_preview() jpegio = StringIO.StringIO(jpegstring) image = pygame.image.load(jpegio) screen.blit(image, (0, 0)) pygame.display.update() print("\nFPS: %f\n" % (frames / (time() - t)))