Example #1
0
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)
Example #2
0
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))
Example #3
0
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)
Example #4
0
def main():
    print "Frizlapse"
    camera = GPhoto(subprocess)
    #idy = Identify(subprocess)
    #netinfo = NetworkInfo(subprocess)
    #network_status = netinfo.network_status()

    shot = 0
    prev_acquired = None
    last_acquired = None
    last_started = None

    
    camera.set_shutter_speed(secs=CONFIG[0])
    camera.set_iso(iso=str(CONFIG[1]))

    try:
        while True:   
            print "Shot n. %d Shutter: %s ISO: %d" % (shot, CONFIG[0], CONFIG[1])

            last_started = datetime.now()        

            try:
              # Capture image
              filename = camera.capture_image_and_download(FOLDERPATH)
            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            
            last_acquired = datetime.now()

            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)
            else:
                print "No need to sleep, we are late %s" % str((last_acquired - last_started) - MIN_INTER_SHOT_DELAY_SECONDS)

            shot = shot + 1
            if shot == SHOTS:
                print "Picture sequence finished! " 
                print "Starting video ...  "
                # FFMPEG stuff
                print "Video %s finished " % str("filename.mp4") 
                break

    except Exception,e:
        print "Exception " + str(e)
Example #5
0
def main():
    print "Timelapse"
    camera = GPhoto(subprocess)
    idy = Identify(subprocess)
    netinfo = NetworkInfo(subprocess)

    ui = TimelapseUi()

    current_config = 11
    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()
            filename = camera.capture_image_and_download()
            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:
        ui.show_error(str(e))
Example #6
0
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)
Example #7
0
def main():
    print "Timelapse starting at %s" % (time.asctime())
    camera = GPhoto(subprocess)
    info = Analyse(subprocess)
    sysinfo = SystemStats(subprocess)

    current_config = 19
    shot = 0
    failures = 0
    prev_acquired = None
    last_acquired = None
    last_started = None

    try:
        while True:
            last_started = datetime.now()
            shot = shot + 1
            config = CONFIGS[current_config]
            print "Shot %d : %s" % (shot, time.asctime())
            print "Shot %d : Shutter: %ss , ISO: %d , Ap: %s" % (shot, config[0], config[1], config[2])
            sys.stdout.flush()

            camera.set_shutter_speed(secs=config[0])
            camera.set_iso(iso=str(config[1]))
            camera.set_aperture(ap=config[2])
            try:
                filename = camera.capture_image_and_download()
            except Exception, e:
                print "Error on capture: " + str(e)
                failures += 1
                if failures > 2:
                    print "3 successive failures: the camera doesn't work!"
                    sys.stdout.flush()
                    break
                print "Retrying..."
                sys.stdout.flush()
                # Occasionally, capture can fail but retries will be successful.
                continue
            failures = 0
            # print "Shot %d Filename: %s" % (shot, filename)
            sys.stdout.flush()

            prev_acquired = last_acquired
            brightness = float(info.mean_brightness("webkamera-tmp.jpg"))
            last_acquired = datetime.now()

            # health = sysinfo.stats()

            print "Shot %d : Brightness: %s " % (shot, brightness)
            sys.stdout.flush()

            if brightness < TARGET_BRIGHTNESS * 0.9 and current_config < len(CONFIGS) - 1:
                if TARGET_BRIGHTNESS - brightness > TARGET_BRIGHTNESS * 0.44 and current_config < len(CONFIGS) - 2:
                    current_config += 2
                    print "Shot %d : EV step: +2/3" % (shot)
                else:
                    current_config += 1
                    print "Shot %d : EV step: +1/3" % (shot)
            elif brightness > TARGET_BRIGHTNESS * 1.1 and current_config > 0:
                if brightness - TARGET_BRIGHTNESS > TARGET_BRIGHTNESS * 0.44 and current_config > 2:
                    current_config -= 2
                    print "Shot %d : EV step: -2/3" % (shot)
                else:
                    current_config -= 1
                    print "Shot %d : EV step: -1/3" % (shot)
            else:
                if last_started and last_acquired and last_acquired - last_started < MIN_INTER_SHOT_DELAY_SECONDS:
                    sleep_for = max((MIN_INTER_SHOT_DELAY_SECONDS - (last_acquired - last_started)).seconds, 0)
                    print "Sleeping for %ss ..." % str(sleep_for)
                    sys.stdout.flush()
                    time.sleep(sleep_for)
    except Exception, e:
        print str(e)
Example #8
0
def main():
    print "Timelapse starting at %s" % (time.asctime())
    camera = GPhoto(subprocess)
    info = Analyse(subprocess)
    sysinfo = SystemStats(subprocess)

    current_config = 19
    shot = 0
    failures = 0
    prev_acquired = None
    last_acquired = None
    last_started = None

    try:
        while True:
            last_started = datetime.now()
            shot = shot + 1
            config = CONFIGS[current_config]
            print "Shot %d : %s" % (shot, time.asctime())
            print "Shot %d : Shutter: %ss , ISO: %d , Ap: %s" % (
                shot, config[0], config[1], config[2])
            sys.stdout.flush()

            camera.set_shutter_speed(secs=config[0])
            camera.set_iso(iso=str(config[1]))
            camera.set_aperture(ap=config[2])
            try:
                filename = camera.capture_image_and_download()
            except Exception, e:
                print "Error on capture: " + str(e)
                failures += 1
                if failures > 2:
                    print "3 successive failures: the camera doesn't work!"
                    sys.stdout.flush()
                    break
                print "Retrying..."
                sys.stdout.flush()
                # Occasionally, capture can fail but retries will be successful.
                continue
            failures = 0
            #print "Shot %d Filename: %s" % (shot, filename)
            sys.stdout.flush()

            prev_acquired = last_acquired
            brightness = float(info.mean_brightness('webkamera-tmp.jpg'))
            last_acquired = datetime.now()

            #health = sysinfo.stats()

            print "Shot %d : Brightness: %s " % (shot, brightness)
            sys.stdout.flush()

            if brightness < TARGET_BRIGHTNESS * 0.9 and current_config < len(
                    CONFIGS) - 1:
                if TARGET_BRIGHTNESS - brightness > TARGET_BRIGHTNESS * 0.44 and current_config < len(
                        CONFIGS) - 2:
                    current_config += 2
                    print "Shot %d : EV step: +2/3" % (shot)
                else:
                    current_config += 1
                    print "Shot %d : EV step: +1/3" % (shot)
            elif brightness > TARGET_BRIGHTNESS * 1.1 and current_config > 0:
                if brightness - TARGET_BRIGHTNESS > TARGET_BRIGHTNESS * 0.44 and current_config > 2:
                    current_config -= 2
                    print "Shot %d : EV step: -2/3" % (shot)
                else:
                    current_config -= 1
                    print "Shot %d : EV step: -1/3" % (shot)
            else:
                if last_started and last_acquired and last_acquired - last_started < MIN_INTER_SHOT_DELAY_SECONDS:
                    sleep_for = max((MIN_INTER_SHOT_DELAY_SECONDS -
                                     (last_acquired - last_started)).seconds,
                                    0)
                    print "Sleeping for %ss ..." % str(sleep_for)
                    sys.stdout.flush()
                    time.sleep(sleep_for)
    except Exception, e:
        print str(e)
Example #9
0
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))