-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
45 lines (34 loc) · 1.32 KB
/
app.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
import edgeiq
import time
def main():
fps = edgeiq.FPS()
qrcode_scanner = edgeiq.QRCodeDetection()
try:
with edgeiq.WebcamVideoStream(cam=0) as video_stream, \
edgeiq.Streamer() as streamer:
# Allow Webcam to warm up
time.sleep(2.0)
fps.start()
# loop detection
while True:
frame = video_stream.read()
# Generate text to display on streamer
streamer_text = ["QR Code Scanner"]
# Localize and Decode the QR Code(s) if present in frame
results = qrcode_scanner.localize_decode(frame)
# Draw the box around localized QR Code(s)
image = results.markup_image()
# Display decoded information from QR Code(s) on streamer
for prediction in results.predictions:
streamer_text.append(prediction.info)
streamer.send_data(image, streamer_text)
fps.update()
if streamer.check_exit():
break
finally:
fps.stop()
print("elapsed time: {:.2f}".format(fps.get_elapsed_seconds()))
print("approx. FPS: {:.2f}".format(fps.compute_fps()))
print("Program Ending")
if __name__ == "__main__":
main()