Browse Source

Add scp and pic taking to cam

master
lheimbs 4 years ago
parent
commit
50be58e0c8
1 changed files with 33 additions and 8 deletions
  1. 33
    8
      camera/camera.py

+ 33
- 8
camera/camera.py View File

#!/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"
GPIO.output(IR_PIN, GPIO.LOW)
time.sleep(20)
print "Gpio High"
print("Gpio Low")
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…
Cancel
Save