import cv2
from pyzbar import pyzbar
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
frame = cv2.resize(frame, (600, 600))
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(frame, 'Press q to close camera', (15, 25),
font, 0.6, (0, 255, 255), 1)
data = pyzbar.decode(frame)
for xywh in data:
(x, y, w, h) = xywh.rect
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 255), 2)
text = data[0].data.decode('utf-8')
cv2.putText(frame, text, (x, y - 50), font, 0.8, (255, 0, 255), 2)
cv2.imshow("QR code scanner", frame)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Comentários
Enviar um comentário