-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (40 loc) · 945 Bytes
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import cv2
import numpy as np
import pyzbar.pyzbar as pyzbar
import sys
import time
import pybase64
# Start web cam
cap = cv2.VideoCapture(0)
names =[]
# function for attendence file
fob=open('attendence.txt', 'a+')
def enterData(z):
if z in names:
pass
else:
names.append(z)
z=''.join(str(z))
fob.write(z+'\n')
return names
print('Reading code.........')
# function data present or not
def checkData(data):
data = str(data)
if data in names:
print('Already present')
else:
print('\n'+str(len(names)+1)+ '\n'+'Present done')
enterData(data)
while True:
_,frame = cap.read()
decodedObject = pyzbar.decode(frame)
for obj in decodedObject:
checkData(obj.data)
time.sleep(1)
cv2.imshow('Frame',frame)
# close
if cv2.waitKey(1)& 0xFF==ord('s'):
cv2.destroyAllWindows()
break
fob.close()