Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi QR Detection Android Demo

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.

Model (required before building)

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.pt

The 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.

Run

  1. Export/copy the model as above.
  2. Run ./gradlew test and ./gradlew assembleDebug.
  3. Install app/build/outputs/apk/debug/app-debug.apk.
  4. 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.

Screenshot

origin qrcodesqrcodes annotated by python

qrcodes annotated by android

Known limitations

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.

About

a fully offline Android 7+ demo for locating and decoding small QR candidates in a high-resolution still image

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages