startWxScanWorker function

Future<WxScanWorker> startWxScanWorker({
  1. Uint8List? detectModel,
  2. Uint8List? srModel,
})

Starts a worker with the engine in it, fetching what it needs.

WxScanner is one caller. The other is the camera plugin, which forwards the documents a scan produces rather than the outcomes parsed from them, and so works one level below.

Implementation

Future<WxScanWorker> startWxScanWorker({
  Uint8List? detectModel,
  Uint8List? srModel,
}) async {
  final paths = wxScanWebPaths;
  final withModels = detectModel != null && srModel != null;
  return WxScanWorker.start(
    workerUrl: paths.workerUrl,
    wxscanWasm: await _fetch(paths.wasmUrl),
    tfliteUrl: withModels ? paths.tfliteUrl : null,
    detectModel: detectModel,
    srModel: srModel,
  );
}