Bonoscan.Components.Server 0.31.0

Bonoscan.Components.Server

The Blazor Server scan engine for Bonoscan.Components. A thin JS live loop POSTs camera frames to two off-circuit HTTP endpoints — /_bonoscan/detect (DocAligner ONNX, model embedded in this package) and /_bonoscan/capture (server-side C# warp) — so per-frame detection never touches the SignalR circuit. Only discrete state transitions and the final captured image cross the circuit.

For Blazor WebAssembly / MAUI use Bonoscan.Components.Client.

The DocAligner model is embedded in this package and loaded by default — you host no model.

Install

<!-- nuget.config -->
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="bonoscan-local" value="/absolute/path/to/scanner/local-feed" />
  </packageSources>
</configuration>
<PackageReference Include="Bonoscan.Components.Server" Version="0.30.0" />

Build the feed with ./build-nugets.sh in the scanner repo.

Setup

// Program.cs
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents()
    .AddHubOptions(o => o.MaximumReceiveMessageSize = 32 * 1024 * 1024);

builder.Services.AddBonoscanServer(o =>
{
    o.Scanner = s =>
    {
        s.GuideAspect   = 0.707;
        s.CaptureWidth  = 2480;
        s.CaptureHeight = 3508;
        s.Mime          = "image/jpeg";
        s.Quality       = 0.92;
    };
});

var app = builder.Build();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapBonoscanDetection();   // maps /_bonoscan/detect and /_bonoscan/capture
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();

Link the stylesheet in App.razor (or _Host):

<link rel="stylesheet" href="_content/Bonoscan.Components/bonoscan.css" />

Then drop <DocumentScanner OnCaptured="..." /> on an interactive-server page (see the Bonoscan.Components README for the component and ScannerResult reference).

Important: raise the SignalR message limit

The captured image is returned to .NET over the SignalR circuit. Blazor's default MaximumReceiveMessageSize is 32 KB — far smaller than a scanned image — so without raising it the circuit drops mid-capture and the result never arrives. The AddHubOptions(...) line above is required.

Secure context

getUserMedia needs HTTPS (or localhost). A LAN IP over plain HTTP will not get camera access; the component fails fast with a clear message.

What this package registers

AddBonoscanServer(...) registers the shared ScannerOptions, the native DocAligner detection service (AddDocAlignerDetection), and an IScannerEngine implemented by ServerScannerEngine (transient). MapBonoscanDetection() maps the off-circuit detect/capture endpoints.

Licensing

Library code MIT. Dependencies: ONNX Runtime (MIT), StbImageSharp (MIT/public domain). The embedded DocAligner weights are Apache-2.0 (DocsaidLab/DocAligner).

No packages depend on Bonoscan.Components.Server.

.NET 10.0

Version Downloads Last updated
0.31.0 149 06/04/2026