|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +title: Deep Learning Models - Dynamsoft Barcode Reader Android |
| 4 | +description: The usage of deep learning models in the Dynamsoft Barcode Reader Android SDK. |
| 5 | +keywords: models, deep learning, Neural Network, Android, java, kotlin |
| 6 | +noTitleIndex: true |
| 7 | +needGenerateH3Content: true |
| 8 | +needAutoGenerateSidebar: true |
| 9 | +--- |
| 10 | + |
| 11 | +# Deep Learning Models in Barcode Scanning |
| 12 | + |
| 13 | +Deep learning models are used by the SDK to improve barcode detection and decoding robustness, especially in challenging conditions such as blur, low contrast, distortion, glare, and complex backgrounds. |
| 14 | + |
| 15 | +In most cases, these models are loaded and used automatically. You usually only need to understand their role and package impact, then decide whether to keep or remove specific model files based on your barcode scope. |
| 16 | + |
| 17 | +## Where Models Are Used in the Pipeline |
| 18 | + |
| 19 | +In a simplified view, barcode processing can be divided into two major stages: |
| 20 | + |
| 21 | +1. Localization stage |
| 22 | + - Find potential barcode regions in the image. |
| 23 | +2. Decoding stage |
| 24 | + - Decode the detected regions into barcode text and format. |
| 25 | + |
| 26 | +Different model groups optimize different stages. |
| 27 | + |
| 28 | +## Available Models |
| 29 | + |
| 30 | +### Localization Models |
| 31 | + |
| 32 | +Localization models mainly affect the region detection stage. |
| 33 | + |
| 34 | +Benefits: |
| 35 | + |
| 36 | +1. Improve barcode localization success rate. |
| 37 | +2. Filter out false-positive regions before decoding. |
| 38 | +3. Reduce wasted decode attempts on invalid regions. |
| 39 | + |
| 40 | +- DataMatrixQRCodeLocalization.data |
| 41 | +- OneDLocalization.data |
| 42 | +- PDF417Localization.data |
| 43 | + |
| 44 | +Typical use case: |
| 45 | + |
| 46 | +- Images where barcodes are small, partially occluded, or surrounded by heavy background textures. |
| 47 | + |
| 48 | +### Decoders |
| 49 | + |
| 50 | +Decoder models mainly affect the decode stage for specific symbologies. |
| 51 | + |
| 52 | +Benefits: |
| 53 | + |
| 54 | +1. Improve decode success rate on difficult samples. |
| 55 | +2. Improve decode efficiency when symbols are damaged or low quality. |
| 56 | +3. Provide stronger format-specific decoding capability. |
| 57 | + |
| 58 | +- Code128Decoder.data |
| 59 | +- Code39ITFDecoder.data |
| 60 | +- EAN13Decoder.data |
| 61 | + |
| 62 | +Typical use case: |
| 63 | + |
| 64 | +- Retail, logistics, and warehouse scenarios where 1D barcodes may be compressed, printed with noise, or captured at non-ideal angles. |
| 65 | + |
| 66 | +### Deblur Models |
| 67 | + |
| 68 | +Deblur models are used before or during decoding to recover details from blurred barcode regions. |
| 69 | + |
| 70 | +Benefits: |
| 71 | + |
| 72 | +1. Improve success rate for motion blur and out-of-focus images. |
| 73 | +2. Especially useful for image-based decoding workflows. |
| 74 | + |
| 75 | +Trade-off: |
| 76 | + |
| 77 | +- Usually slower than non-deblur paths, so they are more suitable when read-rate is prioritized over speed. |
| 78 | + |
| 79 | +- OneDDeblur.data |
| 80 | +- PDF417Deblur.data |
| 81 | +- DataMatrixQRCodeDeblur.data |
| 82 | + |
| 83 | +Typical use case: |
| 84 | + |
| 85 | +- Document scan, album/image import, and any workflow where users decode still images with unstable quality. |
| 86 | + |
| 87 | +## Model Selection Recommendations |
| 88 | + |
| 89 | +If your app has a clear barcode scope, you can keep only the related models. |
| 90 | + |
| 91 | +- QR Code + DataMatrix only: |
| 92 | + - Keep `DataMatrixQRCodeLocalization.data` and `DataMatrixQRCodeDeblur.data`. |
| 93 | + - Consider removing OneD/PDF417-related models. |
| 94 | +- 1D-focused business workflows: |
| 95 | + - Keep `OneDLocalization.data`, `Code128Decoder.data`, `Code39ITFDecoder.data`, `EAN13Decoder.data`, and `OneDDeblur.data`. |
| 96 | +- PDF417-heavy workflows (e.g. IDs and transport docs): |
| 97 | + - Keep `PDF417Localization.data` and `PDF417Deblur.data`. |
| 98 | + |
| 99 | +If you are unsure, keep all default models first, then trim by test results. |
| 100 | + |
| 101 | +## Package Details and How to Shrink APP Size |
| 102 | + |
| 103 | +Model files are packaged in `DynamsoftBarcodeReaderBundle.aar`. |
| 104 | + |
| 105 | +To reduce app size, you can remove unneeded model files during the build process. |
| 106 | + |
| 107 | +For example, if your app focuses on QR Code and DataMatrix only, you can remove most OneD and PDF417 model files: |
| 108 | + |
| 109 | +```groovy |
| 110 | +android.applicationVariants.all { variant -> |
| 111 | + def cap = variant.name.capitalize() |
| 112 | + tasks.named("merge${cap}Assets").configure { |
| 113 | + doLast { |
| 114 | + outputs.files.files.each { out -> |
| 115 | + delete fileTree(out) { |
| 116 | + include "**/Models/OneDLocalization.data" |
| 117 | + include "**/Models/PDF417Localization.data" |
| 118 | + include "**/Models/Code128Decoder.data" |
| 119 | + include "**/Models/Code39ITFDecoder.data" |
| 120 | + include "**/Models/EAN13Decoder.data" |
| 121 | + include "**/Models/OneDDeblur.data" |
| 122 | + include "**/Models/PDF417Deblur.data" |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Best Practices |
| 131 | + |
| 132 | +1. Start with all default models enabled. |
| 133 | +2. Confirm your target barcode formats and real-world scan scenarios. |
| 134 | +3. Remove unrelated models gradually. |
| 135 | +4. Validate both speed and read rate after each shrink step. |
| 136 | +5. Keep a fallback build profile with all models for troubleshooting. |
| 137 | + |
| 138 | +## Next Steps |
| 139 | + |
| 140 | +- [Barcode Formats](barcode-format.md) |
| 141 | +- [Parameters, Settings & Templates](parameters-and-templates.md) |
| 142 | +- [Understand Scan Results](understand-barcode-scan-results.md) |
0 commit comments