Skip to content

Instantly share code, notes, and snippets.

@dmpop
Created July 31, 2015 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmpop/6d39f3d64a36abbbb7ba to your computer and use it in GitHub Desktop.
Save dmpop/6d39f3d64a36abbbb7ba to your computer and use it in GitHub Desktop.
SL4A-based Python script for timelapse photography
import android, time, os
droid = android.Android()
counter = 1
title = "Number of Photos"
droid.dialogCreateAlert(title)
photoCount = int(droid.dialogGetInput("Specify number of photos to take:").result)
title = "Time interval"
droid.dialogCreateAlert(title)
interval = int(droid.dialogGetInput("Specify time interval is seconds:").result)
destDir = time.strftime("%Y%m%d-%H%M%S", time.localtime())
os.system("mkdir /sdcard/" + destDir)
droid.dialogDismiss()
while counter <= photoCount:
captureTime = time.strftime("%Y%m%d-%H%M%S", time.localtime())
captureLocation = "/sdcard/"+destDir+"/"+str(captureTime)+".jpg"
print "Picture taken: "+captureLocation
counter = counter + 1
droid.cameraCapturePicture(captureLocation,True)
time.sleep(interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment