scanner_core library
Direct access to the native CV core that powers flutter_better_scanner.
This is the library that used to be the separate scanner_core package.
It is re-exported here unchanged, so code that previously did
import 'package:scanner_core/scanner_core.dart';
keeps working after a one-line change:
import 'package:flutter_better_scanner/scanner_core.dart';
Everything here is synchronous and CPU-bound — call it from a worker isolate for large images. Most apps never need this library: the scanner, the controller and ScannerEditor already run it on a background isolate.
final rgba = RgbaImage(pixels, width, height);
final quad = ScannerCv.detectDocument(rgba);
final flat = quad == null
? rgba
: ScannerCv.warp(rgba, quad.scale(rgba.width - 1, rgba.height - 1));
final bytes = ScannerCv.encodeJpeg(
ScannerCv.applyFilter(flat, ScanFilter.magicColor), 92);
Classes
- FrameAnalysis
- One-call live-frame analysis result: detected quad (or null) + stats.
- FrameStats
- Frame quality statistics for autocapture gating.
- Quad
-
Quadrilateral as 4 corners, TL/TR/BR/BL. Coordinates are either
normalized
0,1(detection output) or pixels (warp input) — the owner tracks which. - RgbaImage
- A raw RGBA image buffer.
- ScannerCv
Enums
- ScanFilter
- Document filter types. Order must match the C enum in scanner_core.cpp.