This is a fully offline Android 7+ demo for locating and decoding all small QR candidates in a high-resolution still image. It uses the same QRDet reference parameters as qrdet/qrdet_api_demo.py: 512px tiles, 384px stride, detection confidence .05, global NMS IoU .25, final confidence .70, and aspect ratio .75–1.33. It does not contain an API, authentication, upload, or network workflow.
The Android asset path is app/src/main/assets/qrdet-s.onnx. Re-export the included real QRDet s weight whenever the model needs to be refreshed:
python3 -m pip install ultralytics onnx onnxsim
python3 qrdet/export_qrdet_onnx.py --model qrdet/weights/qrdet-s.ptThe script uses ultralytics.YOLO directly on the QRDet .pt file, which is QRDet's underlying actual detector—not a generic replacement. Use --model qrdet/weights/qrdet-{n,m,l}.pt --output app/src/main/assets/qrdet-{n,m,l}.onnx to export another size, then change QrRecognitionEngine.MODEL_ASSET. The parser reads actual ONNX tensor shape at startup and supports common Ultralytics [1,C,N] and [1,N,C] detection/segmentation exports; it uses the first five detection channels (xywh + single QR confidence). Segmentation mask coefficients/prototypes are intentionally not used because the app's algorithm, crop, and annotations are bbox-based.
- Export/copy the model as above.
- Run
./gradlew testand./gradlew assembleDebug. - Install
app/build/outputs/apk/debug/app-debug.apk. - Pick an image or take a full-resolution CameraX JPEG, then tap 开始识别. The app is usable in flight mode once installed.
The image is EXIF-oriented before inference and the annotated JPEG preserves that resulting full resolution. The primary decoder is the Android binding of zxing-cpp (the same decoder family used by the Python reference), using 15/30/50% quiet-zone padding, 4x/8x bicubic and nearest enlargement, and color/grayscale/Otsu/inverted variants. ML Kit is a fallback. Each candidate stops on success while the remaining candidates continue.
No generated ONNX model is shipped, so a missing asset produces an explicit UI error. Actual count and decode success depend on the exported QRDet/ONNX Runtime version and device; the Python reference approximately locates 9 candidates and decodes 4 from docs/qr.png. The app logs the actual candidate/decode count and model/detection/decode/annotation/total times in Logcat and shows them in the UI.


.png)