From 50be58e0c84834f5259d007754d234bac3f497c8 Mon Sep 17 00:00:00 2001 From: lheimbs Date: Mon, 24 Jun 2019 13:36:07 +0200 Subject: [PATCH] Add scp and pic taking to cam --- camera/camera.py | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/camera/camera.py b/camera/camera.py index bcbe658..128ce9f 100755 --- a/camera/camera.py +++ b/camera/camera.py @@ -1,22 +1,47 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 -import time +import time, subprocess import RPi.GPIO as GPIO +from SCP import scp + IR_PIN = 3 GPIO.setmode(GPIO.BOARD) GPIO.setup(IR_PIN, GPIO.OUT) +i = 0 try: while True: - print "Gpio Low" - GPIO.output(IR_PIN, GPIO.LOW) - time.sleep(20) - print "Gpio High" + print("Gpio Low") GPIO.output(IR_PIN, GPIO.HIGH) - time.sleep(20) + time.sleep(2) + + # take image and scp it to the other pi + print("take image...") + subprocess.run(['raspistill', '-o', 'images/image' + str(i) + '.jpg']) + + print("transfer image") + #scp('images/image' + str(i) + '.jpg', '~/image' + str(i) + '.jpg', '192.168.252.1', 'pi', 'smarthome') + + i+=1 + + if i>10: + break + #print("Gpio High") + #GPIO.output(IR_PIN, GPIO.HIGH) + #time.sleep(2) + + # take image and scp it to the other pi + #print("take image...") + #subprocess.run(['raspistill', '-o', 'image2.jpg']) + + #print("transfer image") + #scp('image2.jpg', '~/image2.jpg', '192.168.252.1', 'pi', 'smarthome') + + #break + except Exception as e: - print e + print(e) finally: GPIO.cleanup()