-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (25 loc) · 907 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
import cv2
import numpy as np
import imutils
from pyzbar import pyzbar
video = cv2.VideoCapture(0) #'http://192.168.0.100:4747/video'
while True:
is_ok, frame = video.read()
if is_ok:
frame = imutils.resize(frame, 400)
qrcodes = pyzbar.decode(frame)
for qrcode in qrcodes:
(x, y, w, h) = qrcode.rect
cv2.rectangle(frame, (x,y), (x+w,y+h), (0, 255, 0), 2)
qrcodedata = qrcode.data.decode("utf-8")
qrcodetype = qrcode.type
text = f"{qrcodedata}"
print(qrcodedata)
cv2.putText(frame, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
cv2.imshow("Registro de Ponto", frame)
k = cv2.waitKey(30) & 0xff #pega a tecla esc
if k == 27: #caso esc for apertado para
break
else:
print("erro ao iniciar captura!")
break;