Code Monkey home page Code Monkey logo

zxing-cpp-1's Introduction

Build Status

ZXing-C++

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

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

Features

  • In pure C++17, no third-party dependencies
  • Stateless, thread-safe readers/generators
  • Wrapper to create WinRT component
  • Wrapper for Android
  • Wrapper for WebAssembly
  • Python binding

Supported Formats

1D product 1D industrial 2D
UPC-A Code 39 QR Code
UPC-E Code 93 DataMatrix
EAN-8 Code 128 Aztec
EAN-13 Codabar PDF417
DataBar ITF MaxiCode (beta)
DataBar Expanded

Note: DataBar used to be called RSS.

Getting Started

To read barcodes:

As an example, have a look at ZXingReader.cpp.

  1. Load your image into memory (3rd-party library required).
  2. Call ReadBarcode() from ReadBarcode.h, the simplest API to get a Result.

To write barcodes:

As an example, have a look at ZXingWriter.cpp.

  1. Create a MultiFormatWriter instance with the format you want to generate. Set encoding and margins if needed.
  2. Call encode() with text content and the image size. This returns a BitMatrix which is a binary image of the barcode where true == visual black and false == visual white.
  3. Convert the bit matrix to your native image format. See also the ToMatrix<T>(BitMatrix&) helper function.

Web Demos

WinRT Package

A nuget package is available for WinRT: huycn.zxingcpp.winrt. To install it, run the following command in the Package Manager Console

PM> Install-Package huycn.zxingcpp.winrt

Build Instructions

Standard setup on Windows/macOS/Linux

  1. Make sure CMake version 3.10 or newer is installed.
  2. Make sure a C++17 compliant compiler is installed (minimum VS 2017 15.7 / gcc 7 / clang 5)
  3. See the cmake BUILD_... options to enable the testing code, python wrapper, etc.

Windows GDIPlus wrapper

  1. Open CMake GUI, specify wrappers/gdiplus as source folder in the first input, specify the build output in the second input, and click on Generate.
  2. At prompt, select "Visual Studio 15 2017" (or "Visual Studio 15 2017 Win64" if you want to build for x64 platform); leave the second input (Optional toolset...) empty; leave "Use default native compilers" checked; and click on Finish to generate the VS project. At the end, you will get a solution (.sln) in your binary output directory that you can open in VS. The project ZXingGdiPlus in the solution will generate a static library.

Windows Universal Platform

  1. Download and install CMake 3.4 or more recent if it's not already installed.
  2. Edit the file wrappers/winrt/BuildWinCom.bat to adjust the path to your CMake installation.
  3. Double-click on the batch script to run it.
  4. If the build succeeds, it will put the results in the folder UAP which is ready-to-use SDK extension.

Android NDK

Note: The original Java-only ZXing project has a very good support for Android, whether you want to use it as external app via Intent or directly integrated into your app. You should consider using it first before trying this library since involving with native code is always more complex than Java-only code. Performance-wise, except for specific usecases, you won't notice the difference!

  1. Edit wrappers/android/jni/Application.mk and adjust for your project.
  2. On command line, cd into wrappers/android/jni, type ndk-build (or ndk-build -j <number of your CPU cores>)
  3. Copy files in libs and java into corresponding folders of your Android project.

WebAssembly

  1. Install Emscripten if not done already.
  2. In an empty build folder, invoke emcmake cmake <path to zxing-cpp.git/wrappers/wasm>.
  3. Invoke cmake --build . to create zxing.js and zxing.wasm (and _reader/_writer versions).
  4. To see how to include these into a working HTML page, have a look at the reader and writer demos.
  5. To quickly test your build, copy those demo files into your build directory and run e.g. emrun --serve_after_close demo_reader.html.

You can also download the latest build output from the continuous integration system from the Actions tab. Look for 'wasm-artifacts'. Also check out the live demos.

zxing-cpp-1's People

Contributors

adamf88 avatar axxel avatar benys avatar dabrain34 avatar dfaure-kdab avatar dimatura avatar ducksoft avatar enzo-simone avatar gbsf avatar hondero2552 avatar huycn avatar jonthysell avatar marxin avatar seed93 avatar simonschmeisser avatar srinivas32 avatar swex avatar tanius avatar timrae avatar tsdgeos avatar urishab avatar vkrause 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.