Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C++ port of ZXing

License

NotificationsYou must be signed in to change notification settings

zxing-cpp/zxing-cpp

Repository files navigation

Build Status

ZXing-C++

ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.

It was originally ported from the JavaZXing Library but has been developed further and now includes many improvements in terms of runtime and detection performance. It can both read and write barcodes in a number of formats.

Sponsors

You can sponsor this library atGitHub Sponsors.

Named Sponsors:

Thanks a lot for your contribution!

Features

Supported Formats

Linear productLinear industrialMatrix
UPC-ACode 39QR Code
UPC-ECode 93Micro QR Code
EAN-8Code 128rMQR Code
EAN-13CodabarAztec
DataBarDataBar ExpandedDataMatrix
DataBar LimitedDX Film EdgePDF417
ITFMaxiCode (partial)

[Note:]

  • DataBar used to be called RSS.
  • DataBar, DX Film Edge, MaxiCode, Micro QR Code and rMQR Code are not supported for writing (unless the library is configuredZXING_WRITERS=NEW andZXING_EXPERIMENTAL_API=ON).
  • Building with only C++17 (seeCMakeLists.txt) changes the behavior of the library: it then lacks support for DataBarLimited and multi-symbol and position independent detection for DataMatrix.

Getting Started

To read barcodes:

  1. Load your image into memory (3rd-party library required).
  2. CallReadBarcodes() fromReadBarcode.h, the simplest API to get a list ofBarcode objects.

A very simple example looks like this:

#include"ZXing/ReadBarcode.h"#include<iostream>intmain(int argc,char** argv){int width, height;unsignedchar* data;// load your image data from somewhere. ImageFormat::Lum assumes grey scale image data.auto image =ZXing::ImageView(data, width, height, ZXing::ImageFormat::Lum);auto options =ZXing::ReaderOptions().setFormats(ZXing::BarcodeFormat::Any);auto barcodes =ZXing::ReadBarcodes(image, options);for (constauto& b : barcodes)        std::cout <<ZXing::ToString(b.format()) <<":" << b.text() <<"\n";return0;}

To see the full capability of the API, have a look atZXingReader.cpp.

[Note: At least C++17 is required on the client side to use the API.]

To write barcodes:

  1. Create aMultiFormatWriter instance with the format you want to generate. Set encoding and margins if needed.
  2. Callencode() with text content and the image size. This returns aBitMatrix which is a binary image of the barcode wheretrue == visual black andfalse == visual white.
  3. Convert the bit matrix to your native image format. See also theToMatrix<T>(BitMatrix&) helper function.

As an example, have a look atZXingWriter.cpp. That file also contains example code showing the newZXING_EXPERIMENTAL_API for writing barcodes.

Web Demos

[Note: those live demos are not necessarily fully up-to-date at all times.]

Build Instructions

These are the generic instructions to build the library on Windows/macOS/Linux. For details on how to build the individual wrappers, follow the links above.

  1. Make sureCMake version 3.16 or newer is installed. The python module requires 3.18 or higher.
  2. Make sure a sufficiently C++20 compliant compiler is installed (minimum VS 2019 16.10? / gcc 11 / clang 12?).
  3. See the cmakeZXING_... options to enable the testing code, python wrapper, etc.
git clone https://github.com/zxing-cpp/zxing-cpp.git --recursive --single-branch --depth 1cmake -S zxing-cpp -B zxing-cpp.release -DCMAKE_BUILD_TYPE=Releasecmake --build zxing-cpp.release -j8 --config Release

[Note: binary packages are available for/asvcpkg,conan,mingw and a bunch oflinux distributions.]


[8]ページ先頭

©2009-2025 Movatter.jp