-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from NaturalHistoryMuseum/feature/27-pyzbar
Feature/27 pyzbar
- Loading branch information
Showing
13 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# v0.1.9 | ||
- #27 Support pyzbar | ||
|
||
# v0.1.8 | ||
- #24 Support pylibdmtx | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
include *.py | ||
include requirements.txt | ||
include requirements.pip | ||
include gouda/tests/test_data/*png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.8' | ||
__version__ = '0.1.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,34 @@ | ||
# This file is not called zbar.py to avoid collision with the zbar package | ||
|
||
import cv2 | ||
|
||
from gouda.barcode import Barcode | ||
from gouda.gouda_error import GoudaError | ||
from gouda.util import debug_print | ||
|
||
from PIL import Image | ||
|
||
try: | ||
import zbar | ||
from pyzbar import pyzbar | ||
except ImportError: | ||
zbar = None | ||
pyzbar = None | ||
|
||
|
||
class ZbarEngine(object): | ||
"""Decode using the zbar library | ||
http://sourceforge.net/projects/zbar/ | ||
https://pypi.python.org/pypi/zbar | ||
https://pypi.python.org/pypi/pyzbar | ||
""" | ||
def __init__(self): | ||
if not self.available(): | ||
raise GoudaError('zbar unavailable') | ||
|
||
@classmethod | ||
def available(cls): | ||
return zbar is not None | ||
return pyzbar is not None | ||
|
||
def decode_file(self, path): | ||
return self(cv2.imread(str(path), cv2.IMREAD_GRAYSCALE)) | ||
return self(Image.open(str(path))) | ||
|
||
def __call__(self, img): | ||
# Decode barcodes in img using zbar | ||
# https://github.com/ZBar/ZBar/blob/master/python/README | ||
# https://github.com/herbyme/zbar/blob/master/python/examples/scan_image.py | ||
scanner = zbar.ImageScanner() | ||
height, width = img.shape[:2] | ||
if 'uint8' != img.dtype or 2 != len(img.shape): | ||
debug_print('Convert to greyscale for zbar') | ||
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | ||
image = zbar.Image(width, height, 'Y800', img.tostring()) | ||
scanner.scan(image) | ||
return [Barcode(str(s.type), unicode(s.data, 'utf8')) for s in image] | ||
# Decode barcodes in img using pyzbar | ||
return [Barcode(r.type, r.data) for r in pyzbar.decode(img)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# TODO How to specify OpenCV? 'cv2>=2.4.8', | ||
pathlib>=1.0.1 | ||
Pillow>=3.2.0 | ||
pylibdmtx==0.1.4 | ||
pyzbar==0.1.2 | ||
numpy>=1.8.2 | ||
|
||
# Packages required for testing | ||
coveralls>=1.1 | ||
nose>=1.3.4 | ||
|
||
# Packages required for distribution | ||
PyInstaller==3.1.1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters