wxscan 0.1.2
wxscan: ^0.1.2 copied to clipboard
QR decoding for Dart and Flutter - a Rust port of the wechat_qrcode algorithm (CNN detection, super resolution, decoding). Images and raw pixel buffers; for a camera see wxscan_live.
Changelog #
0.1.2 #
-
The image formats the native library carries decoders for, and the cargo release profile it is built with, are now the application's to set, in its own
pubspec.yamlunderhooks: user_defines: wxscan:. Both were fixed here before, and neither is this package's business: which formats an application will ever be handed is something only it knows, and a decoder for a format it never sees is pure size — 2.13 MB of Android library becomes 866 KB when the answer is "none of them, I scan camera frames".hooks: user_defines: wxscan: image_formats: [png, jpeg] cargo_profile: strip: symbolsimage_formatstakes any ofpng,jpeg,gif,webp,bmp,tiffandheic, and defaults to all of them except on Apple, where ImageIO is lent to the library and reads them already. A format left out answersunsupportedFormat, the same as a format nothing here ever read.cargo_profiletakesopt_level,lto,codegen_units,stripandpanic. Both are validated: a misspelled format or key stops the build rather than quietly shipping a library missing a decoder.doc/image_formats.mdand the README carry the measured sizes, including whatopt_level: zcosts per frame, which is more than it saves.
0.1.1 #
- macOS builds for Intel as well as Apple Silicon. The
darwin_universalarchive the build hook pins holds both slices and the hook already thinned it to the one each build asked for; what stopped an x86_64 build was a check written when no x86_64 library existed to fetch. A macOS release build is universal by default, so this is what a release build wanted all along —ARCHSno longer has to be pinned to arm64 inmacos/Runner/Configs/Release.xcconfig, and an application that wants one architecture alone still sets it.
0.1.0 #
First release.
- Decodes images and raw pixel buffers through a Rust port of the
wechat_qrcodealgorithm: CNN detection, super resolution and decoding, with no OpenCV. - A plain Dart package rather than a Flutter plugin.
hook/build.dartbuilds the native library and bundles it, together with the TFLite C library, as code assets, sodart runanddart testwork as well as Flutter does and there are no platform build files. - Runs in a browser too, as WebAssembly on a worker, against the same TFLite
weights and the same runtime as every other platform. The four files an
application serves are placed by
dart run wxscan:fetch_web, which fetches the compiled three from pinned releases rather than carrying them here; seedoc/web_build.md. - Decodes pictures as well as pixels:
scanPathfor a file,scanImagefor bytes already in hand — a picked image, a download, or a browser, which has no paths. PNG, JPEG and GIF everywhere; WebP, BMP and TIFF where the platform lends nothing; HEIC on Apple, Android and in Safari.doc/image_formats.mdis the matrix, and the platform can be lent a decoder for the rest. WxScanner.createtakes the weights as bytes or as paths —detectModelPathandsrModelPath— and the path form is read by the native library on the worker isolate, so the megabyte is never held on the isolate that asked. Flutter assets have no path and still go as bytes; a browser has no filesystem and refuses a path outright.- Scanning runs on a worker isolate owned by the scanner, so a stream costs one message round trip per frame rather than an isolate spawn.
scanPixelstakes RGB, RGBA, BGR or BGRA and converts natively, so a caller decoding a PNG or a JPEG does not convert pixels in Dart.- Detection is configurable:
confidenceThreshold,nmsThresholdandscaleFactorread and write without contending for the scanner's lock. - A scanner can be lent to
wxscan_live, so an application that scans both live and from the photo library holds one scanner and one copy of the weights. The two sides may be disposed in either order: the native handle is a counted reference rather than a pointer, so whichever lets go last frees it, and one left over from an isolate that is gone names nothing rather than being followed. WxScanner.usecreates a scanner for one piece of work and disposes it however that ends, andWxScanner.liveCountsays how many exist — enough to assert in a test that nothing leaked, which from the outside was previously invisible.- Mismatched dimensions raise
ArgumentErrorinstead of returning an empty result that looks like a frame with nothing in it.