44 lines
1.4 KiB
Python
Executable File
44 lines
1.4 KiB
Python
Executable File
#!/usr/bin/python3
|
|
################################################################################
|
|
# Authors: Fred (support@qo-op.com) + Mark
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
import cv2
|
|
import os
|
|
import time
|
|
import subprocess
|
|
import numpy as np
|
|
from pyzbar import pyzbar
|
|
|
|
print("\n [INFO] STARTING VIDEO CAPTURE \n")
|
|
faceCascade = cv2.CascadeClassifier('./haarcascade_frontalface_default.xml')
|
|
|
|
cap = cv2.VideoCapture(0)
|
|
|
|
while 1:
|
|
ret, img = cap.read()
|
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
time.sleep(1)
|
|
# find the barcodes in the image and decode each of the barcodes
|
|
barcodes = pyzbar.decode(img)
|
|
# loop over the detected barcodes
|
|
for barcode in barcodes:
|
|
(x, y, w, h) = barcode.rect
|
|
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
|
|
barcodeData = barcode.data.decode("utf-8")
|
|
barcodeType = barcode.type
|
|
text = "{} ({})".format(barcodeData, barcodeType)
|
|
print("QRcode: %s"%(text))
|
|
|
|
# Filename to append
|
|
filename = "/tmp/qrcode.scan"
|
|
myfile = open(filename, 'a')
|
|
myfile.write("%s\n"%(text))
|
|
myfile.close()
|
|
|
|
# do a bit of cleanup
|
|
print("\n [INFO] Exiting Program and cleanup stuff \n")
|
|
cap.release()
|
|
cv2.destroyAllWindows()
|