-
Notifications
You must be signed in to change notification settings - Fork 0
/
flowerlapse.py
103 lines (80 loc) · 3.66 KB
/
flowerlapse.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from pathlib import Path
from datetime import datetime
import argparse
import cv2
import uuid
from core.test_camera import test_image, test_stream
from core.timelapse import timelapse
from core.summary import summary
PATH = Path().resolve()
now = datetime.now()
day = now.strftime("%d_%m")
uuid = str(uuid.uuid1())
TIMELAPSE_ID = uuid[0:uuid.find('-')]
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--cam_id',
type=int,
default=0,
help='ID of the camera that will be used. Default = 0, integrated webcam is usually 0 and if only one camera is connected the ID is always 0.')
parser.add_argument('--timelapse_id',
type=str,
default=TIMELAPSE_ID,
help='ID that will be used to create a base directory to store images. Defaults to a generated ID.')
parser.add_argument('--sec_between',
type=int,
default=30,
help='Seconds between each image. Default at 30, mutually exclusive with min_between.')
parser.add_argument('--min_between',
type=int,
default=0,
help='Minutes between each image. Defaults to 0 which means OFF, mutually exclusive with sec_between.')
parser.add_argument('--start_hour',
type=int,
default=8,
help='Start taking pictures for the timelapse after 08:00 by default. Int between 0 and 23.')
parser.add_argument('--end_hour',
type=int,
default=22,
help='Stop taking pictures for the timelapse after 24:00 by default. Int between 1 and 24.')
parser.add_argument('--fps',
type=int,
default=30,
help='Frames per second for the timelapse. 24 or 30 is recommended. Default is 30.')
parser.add_argument('--path',
type=str,
default=str(PATH),
help='Base path where all directories will be created. Default is current directory.')
parser.add_argument('--timezone',
type=str,
default='CET',
help='Settable timezone for hour range, default is CET.')
parser.add_argument('--extension',
type=str,
default='jpg',
help='Image extension, can be .jpg, .png or any OpenCV supported format. default is .jpg.')
parser.add_argument('-overlay_off',
default=False,
action='store_true',
help='Option to remove overlay from timelapse. Default is True (on)')
parser.add_argument('-test_image',
default=False,
action='store_true',
help='Test the camera by taking a single image, image will be shown and saved to disk.')
parser.add_argument('-test_stream',
default=False,
action='store_true',
help='Test the camera by displaying a videostream. Handy when placing the camera.')
args = parser.parse_args()
if args.test_image:
print('RUNNING: TEST_IMAGE')
test_image(args)
elif args.test_stream:
print('RUNNING: TEST_STREAM')
print('PRESS Q TO EXIT THE STREAM')
test_stream(args)
else:
summary(args)
timelapse(args)
if __name__ == '__main__':
main()