Skip to content

Instantly share code, notes, and snippets.

@alevchuk
Created March 9, 2015 03:42
Show Gist options
  • Save alevchuk/a0e8d702b61856a9e604 to your computer and use it in GitHub Desktop.
Save alevchuk/a0e8d702b61856a9e604 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import time
import picamera
#import gps_controller
import datetime
#gpsc = gps_controller.GpsController()
#gpsc.start()
with picamera.PiCamera() as camera:
try:
while True:
camera.start_preview(
fullscreen=False,
window=(1000, 0, 640, 480)
)
#camera.preview.alpha = 168
camera.rotation = 180
#camera.resolution = (1023, 768)
#camera.resolution = (1920, 1080)
#camera.resolution = (2592, 1944)
camera.resolution = (640, 480)
#la = gpsc.fix.latitude
#lo = gpsc.fix.longitude
#speed = gpsc.fix.speed # in meters per second
#mph = speed * 2.23694
#position_error = gpsc.fix.epx * 3.28084
#speed_error = gpsc.fix.eps * 2.23694
la = 1
lo = 1
speed = 1
mph = speed * 2.23694
position_error = 1
speed_error = 2
now = datetime.datetime.now()
date_text = ("%s.%s" % (now.strftime('%Y-%m-%d %H:%M:%S'),
now.strftime('%f')[0:1]))
text = date_text.rjust(38) + \
("%f,%f %.0f mph" % (la, lo, speed)).rjust(38) + \
("+/- %.0f ft" % position_error).rjust(38) + \
("+/- %.0f mph " % speed_error).rjust(38)
camera.annotate_text = text
time.sleep(600000)
camera.stop_preview()
finally:
camera.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment