/
TryInfrared.py
executable file
·44 lines (35 loc) · 1.13 KB
/
TryInfrared.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
#!/usr/bin/python
import time
import argparse
import subprocess
from mail import sendmail
import picamera
CAMERA_WIDTH=1024
CAMERA_HEIGHT=768
CAMERA_HFLIP=True
CAMERA_VFLIP=True
parser=argparse.ArgumentParser(prog="TryInfrared",prefix_chars='-')
parser.add_argument('-i','--interval',type=int,default=60,help="Photo taking interval in seconds")
parser.add_argument('-r','--remote_host',help="Transmit tracking photo \
to this")
parser.add_argument('-m','--mail',
help="Send pictures to ")
args=parser.parse_args()
topic="Session started @%s"%time.ctime()
try:
while True:
with picamera.PiCamera() as camera:
camera.resolution = (CAMERA_WIDTH, CAMERA_HEIGHT)
camera.hflip = CAMERA_HFLIP
camera.vflip = CAMERA_VFLIP
filename="footageAt%s.png"%(int(time.time()))
camera.capture(filename)
print("Photo saved:%s"%filename)
if args.remote_host is not None:
subprocess.call(['scp',filename,args.remote_host])
if args.mail is not None:
content=time.ctime()
sendmail(args.mail,topic,content,filename)
time.sleep(args.interval)
except KeyboardInterrupt:
pass