Skip to content

Instantly share code, notes, and snippets.

@threedaymonk
Created January 14, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save threedaymonk/31855c3aaae6c35ad25401b0183e1259 to your computer and use it in GitHub Desktop.
Save threedaymonk/31855c3aaae6c35ad25401b0183e1259 to your computer and use it in GitHub Desktop.
Python barcode reader example
#!/usr/bin/python3
from imutils.video import VideoStream
from pyzbar.pyzbar import decode
from pprint import pprint
import cv2
import time
vs = VideoStream(src=0).start()
time.sleep(1.0)
cv2.startWindowThread()
cv2.namedWindow("Frame")
while True:
frame = vs.read()
decoded = decode(frame)
for barcode in decoded:
print(barcode.data)
cv2.imshow("Frame", frame)
if frame is None:
break
vs.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment