Skip to main content

pylibdmtx

Python Versions PyPI version Travis status Coverage Status

A ctypes-based Python wrapper around the libdmtx datamatrix barcode reader.

The pydmtx wrapper is stuck in Python 2.x-land. This ctypes-based wrapper brings libdmtx to Python 2.7 and to Python 3.4 or greater.

Installation

The libdmtx DLLs are included with the Windows Python wheels. On other operating systems, you will need to install the libdmtx shared library.

On Mac OS X:

brew install libdmtx

On Linux:

sudo apt-get install libdmtx0a

Install this Python wrapper; use the second form to install dependencies of the read_datamatrix command-line script:

pip install pylibdmtx
pip install pylibdmtx[scripts]

Example usage

The decode function accepts instances of PIL.Image.

>>> from pylibdmtx.pylibdmtx import decode
>>> from PIL import Image
>>> decode(Image.open('pylibdmtx/tests/datamatrix.png'))
[Decoded(data='Stegosaurus', rect=Rect(left=5, top=6, width=96, height=95)),
 Decoded(data='Plesiosaurus', rect=Rect(left=298, top=6, width=95, height=95))]

It also accepts instances of numpy.ndarray, which might come from loading images using OpenCV.

>>> import cv2
>>> decode(cv2.imread('pylibdmtx/tests/datamatrix.png'))
[Decoded(data='Stegosaurus', rect=Rect(left=5, top=6, width=96, height=95)),
 Decoded(data='Plesiosaurus', rect=Rect(left=298, top=6, width=95, height=95))]

You can also provide a tuple (pixels, width, height)

>>> image = cv2.imread('pylibdmtx/tests/datamatrix.png')
>>> height, width = image.shape[:2]
>>> decode((image.tobytes(), width, height))
[Decoded(data='Stegosaurus', rect=Rect(left=5, top=6, width=96, height=95)),
 Decoded(data='Plesiosaurus', rect=Rect(left=298, top=6, width=95, height=95))]

Limitations

Feel free to submit a PR to address any of these.

  • decoding only - no encoding

  • I took the bone-headed approach of copying the logic in pydmtx’s decode function (in pydmtxmodule.c); there might be more of libdmtx’s functionality that could be used to read barcodes

  • I exposed the bare minimum of functions, defines, enums and typedefs neede to reimplement pydmtx’s decode function

License

pylibdmtx is distributed under the MIT license (see LICENCE.txt). The libdmtx shared library is distributed under the Simplified BSD license (see libdmtx-LICENCE.txt).

Metadata

Release files for pylibdmtx 0.1.7

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

Built distributions (wheels)

Table of built distributions (wheels) for pylibdmtx 0.1.7
File Interpreter ABI Platform
pylibdmtx-0.1.7-py2.py3-none-win_amd64.whl Python 3, Python 2 none Windows x86-64 Details
pylibdmtx-0.1.7-py2.py3-none-win32.whl Python 2, Python 3 none Windows x86-32 Details
pylibdmtx-0.1.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 165.1 kB

Release files / pylibdmtx-0.1.7-py2.py3-none-win_amd64.whl

Download URL pylibdmtx-0.1.7-py2.py3-none-win_amd64.whl
Size 94.2 kB
Tags Python 2 Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
45ad0bbc09256ade2fac7849da2ed827ca17117ba85c6c6c096dd2a3b31d59ca
BLAKE2b-256 checksum
How to use checksums
3c7fd625413ea41162de05374249765e1df67aa97b89d83bb89be6ed578a0566
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pylibdmtx-0.1.7-py2.py3-none-win32.whl

Download URL pylibdmtx-0.1.7-py2.py3-none-win32.whl
Size 52.8 kB
Tags Python 2 Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
52d852b2672ee5c3cc7b29f51627e147e0760ea4ac226956c6942f3639b1d9e4
BLAKE2b-256 checksum
How to use checksums
04ca84fa5bda1cd2a9915c0b0fa333ea9549b95ee53fee603cd43d81f4c1562b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pylibdmtx-0.1.7-py2.py3-none-any.whl

Download URL pylibdmtx-0.1.7-py2.py3-none-any.whl
Size 18.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cc5de1d2ae30adb652b893ca5ec55b86fbd4d02cd24bb4ba625a780bddbe2348
BLAKE2b-256 checksum
How to use checksums
4a97758c0cce0e596206e036465e31556877e66f3f6226608e7704a2d5be44f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.10

3 release files

0.1.9

3 release files

0.1.8

3 release files

This release

0.1.7 This release

3 release files

0.1.6

3 release files

0.1.5

3 release files

0.1.4

3 release files

0.1.3

3 release files

0.1.2

3 release files

0.1.1

3 release files

0.1.0

3 release files

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