Skip to content

Instantly share code, notes, and snippets.

@bhive01
Created January 23, 2017 23:46
Show Gist options
  • Select an option

  • Save bhive01/efdbb90eb844b7754f6c3afda2e2303b to your computer and use it in GitHub Desktop.

Select an option

Save bhive01/efdbb90eb844b7754f6c3afda2e2303b to your computer and use it in GitHub Desktop.
import os, sys # for deleting file
import subprocess # for sending file via SCP back to unit
import argparse #needed for getting filename from script run
# for taking the image
from time import sleep
from picamera import PiCamera
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-l", "--location", required=True,
help="name of image to be saved")
args = ap.parse_args()
#Setup Camera
camera = PiCamera()
camera.rotation = 90
#take image
camera.start_preview()
sleep(0.5) # time for camera to move and warmup
camera.capture("IRphoto.jpg")
camera.stop_preview()
#send image to other Pi
subprocess.Popen(['scp', "IRphoto.jpg", 'pi@pirgb.local:'+args.location])
# can't delete until this is sent, put in sleep
sleep(1.5)
## if file exists, delete it ##
if os.path.isfile("IRphoto.jpg"):
print("File exists.")
#os.remove("IRphoto.jpg")
else: ## Show an error ##
print("Error: %s file not found" % "IRphoto.jpg")
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment