-
Notifications
You must be signed in to change notification settings - Fork 3
/
qr_decoder.py
45 lines (36 loc) · 913 Bytes
/
qr_decoder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from picamera import PiCamera
from time import sleep
from qrtools import QR
camera = PiCamera()
import RPi.GPIO as GPIO
import time
sensor = 16
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor,GPIO.IN)
print "IR Sensor Ready....."
print " "
try:
while True:
if GPIO.input(sensor):
print "No Ob"
# GPIO.setup(18,GPIO.OUT)
# GPIO.output(18,GPIO.HIGH)
else:
print "Object Detected"
time.sleep(0.2)
camera.start_preview
sleep(1)
camera.capture('/tmp/picture.jpg')
camera.stop_preview
my_QR=QR(filename="/tmp/picture.jpg")
my_QR.decode()
print(my_QR.data)
if(my_QR.data=="Room1"):
print "Door Opening"
GPIO.setup(17,GPIO.OUT)
print "LED ON"
GPIO.output(17,GPIO.HIGH)
time.sleep(1)
GPIO.output(17,GPIO.LOW)
except KeyboardInterrupt:
GPIO.cleanup()