Add scp and pic taking to cam
This commit is contained in:
parent
fe71e3400a
commit
50be58e0c8
@ -1,22 +1,47 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import time
|
import time, subprocess
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
|
from SCP import scp
|
||||||
|
|
||||||
IR_PIN = 3
|
IR_PIN = 3
|
||||||
|
|
||||||
GPIO.setmode(GPIO.BOARD)
|
GPIO.setmode(GPIO.BOARD)
|
||||||
GPIO.setup(IR_PIN, GPIO.OUT)
|
GPIO.setup(IR_PIN, GPIO.OUT)
|
||||||
|
|
||||||
|
i = 0
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
print "Gpio Low"
|
print("Gpio Low")
|
||||||
GPIO.output(IR_PIN, GPIO.LOW)
|
|
||||||
time.sleep(20)
|
|
||||||
print "Gpio High"
|
|
||||||
GPIO.output(IR_PIN, GPIO.HIGH)
|
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:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
finally:
|
finally:
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user