Skip to main content

Introduction

Author: Zachary Pincus zpincus@gmail.com

Contributions: Rounak Singh rounaksingh17@gmail.com (example code and zbar.misc).

zbar-py is a module (compatible with both Python 2.7 and 3+) that provides an interface to the zbar bar-code reading library, which can read most barcode formats as well as QR codes. Input images must be 2D numpy arrays of type uint8 (i.e. 2D greyscale images).

The zbar library itself packaged along with zbar-py (it’s built as a python extension), so no external dependencies are required. Building zbar requires the iconv library to be present, which you almost certainly have, except if you’re on windows. Then you probably will need to download or build the iconv DLL. Here are pre-built 32- and 64-bit binaries for same.

The python code is under the MIT license, and zbar itself is licensed under the GNU LGPL version 2.1.

Prerequisites:

  • iconv – c library required for building zbar-py; see above

  • numpy – for running zbar-py

  • pygame – for examples using a webcam

Simple examples:

More sophisticated examples can be found in ‘examples’ directory.

  • Scan for barcodes in a 2D numpy array:

import zbar
image = read_image_into_numpy_array(...) # whatever function you use to read an image file into a numpy array
scanner = zbar.Scanner()
results = scanner.scan(image)
for result in results:
    print(result.type, result.data, result.quality, result.position)
  • Scan for UPC-A barcodes and perform checksum validity test:

import zbar
import zbar.misc
image = read_image_into_numpy_array(...) # get an image into a numpy array
scanner = zbar.Scanner()
results = scanner.scan(image)
for result in results:
    if result.type == 'UPC-A':
        print(result.data, zbar.misc.upca_is_valid(result.data.decode('ascii')))

Release files for zbar-py 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zbar-py 1.0.4
File Size Uploaded
zbar-py-1.0.4.tar.gz 543.9 kB Details

Release files / zbar-py-1.0.4.tar.gz

Download URL zbar-py-1.0.4.tar.gz
Size 543.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8f90fa36480f50109a8555a3e4debed69f70d8085545fd413190ae21a1455466
BLAKE2b-256 checksum
How to use checksums
91ba5f16696d44c69df1d6a890adc60211183d2da90e8de4282d29d1475aba68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.4 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page