-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsinglecameragpstag.py
More file actions
48 lines (34 loc) · 984 Bytes
/
singlecameragpstag.py
File metadata and controls
48 lines (34 loc) · 984 Bytes
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
# Import modules to work with GPS unit and also the picamera
import gps
import picamera
import time
# setup GPS
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
lat = 0;
long = 0;
# see if we have a GPS fix
# if not then exit
# if we do (mode 2/3) then record the location for the image
while True:
report = session.next()
if report['class']== 'TPV':
print report
if hasattr(report,'mode'):
if report.mode !=1:
# record location
print "Has Fix"
lat = report.lat
long = report.lon
t = time.time()
# Take Image and store with filename using lat and long
filename= "img" + str(lat) + "-" + str(long) + "-" + str(t) + ".jpg"
with picamera.PiCamera() as camera:
camera.resolution = (2592,1944)
camera.start_preview()
time.sleep(2)
camera.capture(filename)
else:
print "No Fix"
# take image
# save image with GPS location in filename