Initial commit
This commit is contained in:
commit
8bde43bd49
152 changed files with 5294 additions and 0 deletions
33
client/qr_scan.py
Normal file
33
client/qr_scan.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
|
||||
|
||||
def decoder(image):
|
||||
gray_img = cv2.cvtColor(image,0)
|
||||
barcode = decode(gray_img)
|
||||
|
||||
for obj in barcode:
|
||||
points = obj.polygon
|
||||
(x,y,w,h) = obj.rect
|
||||
pts = np.array(points, np.int32)
|
||||
pts = pts.reshape((-1, 1, 2))
|
||||
cv2.polylines(image, [pts], True, (0, 255, 0), 3)
|
||||
|
||||
barcodeData = obj.data.decode("utf-8")
|
||||
barcodeType = obj.type
|
||||
string = "Data " + str(barcodeData) + " | Type " + str(barcodeType)
|
||||
|
||||
cv2.putText(frame, string, (x,y), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,0,0), 2)
|
||||
print("Barcode: "+barcodeData +" | Type: "+barcodeType)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cap = cv2.VideoCapture(0)
|
||||
while True:
|
||||
ret, frame = cap.read()
|
||||
decoder(frame)
|
||||
cv2.imshow('Image', frame)
|
||||
code = cv2.waitKey(10)
|
||||
if code == ord('q'):
|
||||
break
|
||||
Loading…
Add table
Add a link
Reference in a new issue