def __init__(self): self.camera = GPhoto(subprocess) self.idy = Identify(subprocess) self.netinfo = NetworkInfo(subprocess) self.shot = 0 self.displaySet = False
def main(): #print "Testing Configs" #test_configs() print "Timelapse" camera = GPhoto(subprocess) idy = Identify(subprocess) netinfo = NetworkInfo(subprocess) #ui = TimelapseUi() current_config = 11 ## <-- set this manually because we don't have an LCD to select it shot = 0 prev_acquired = None last_acquired = None last_started = None network_status = netinfo.network_status() #current_config = ui.main(CONFIGS, current_config, network_status) try: while True: last_started = datetime.now() config = CONFIGS[current_config] print "Shot: %d Shutter: %s ISO: %d" % (shot, config[0], config[1]) #ui.backlight_on() #ui.show_status(shot, CONFIGS, current_config) camera.set_shutter_speed(secs=config[0]) camera.set_iso(iso=str(config[1])) #ui.backlight_off() try: filename = camera.capture_image_and_download() except Exception, e: print "Error on capture." + str(e) print "Retrying..." # Occasionally, capture can fail but retries will be successful. continue prev_acquired = last_acquired brightness = float(idy.mean_brightness(filename)) last_acquired = datetime.now() print "-> %s %s" % (filename, brightness) if brightness < MIN_BRIGHTNESS and current_config < len( CONFIGS) - 1: current_config = current_config + 1 elif brightness > MAX_BRIGHTNESS and current_config > 0: current_config = current_config - 1 else: if last_started and last_acquired and last_acquired - last_started < MIN_INTER_SHOT_DELAY_SECONDS: print "Sleeping for %s" % str( MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)) time.sleep((MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)).seconds) shot = shot + 1 except Exception, e: print "Error:", str(e)
def __init__(self): self.LCDAttached = self.checkPanel() # Initialize the LCD using the pins # see https://learn.adafruit.com/adafruit-16x2-character-lcd-plus-keypad-for-raspberry-pi/usage if (self.LCDAttached == True): Adafruit_CharLCDPlate.__init__(self) self.camera = GPhoto(subprocess) self.idy = Identify(subprocess) self.netinfo = NetworkInfo(subprocess) self.shot = 0 self.displaySet = False
def main(): # print "Testing Configs" # test_configs() print "Timelapse" camera = GPhoto(subprocess) idy = Identify(subprocess) netinfo = NetworkInfo(subprocess) persist = Persist() #ui = TimelapseUi() initVal = 14 current_config = persist.readLastConfig(initVal) shot = 0 prev_acquired = None last_acquired = None last_started = None network_status = netinfo.network_status() #current_config = 0 #ui.main(CONFIGS, current_config, network_status) try: while True: last_started = datetime.now() config = CONFIGS[current_config] print "Shot: %d Shutter: %s ISO: %d" % (shot, config[1], config[3]) #ui.backlight_on() #ui.show_status(shot, CONFIGS, current_config) camera.set_shutter_speed(secs=config[1]) camera.set_iso(iso=str(config[3])) #ui.backlight_off() try: filename = camera.capture_image_and_download() filenameWithCnt = "IMG_{:0>5d}.jpg".format(shot) os.rename(filename, filenameWithCnt) filename = filenameWithCnt except Exception, e: print "Error on capture." + str(e) print "Retrying..." # Occasionally, capture can fail but retries will be successful. continue prev_acquired = last_acquired brightness = float(idy.mean_brightness(filename)) last_acquired = datetime.now() print "-> %s %s" % (filename, brightness) if brightness < MIN_BRIGHTNESS and current_config < len( CONFIGS) - 1: current_config = current_config + 1 persist.writeLastConfig(current_config) elif brightness > MAX_BRIGHTNESS and current_config > 0: current_config = current_config - 1 persist.writeLastConfig(current_config) else: if last_started and last_acquired and last_acquired - last_started < MIN_INTER_SHOT_DELAY_SECONDS: print "Sleeping for %s" % str( MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)) time.sleep((MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)).seconds) shot = shot + 1 except Exception, e: #ui.show_error(str(e)) print str(e)
def main(): #print "Testing Configs" #test_configs() timestr = str(datetime.now()) print "No problem. Timelapse starts now, at " + timestr camera = GPhoto(subprocess) idy = Identify(subprocess) netinfo = NetworkInfo(subprocess) #ui = TimelapseUi() current_config = 28 shot = 0 prev_acquired = None last_acquired = None last_started = None #network_status = netinfo.network_status() #current_config = ui.main(CONFIGS, current_config, network_status) try: while True: last_started = datetime.now() config = CONFIGS[current_config] print "Shot: %d Shutter: %s ISO: %d" % (shot, config[0], config[1]) #ui.backlight_on() #ui.show_status(shot, CONFIGS, current_config) camera.set_shutter_speed(secs=config[0]) camera.set_iso(iso=str(config[1])) #ui.backlight_off() try: filename = camera.capture_image_and_download(shot) print "Capture signaled." except Exception, e: print "Error on capture." + str(e) print "Retrying..." # Occasionally, capture can fail but retries will be successful. continue prev_acquired = last_acquired brightness = float(idy.mean_brightness(filename)) last_acquired = datetime.now() print "-> %s Brightness: %s" % (filename, brightness) if brightness < MIN_BRIGHTNESS and current_config < len( CONFIGS) - 1: current_config = current_config + 1 print "WARNING: Brightness is below threshold " + strMIN_BRIGHTNESS + ", trying a brighter config NOW!" elif brightness > MAX_BRIGHTNESS and current_config > 0: print "WARNING: Brightness is above threshold " + strMAX_BRIGHTNESS + ", trying a darker config NOW!" else: if last_started and last_acquired and last_acquired - last_started < MIN_INTER_SHOT_DELAY_SECONDS: print "Sleeping for %s" % str( MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)) time.sleep((MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)).seconds) shot = shot + 1 except Exception, e: #ui.show_error(str(e)) print(str(e))
def setUp(self): self._test_subprocess = FakeSubprocess() self._network_info = NetworkInfo(self._test_subprocess)