Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrobinson-uk/97ee91e86c38dae0056eeb507231d883 to your computer and use it in GitHub Desktop.
Save jrobinson-uk/97ee91e86c38dae0056eeb507231d883 to your computer and use it in GitHub Desktop.
import zbar
import picamera
import io
width = 640
height = 480
raw_data = io.BytesIO()
scanner = zbar.ImageScanner()
scanner.parse_config('enable')
with picamera.PiCamera() as camera:
camera.resolution = (width, height)
camera.raw_format = 'yuv'
while True:
camera.capture(raw_data, 'raw')
raw_data.seek(0)
image = zbar.Image(width, height, 'Y800',
raw_data.getvalue()[0:width*height])
scanner.scan(image)
for symbol in image:
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment