PatrickJahr.Blazor.BarcodeDetection 1.0.0

dotnet add package PatrickJahr.Blazor.BarcodeDetection --version 1.0.0                
NuGet\Install-Package PatrickJahr.Blazor.BarcodeDetection -Version 1.0.0                
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="PatrickJahr.Blazor.BarcodeDetection" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PatrickJahr.Blazor.BarcodeDetection --version 1.0.0                
#r "nuget: PatrickJahr.Blazor.BarcodeDetection, 1.0.0"                
#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 PatrickJahr.Blazor.BarcodeDetection as a Cake Addin
#addin nuget:?package=PatrickJahr.Blazor.BarcodeDetection&version=1.0.0

// Install PatrickJahr.Blazor.BarcodeDetection as a Cake Tool
#tool nuget:?package=PatrickJahr.Blazor.BarcodeDetection&version=1.0.0                

PatrickJahr.Blazor.BarcodeDetection

NuGet Downloads (official NuGet)

Introduction

A Blazor wrapper for the Barcode Detection API.

The Barcode Detection API is a part of the Shape Detection API and enables the detection of barcodes from an image or a video stream in various formats such as QR, Code 128, EAN-13, and many others.

Getting started

Prerequisites

You need .NET 7.0 or newer to use this library.

Download .NET 7 Download .NET 8

Platform support

Platform support for Barcode Detection API

Installation

You can install the package via NuGet using the Package Manager in your IDE or alternatively using the command line:

dotnet add package PatrickJahr.Blazor.BarcodeDetection

Usage

The package can be utilized in Blazor projects.

Add to service collection

To make the BarcodeDetection available on all pages, register it in the IServiceCollection in Program.cs before the host is built:

builder.Services.AddBarcodeDetectionService();

Checking for Browser Support

Before utilizing the Barcode Detection API, you should first verify if the API is supported on the target platform by calling the IsSupportedAsync() method. This method returns a boolean indicating whether the Barcode Detection API is supported or not.

var isSupported = await barcodeDetectionService.IsSupportedAsync();
if (isSupported)
{
    // enable badging feature
}
else
{
    // use fallback mechanism or hide/disable feature
}

Detect Barcode

To detect a barcode, simply call the DetectCode method of the BarcodeDetectionService class, which can be added to your component via Dependency Injection. To invoke the method, you need the following parameters:

  • First, we need a picture or video to detect a barcode: -- IJSObjectReference file: An instance of a blob or ImageBitmap, for example -- ElementReference file: An instance of an HTML element like img or video
  • Then, you can set your preferred formats with the formats parameter. The result is a list of string with the detected barcodes.
Supported Formats

To find out which formats are supported, simply call the GetSupportedFormatsAsync method, which returns a string[] with all the formats that are supported.

License and Note

BSD-3-Clause.

This is a technical showcase, not an official PatrickJahr product.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 162 3/25/2024