-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestQRCodeDetection.py
39 lines (32 loc) · 1.1 KB
/
TestQRCodeDetection.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
import CameraController
import cv2
import numpy as np
import QRCodeDetector
import Logger
import sys
logger = Logger.Logger(Logger.LogLevel.DISPLAY)
camera = CameraController.CameraController(loglevel=logger)
qrCodeDetector = QRCodeDetector.QRCodeDetector(isRaspberryPI=False, loglevel=logger)
while(True):
while (camera.last_frame is None):
continue
copy = camera.last_frame.copy()
data,x,y,w,h = qrCodeDetector.Decode(copy)
cv2.rectangle(copy,(x,y),(x+w,y+h),(255,0,0),5)
if len(data)>0:
cv2.putText(copy,"Decoded Data : {}".format(data), (10, 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 255, 0), 1)
logger.log("Decoded Data : {}".format(data))
else:
cv2.putText(copy,"QR Code not detected", (10, 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, (255, 0, 255), 1)
logger.log("QR Code not detected")
cv2.imshow('frame', copy)
# the 'q' button is set as the
# quitting button you may use any
# desired button of your choice
if cv2.waitKey(1) & 0xFF == ord('q'):
break
camera.stop()
cv2.destroyAllWindows()
sys.exit()