Skip to main content

Efficient cffi-based bindings for the zbar QR decoder (Py2, Py3, and PyPy)

Project description

Python cffi-based bindings for zbar (http://zbar.sourceforge.net/) designed to be as efficient as possible.

Python 2, Python 3, and PyPy compatible!

Note: currently a work in progress. Entirely functional and production-ready (see NumPy note), but missing some configuration options.

Installation

$ pip install libzbar-cffi

Examples

>>> import libzbar as zb

# Images can be loaded from PIL images:
>>> from PIL import Image
>>> im = Image.open("test/qr-numeric.png")
>>> zb.Image.from_im(im).scan()
[<Symbol type=ZBAR_QRCODE quality=1 data='12345' locator=[(12, 12), (12, 75), (75, 75), (75, 12)]>]

# And from NumPy arrays. Note: if the array has an 8-bit data type (ex,
# uint8) a pointer to its data will be passed directly into zbar making
# this method very efficient.
>>> import numpy as np
>>> zb.Image.from_np(im.size, np.array(im)).scan()
[<Symbol type=ZBAR_QRCODE quality=1 data='12345' locator=[(12, 12), (12, 75), (75, 75), (75, 12)]>]

NumPy Note

When using the Image.from_np(…) constructor a pointer to the underlying array is passed directly to zbar. The array’s size and dtype are sanity checked, but at the moment the ctypes flags are ignored, so Strange Things might happen if the underyling array isn’t a straight forward uint8_t[size[0] * size[1]].

Additionally, the array should not be changed for the lifecycle of the Image, as this could invalidate the data pointer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libzbar-cffi-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

File details

Details for the file libzbar-cffi-0.1.1.tar.gz.

File metadata

File hashes

Hashes for libzbar-cffi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3e93384c65e9ceca078aebf67f7d8ce98966cd59acbe96a7141d31cf71adc207
MD5 98dba5d3335eb4aebaed4eada9b4fd57
BLAKE2b-256 1a7b6139e90480c09895dcb9940c16af1da00d882b10ba0fff166eddb0894321

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page