ZXingCpp 0.1.1-alpha

This is a prerelease version of ZXingCpp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ZXingCpp --version 0.1.1-alpha                
NuGet\Install-Package ZXingCpp -Version 0.1.1-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZXingCpp" Version="0.1.1-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZXingCpp --version 0.1.1-alpha                
#r "nuget: ZXingCpp, 0.1.1-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ZXingCpp as a Cake Addin
#addin nuget:?package=ZXingCpp&version=0.1.1-alpha&prerelease

// Install ZXingCpp as a Cake Tool
#tool nuget:?package=ZXingCpp&version=0.1.1-alpha&prerelease                

ZXingCpp

ZXingCpp is a .NET wrapper for the C++ library zxing-cpp.

It is an open-source, multi-format linear/matrix 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 runtime and detection performance.

Usage

There is a NuGet package available: https://www.nuget.org/packages/ZXingCpp. It does currently not yet contain the native binary dll file. That needs to be copied/build separately at the moment.

Simple example usage:

using System.Collections.Generic;
using ImageMagick;
using ZXingCpp;

public static class ImageMagickBarcodeReader
{
    public static List<Barcode> Read(MagickImage img, ReaderOptions? opts = null)
    {
        if (img.DetermineBitDepth() < 8)
            img.SetBitDepth(8);
        var bytes = img.ToByteArray(MagickFormat.Gray);
        var iv = new ImageView(bytes, img.Width, img.Height, ImageFormat.Lum);
        return BarcodeReader.Read(iv, opts);
    }

    public static List<Barcode> Read(this BarcodeReader reader, MagickImage img) => Read(img, reader);
}

public class Program
{
    public static void Main(string[] args)
    {
        var img = new MagickImage(args[0]);

        var reader = new BarcodeReader() {
            Formats = BarcodeReader.FormatsFromString(args[1]),
            TryInvert = false,
        };

        foreach (var b in reader.Read(img))
            Console.WriteLine($"{b.Format} : {b.Text}");
    }
}

To run the ZXingCppDemo sample program, it is important that the dotnet runtime finds the native ZXing[.dll|.so|.dylib] in your path. E.g. on Linux a complete command line would look like this

LD_LIBRARY_PATH=<path-to-your-ZXing.so> dotnet run --project ZXingCppDemo -- ../../test/samples/multi-1/1.png

Note: This should currently be considered a pre-release. The API may change slightly to be even more "managed" depending on community feedback.

Benchmarking

To compare the performance of this .NET wrapper project with other available barcode scanner .NET libraries, I started the project zxing-bench. The README contains a few results to get an idea.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ZXingCpp:

Repository Stars
afriscic/BarcodeScanning.Native.Maui
Barcode scanning library for .NET MAUI
Version Downloads Last updated
0.2.2-alpha 126 9/8/2024
0.2.1-alpha 297 3/21/2024
0.2.0-alpha 62 3/21/2024
0.1.3-alpha 433 2/3/2024
0.1.2-alpha 53 2/2/2024
0.1.1-alpha 54 1/31/2024
0.1.0-alpha 54 1/30/2024