-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbarcode.py
More file actions
22 lines (19 loc) · 676 Bytes
/
barcode.py
File metadata and controls
22 lines (19 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import cv2 as cv
import numpy as np
from pyzbar.pyzbar import decode
cap = cv.VideoCapture(0)
while True:
_,frame = cap.read()
for barcode in decode(frame):
print(barcode.data.decode('utf-8'))
Data = barcode.data.decode('utf-8')
pts = np.array([barcode.polygon],np.int32)
pts = pts.reshape((1,-1,2))
cv.polylines(frame,[pts],True,(0,255,0),3)
pts2 = barcode.rect
cv.putText(frame,Data,(pts2[0],pts2[1]),cv.FONT_HERSHEY_COMPLEX_SMALL,0.9,(255,0,255),2)
cv.imshow("Frame",frame)
if cv.waitKey(1) & 0xFF == 27: # Press Escape Key to close all windows
break
cap.release()
cv.destroyAllWindows()