Created
December 21, 2017 16:28
-
-
Save Peotus/a0080ef598b06c955523cb6ea2b72dd5 to your computer and use it in GitHub Desktop.
Infinite timelapse python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from goprohero import GoProHero | |
import urllib | |
import urllib2 | |
import json | |
import time | |
import calendar | |
camera = GoProHero(password='') | |
# status = camera.status() | |
# http://10.5.5.9:8080/videos/DCIM/100GOPRO/ | |
testfile = urllib.URLopener() | |
mymin= 51590 | |
folder = 103 | |
returns = [36300,0] | |
def fn_capture(mymin, folder): | |
init= int(round(time.time() * 1000)) | |
print("http://10.5.5.9:8080/videos/DCIM/"+str(folder)+"GOPRO/G00"+str(mymin)+".JPG") | |
testfile.retrieve("http://10.5.5.9:8080/videos/DCIM/"+str(folder)+"GOPRO/G00"+str(mymin)+".JPG", "images/infinite/G00"+str(mymin)+".JPG") | |
# delete http://10.5.5.9/gp/gpControl/command/storage/delete?p=file | |
time.sleep(.4) | |
urllib2.urlopen('http://10.5.5.9/gp/gpControl/command/storage/delete?p=/'+str(folder)+'GOPRO/G00'+str(mymin)+'.JPG').read() | |
print str(mymin) | |
return float(int(round(time.time() * 1000))-init) | |
def fn_init(): | |
camera = GoProHero(password='') | |
camera.command("record", "on") #start recording | |
urllib2.urlopen('http://10.5.5.9/gp/gpControl/command/shutter?p=0').read() | |
time.sleep(.4) | |
response = urllib2.urlopen("http://10.5.5.9:8080/gp/gpMediaList") | |
json_response = json.loads(response.read()) | |
return(json_response['media'][0]['fs'][0]['n']) | |
urllib2.urlopen('http://10.5.5.9/gp/gpControl/command/storage/delete/all').read() # clean the camera | |
mymin = int(fn_init().split(".")[0].split("G00")[1]) | |
print(mymin) | |
time.sleep(.4) | |
# urllib2.urlopen('http://10.5.5.9/gp/gpControl/command/storage/delete/all').read() | |
camera.command("record", "on") | |
time.sleep(2) | |
mymin+=10000 | |
while True: | |
mymin +=1 | |
if mymin%10000==0: | |
folder+=1 | |
mymin+=1 | |
elapsed= fn_capture(mymin, folder) | |
print("Captured") | |
time.sleep(10-elapsed/1000.0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment