sfxsfl 81bd2e02f4 first code checkin 10 months ago
..
CMakeLists.txt 81bd2e02f4 first code checkin 10 months ago
MANIFEST.in 81bd2e02f4 first code checkin 10 months ago
README.md 81bd2e02f4 first code checkin 10 months ago
core 81bd2e02f4 first code checkin 10 months ago
demo_reader.py 81bd2e02f4 first code checkin 10 months ago
demo_writer.py 81bd2e02f4 first code checkin 10 months ago
pyproject.toml 81bd2e02f4 first code checkin 10 months ago
setup.py 81bd2e02f4 first code checkin 10 months ago
test.py 81bd2e02f4 first code checkin 10 months ago
zxing.cmake 81bd2e02f4 first code checkin 10 months ago
zxing.cpp 81bd2e02f4 first code checkin 10 months ago

README.md

Python bindings for zxing-cpp

PyPI

Installation

pip install zxing-cpp

or

python setup.py install

Note: To enable position independent and multi-symbol DataMatrix detection, the library needs to be compiled with a c++20 compiler. Unfortunately some build environments (currently the 32-bit builds for Linux) used by cibuildwheel to generate the binary wheels that are published on pypi.org don't include a c++20 compiler. Best chance to enable proper DataMatrix support in that case is by installing from source:

pip install zxing-cpp --no-binary zxing-cpp

In that case or if there is no pre-build wheel available for your platform or python version or if you use setup.py directly, a suitable build environment including a c++ compiler is required.

Usage

import cv2, zxingcpp

img = cv2.imread('test.png')
barcodes = zxingcpp.read_barcodes(img)
for barcode in barcodes:
	print('Found barcode:'
		f'\n Text:    "{barcode.text}"'
		f'\n Format:   {barcode.format}'
		f'\n Content:  {barcode.content_type}'
		f'\n Position: {barcode.position}')
if len(barcodes) == 0:
	print("Could not find any barcode.")

To get a full list of available parameters for read_barcodes and write_barcode as well as the properties of the Barcode objects, have a look at the PYBIND11_MODULE definition in this c++ source file.