-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.py
More file actions
28 lines (22 loc) · 700 Bytes
/
camera.py
File metadata and controls
28 lines (22 loc) · 700 Bytes
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
import cv2
import qr_reader
def QRscanner():
cam = cv2.VideoCapture(0)
reading_qr = False
# Get the default frame width and height
frame_width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT))
while True:
ret, frame = cam.read()
# Display the captured frame
cv2.imshow('Camera', frame)
decryption = qr_reader.qr(frame)
if decryption:
break
# Press 'q' to exit the loop, just in case button
if cv2.waitKey(1) == ord('q'):
break
# Release the capture and writer objects
cam.release()
cv2.destroyWindow('Camera')
return decryption