-
Notifications
You must be signed in to change notification settings - Fork 0
/
QrCodeProject.py
36 lines (28 loc) · 915 Bytes
/
QrCodeProject.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
import cv2
import numpy as np
from pyzbar.pyzbar import decode
#img = cv2.imread('1.jpg')
cap = cv2.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)
with open('myDataFile.text') as f:
myDataList = f.read().splitlines()
while True:
success, img = cap.read()
for barcode in decode(img):
myData = barcode.data.decode('utf-8')
print(myData)
if myData in myDataList:
myOutput = 'Authorized'
myColor = (0,255,0)
else:
myOutput = 'Un-Authorized'
myColor = (0, 0, 255)
pts = np.array([barcode.polygon],np.int32)
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts],True,myColor,5)
pts2 = barcode.rect
cv2.putText(img,myOutput,(pts2[0],pts2[1]),cv2.FONT_HERSHEY_SIMPLEX,
0.9,myColor,2)
cv2.imshow('Result',img)
cv2.waitKey(1)