pyzbar
A ctypes-based Python wrapper around the zbar barcode reader.
The zbar wrapper is stuck in Python 2.x-land. The zbarlight wrapper doesn’t provide support for Windows and depends upon Pillow. This ctypes-based wrapper brings zbar to Python 2.7 and to Python 3.4 or greater.
Installation
The zbar DLLs are included with the Windows Python wheels. On other operating systems, you will need to install the zbar shared library.
On Mac OS X:
brew install zbar
On Linux:
sudo apt-get install libzbar0
Install this Python wrapper; use the second form to install dependencies of the command-line scripts:
pip install pyzbar pip install pyzbar[scripts]
Example usage
The decode function accepts instances of PIL.Image.
>>> from pyzbar.pyzbar import decode
>>> from PIL import Image
>>> decode(Image.open('pyzbar/tests/code128.png'))
[Decoded(data=b'Foramenifera', type='CODE128'),
Decoded(data=b'Rana temporaria', type='CODE128')]
It also accepts instances of numpy.ndarray, which might come from loading images using OpenCV.
>>> import cv2
>>> decode(cv2.imread('pyzbar/tests/code128.png'))
[Decoded(data=b'Foramenifera', type='CODE128'),
Decoded(data=b'Rana temporaria', type='CODE128')]
You can also provide a tuple (pixels, width, height), where the image data is eight bits-per-pixel.
>>> image = cv2.imread('pyzbar/tests/code128.png')
>>> height, width = image.shape[:2]
>>> # Considering just the blue channel
>>> decode((image[:, :, 0].astype('uint8').tobytes(), width, height))
[Decoded(data=b'Foramenifera', type='CODE128'),
Decoded(data=b'Rana temporaria', type='CODE128')]
>>> # Converting to greyscale
>>> grey = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
>>> decode((grey.tobytes(), width, height))
[Decoded(data=b'Foramenifera', type='CODE128'),
Decoded(data=b'Rana temporaria', type='CODE128')]
License
pyzbar is distributed under the MIT license (see LICENCE.txt). The zbar shared library is distributed under the GNU Lesser General Public License, version 2.1 (see zbar-LICENCE.txt).
Release files for pyzbar 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyzbar-0.1.0-py2.py3-none-win_amd64.whl | Python 3, Python 2 | none | Windows x86-64 | Details |
| pyzbar-0.1.0-py2.py3-none-win32.whl | Python 2, Python 3 | none | Windows x86-32 | Details |
| pyzbar-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 1.6 MB
Release files / pyzbar-0.1.0-py2.py3-none-win_amd64.whl
| Download URL | pyzbar-0.1.0-py2.py3-none-win_amd64.whl |
|---|---|
| Size | 797.1 kB |
| Tags | Python 2 Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
89034245f748ebdd68a4dee0bd3595b200c7742f8a580875206ffb532806c9f8
|
|
BLAKE2b-256 checksum How to use checksums |
fb9786c5aaacfb434d5b2b22379c00f70547b8257c32af54bba5278e076f22e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyzbar-0.1.0-py2.py3-none-win32.whl
| Download URL | pyzbar-0.1.0-py2.py3-none-win32.whl |
|---|---|
| Size | 829.9 kB |
| Tags | Python 2 Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
94589747620739e3eb04af45e73be2583929080c4c72eea4630a54d5f5d31422
|
|
BLAKE2b-256 checksum How to use checksums |
c47e43d45291b03e1f7b55a5ef703e7893e18853a1ebe1723323b788bfd2f33c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyzbar-0.1.0-py2.py3-none-any.whl
| Download URL | pyzbar-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
66b8a96a1487d4c42b77795e9a56ff5d222fa8e512b603019a344f12c75210d4
|
|
BLAKE2b-256 checksum How to use checksums |
d1e45446112fbd7e787ec55d9e4972f57c2bab85acbb9df89912be6fae73f69a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |