GithubHelp home page GithubHelp logo

5l1v3r1 / zbarlight Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polyconseil/zbarlight

0.0 1.0 0.0 106 KB

A simple wrapper for zbar

License: BSD 3-Clause "New" or "Revised" License

Python 61.37% C 33.90% Makefile 4.73%

zbarlight's Introduction

ZbarLight

zbarlight is a simple wrapper for the zbar library. For now, it can read all zbar supported codes. Contributions, suggestions and pull requests are welcome.

zbarlight is hosted on Github at <https://github.com/Polyconseil/zbarlight/>.

Installation

You need to install ZBar Bar Code Reader <http://zbar.sourceforge.net/> and its headers before installing zbarlight.

On Debian

$ apt-get install libzbar0 libzbar-dev
$ pip install zbarlight  # you can also use setuptools directly

On Mac OS X

$ brew install zbar
$ export LDFLAGS="-L$(brew --prefix zbar)/lib"
$ export CFLAGS="-I$(brew --prefix zbar)/include"
$ pip install zbarlight

On Windows

Instruction can be found on <https://gist.github.com/Zephor5/aea563808d80f488310869b69661f330>.

How To use ZbarLight

from PIL import Image
import zbarlight

file_path = './tests/fixtures/two_qr_codes.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()

codes = zbarlight.scan_codes(['qrcode'], image)
print('QR codes: %s' % codes)

Troubleshooting

In some case zbarlight will not be able to detect the 1D or 2D code in an image, one of the known cause is that the image background color is the same as the foreground color after conversion to grey scale (it's happen on images with alpha channel). You can use the copy_image_on_background function to add a background color on your image.

from PIL import Image
import zbarlight

file_path = './tests/fixtures/two_qr_codes.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()

new_image = zbarlight.copy_image_on_background(image, color=zbarlight.WHITE)  # <<<<<<<<<<<<<<<< Add this line <<<<
codes = zbarlight.scan_codes(['qrcode'], new_image)
print('QR codes: %s' % codes)

Some other cases without known solutions are show in the scan_codes() tests (search for the expected failures). Any clues on these cases is welcome.

zbarlight's People

Contributors

dbaty avatar fbochu avatar zephor5 avatar zhangxinnan avatar

Watchers

 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.