-
Notifications
You must be signed in to change notification settings - Fork 1
/
Library_Final.py
224 lines (172 loc) · 6.7 KB
/
Library_Final.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 28 00:42:09 2019
@author: bhaik
"""
from pyzbar import pyzbar
import cv2
from xlwt import Workbook
from datetime import datetime
from datetime import date
wb = Workbook()
sheet1 = wb.add_sheet("Sheet 1")
sheet1.write(0,0, "S. No.")
sheet1.write(0,1, "Roll. No.")
sheet1.write(0,2, "Date")
sheet1.write(0,3, "In Time")
sheet1.write(0,4, "Book S. No.")
sheet1.write(0,5, "Out_Time")
wb.save("Xlib.xls")
count = 1
lis = []
c=True
d=1
while True:
if len(lis) == 0:
cnt = []
today = date.today()
t = datetime.time(datetime.now())
cap = cv2.VideoCapture(0)
#cap = cv2.VideoCapture(1)
while True:
ret,frame = cap.read()
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
cv2.imwrite("123.jpg", frame)
break
cap.release()
cv2.destroyAllWindows()
path = "C:\\Users\\bhaik\\OneDrive\\Desktop\\Vibhav_projects\\Finalised\\Library\\123.jpg"
image = cv2.imread(path)
barcodes = pyzbar.decode(image)
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
text2 = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text2, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
cv2.imwrite("123.jpg", frame)
break
cap.release()
cv2.destroyAllWindows()
path = "C:\\Users\\bhaik\\OneDrive\\Desktop\\Vibhav_projects\\Finalised\\Library\\123.jpg"
image = cv2.imread(path)
barcodes = pyzbar.decode(image)
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
sheet1.write(count,0, count)
sheet1.write(count,1, text2)
sheet1.write(count,2, str(today))
sheet1.write(count,3, str(t))
sheet1.write(count,4, text)
cnt.append(count)
cnt.append(text)
cnt.append(text2)
lis.append(cnt)
print(lis)
print("-------------------------------")
print("You have entered your book")
print("Your Roll No:")
print(text2)
print("Information in Barcodes:")
print(text)
print("-------------------------------")
cv2.imshow("Image", image)
wb.save("Xlib.xls")
cv2.waitKey(0)
cv2.destroyAllWindows()
else:
c=True
cnt = []
today = date.today()
t = datetime.time(datetime.now())
cap = cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
cv2.imwrite("123.jpg", frame)
break
cap.release()
cv2.destroyAllWindows()
path = "C:\\Users\\bhaik\\OneDrive\\Desktop\\Vibhav_projects\\Finalised\\Library\\123.jpg"
image = cv2.imread(path)
barcodes = pyzbar.decode(image)
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
text2 = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text2, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
cv2.imwrite("123.jpg", frame)
break
cap.release()
cv2.destroyAllWindows()
path = "C:\\Users\\bhaik\\OneDrive\\Desktop\\Vibhav_projects\\Finalised\\Library\\123.jpg"
image = cv2.imread(path)
barcodes = pyzbar.decode(image)
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,0.5, (0, 0, 255), 2)
for l in lis:
if text == l[1]:
c = False
remove1 = l
if c == True:
cnt.append(count)
cnt.append(text)
cnt.append(text2)
lis.append(cnt)
sheet1.write(count,0, count)
sheet1.write(count,1, text2)
sheet1.write(count,2, str(today))
sheet1.write(count,3, str(t))
sheet1.write(count,4, text)
print("-------------------------------")
print("you have entered your book")
print("Roll No")
print(text2)
print("Information in Barcodes:")
print(text)
print("you have entered your book")
print("-------------------------------")
wb.save("Xlib.xls")
print(lis)
if c == False:
t1 = datetime.time(datetime.now())
sheet1.write(remove1[0],5, str(t1))
wb.save("Xlib.xls")
print("your_entry_closed_sucessfully")
lis.remove(remove1)
count = count - 1
print(remove1)
print(lis)
count = count + 1