-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelapse.py
66 lines (55 loc) · 1.89 KB
/
timelapse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
import time
import picamera
from datetime import datetime
import os, errno
STARTHOUR = 14 # 0 - 23
ENDHOUR = 18 # 0 - 23
INTERVAL = 12 # Seconds
HFLIP = True
VFLIP = True
QUALITY = 22
THUMBNAILS = True
rotateCmd = ""
INVHOURS = False
thCmd = " -th none "
d = datetime.now()
HERE = os.path.abspath(os.path.dirname(__file__))
imagesFolder = HERE + '/Series/{}'.format(d.strftime('%d%m%Y'))
try:
os.makedirs(imagesFolder)
print "Created new directory: {}".format(imagesFolder)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(imagesFolder):
print "Error: Can\'t create directory. Folder: {} already exits?".format(imagesFolder)
'''
try:
os.mkdir(imagesFolder)
print('Created new folder ' + imagesFolder)
except:
print "Error: Can\'t create directory. Folder: {} already exits?".format(imagesFolder)
'''
print 'Start time: {}, End time: {}, Interval: {} seconds'.format(STARTHOUR, ENDHOUR, INTERVAL)
if (STARTHOUR > ENDHOUR):
STARTHOUR, ENDHOUR, INVHOURS = ENDHOUR, STARTHOUR, True
while True:
d = datetime.now()
if (INVHOURS ^ (d.hour >= STARTHOUR and d.hour < ENDHOUR) and not d.second % INTERVAL):
fileName = '{}/IMG{}.jpg'.format(imagesFolder, d.strftime('%d%H%M%S'))
with picamera.PiCamera() as camera:
camera.resolution = (1920, 1080)
camera.hflip, camera.vflip = HFLIP, VFLIP
camera.sharpness = 20
camera.contrast = 0
camera.brightness = 50
#camera.saturation = 0
#camera.ISO = 0
camera.video_stabilization = False
#camera.exposure_compensation = 0
camera.exposure_mode = 'auto'
camera.meter_mode = 'average'
camera.awb_mode = 'auto'
camera.image_effect = 'none'
camera.color_effects = None
camera.capture(fileName)
print 'Image created: {}'.format(fileName)