Git Product home page Git Product logo

zbar-py's Introduction

zbar-py

Introduction

Author: Zachary Pincus [email protected]

Contributions: Rounak Singh [email protected] (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')))

zbar-py's People

Contributors

rounaksingh avatar zpincus avatar erikhvatum avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.