ZXingCpp 0.1.3-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.3-alpha                
NuGet\Install-Package ZXingCpp -Version 0.1.3-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.3-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZXingCpp --version 0.1.3-alpha                
#r "nuget: ZXingCpp, 0.1.3-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.3-alpha&prerelease

// Install ZXingCpp as a Cake Tool
#tool nuget:?package=ZXingCpp&version=0.1.3-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

using SkiaSharp;
using ZXingCpp;

public class Program
{
    public static void Main(string[] args)
    {
        var img = SKBitmap.Decode(args[0]).Copy(SKColorType.Gray8);
        var iv = new ImageView(img.GetPixels(), img.Info.Width, img.Info.Height, ImageFormat.Lum);

        var reader = new BarcodeReader() {
            Formats = args.Length > 1 ? BarcodeReader.FormatsFromString(args[1]) : BarcodeFormats.Any,
            TryInvert = false,
            // see the ReaderOptions implementation for more available options
        };

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

Executing this sample code from the command line would look like this:

dotnet run -- <image-file-name> [barcode-format-list]

The NuGet package includes the runtime/native c++ libraries for the x64 architecture on Windows, Linux and macOS. If something is not working out of the box or you need arm64 support then you need to build the [lib]ZXing[.dll|.so|.dylib] file yourself and make sure the .NET runtime find it (see e.g. the environment variables LD_LIBRARY_PATH on Linux or PATH on Windows).

Note: This is an alpha release, meaning the API may still change slightly to potentially feel even more like a native C# library depending on community feedback.

Why ZXingCpp?

There are a number of areas where ZXingCpp shines compared to other popular .NET barcode scanner libraries. The following comparison is with respect to the open source ZXing.Net and the commercial Dynamsoft projects.

Performance

To compare the performance of ZXingCpp with the other two libraries, I started the project zxing-bench. The README contains a few details but to get an idea: ZXingCpp is on average 2x-10x faster than Dynamsoft and 10x-50x faster than ZXing.Net.

Detection rate

The benchmarking tool also showed that ZXingCpp has a superior detection rate compared to ZXing.Net while it is sometimes better sometimes worse than the commercial Dynamsoft package, depending on the sample type and the library configuration. The latter definitively supports more barcode formats compared to the two ZXing decendents.

Ease of use

The sample program above shows the simplicitly of the API. The others are similar but seem a bit more complicated with regards to setting parameters.

Standards support

ZXingCpp has full support for binary data and ECI handling and provides a standards conforming bytesECI() data that can be used to simulate a hardware/handheld barcode scanner. This seems not the case for ZXing.Net and is unclear for Dynamsoft.

License / costs

ZXingCpp has the liberal Apache-2.0 license and is free to use in commercial applications. That said, I accept donations and might be available for commercial consulting 😉.

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