|
| 1 | +--- |
| 2 | +name: dbr-template-tuner |
| 3 | +description: 'Tune Dynamsoft Barcode Reader template JSON when the default DBR preset returns NO_RESULT on a hard barcode image. Use for difficult QR, DataMatrix, PDF417, 1D, blurry, low-contrast, mirrored, skewed, cropped, warped, or cluttered images when you need evidence-driven parameter tuning instead of random template edits.' |
| 4 | +argument-hint: 'image path, current template path, expected barcode type if known' |
| 5 | +user-invocable: true |
| 6 | +--- |
| 7 | + |
| 8 | +# DBR Template Tuning |
| 9 | + |
| 10 | +## When to Use |
| 11 | + |
| 12 | +- The default DBR preset fails with `NO_RESULT` on a barcode image. |
| 13 | +- You need to tune `dbr_template.json` or create a focused template for one failure case. |
| 14 | +- You want evidence before changing `LocalizationModes`, `DeblurModes`, `MinQuietZoneWidth`, or related parameters. |
| 15 | +- You want AI to stop random parameter churn and use a repeatable workflow. |
| 16 | + |
| 17 | +## Inputs |
| 18 | + |
| 19 | +- Image path |
| 20 | +- The image itself attached to chat when available, so AI can inspect visual symptoms before changing parameters |
| 21 | +- Current template path if one already exists |
| 22 | +- Expected format if known, such as `QR`, `DataMatrix`, or `Code128` |
| 23 | +- Whether preprocessing is allowed or the ask is strictly template-only |
| 24 | +- Whether any included example template is actually relevant to this image |
| 25 | + |
| 26 | +## Procedure |
| 27 | + |
| 28 | +1. Observe the image before touching the template. |
| 29 | +Use the image tool on the provided barcode image and describe visible symptoms in concrete terms: quiet-zone loss, border clipping, blur, low contrast, warping, wrinkles, inversion, reflection, background texture, finder-pattern damage, or perspective skew. |
| 30 | + |
| 31 | +2. Validate the current template directly through the simplest DBR path. |
| 32 | +The validator must initialize the DBR license before creating `CaptureVisionRouter`; otherwise treat `NO_RESULT` as invalid evidence. |
| 33 | +Run `python validate_dbr_template.py <image> --template-file <template>`. |
| 34 | + |
| 35 | +3. Establish a broader baseline only after the direct validation result is known. |
| 36 | +Run `python probe_dbr_templates.py <image>`. |
| 37 | + |
| 38 | +Do not assume an existing example template is the right first answer. Only reuse one when the symbol type and failure pattern are close enough to justify it. |
| 39 | + |
| 40 | +4. If the user already has a proven template from Dynamsoft or another teammate, compare it before theorizing. |
| 41 | +Run `python compare_dbr_template_profiles.py <current-template> <proven-template>`. |
| 42 | + |
| 43 | +5. If everything still returns `NO_RESULT`, test whether simple preprocessing changes the outcome. |
| 44 | +Run `python probe_dbr_templates.py <image> --variant-set basic --report-json tuning-report.json`. |
| 45 | + |
| 46 | +6. Use image observation, the direct validation result, the result matrix, and the template diff to classify the failure. |
| 47 | +- Raw image succeeds with a candidate template: keep tuning in the template only. |
| 48 | +- Only a preprocessed variant succeeds: the image needs preprocessing plus template tuning. |
| 49 | +- No raw or basic variant succeeds: treat this as a stop signal for template-only tuning and say so explicitly. |
| 50 | +- A proven template differs mainly in `DeformationResistingModes` or separate decode `ImageParameterOptions`: prioritize those before adding more `DeblurModes`. |
| 51 | + |
| 52 | +7. Change one parameter family at a time. |
| 53 | +- Scope first: `ExpectedBarcodesCount`, `BarcodeFormatIds` |
| 54 | +- Localization second: `LocalizationModes`, `ConfidenceThreshold` |
| 55 | +- Decode third: `DeformationResistingModes`, decode `ImageParameterOptions`, `DeblurModes`, `BarcodeScaleModes`, grayscale and binarization choices |
| 56 | +- Acceptance last: `MinQuietZoneWidth`, `MirrorMode`, `ReturnPartialBarcodeValue` |
| 57 | + |
| 58 | +8. Keep the edit minimal. |
| 59 | +Prefer a new focused template file with one `CaptureVisionTemplate` over editing a large exported default file. |
| 60 | + |
| 61 | +9. Re-run the direct validator after each edit. |
| 62 | +Run `python validate_dbr_template.py <image> --template-file <candidate-template>`. |
| 63 | + |
| 64 | +10. Re-run the broader probe only when needed. |
| 65 | +Do not make another parameter change before the previous change is tested. |
| 66 | + |
| 67 | +## Lessons From The Official Template Example |
| 68 | + |
| 69 | +- More `DeblurModes` is not automatically better; a proven template may win through `DRM_BROAD_WARP` and `DRM_DEWRINKLE` with `DeblurModes = null`. |
| 70 | +- Separate image parameters for localization and decoding can matter. |
| 71 | +- Do not assume custom `BarcodeFormatSpecificationOptions` are needed; leaving default format behavior intact may be better. |
| 72 | +- `IfEraseTextZone = 0` can preserve damaged structure that an aggressive text-zone removal step might destroy. |
| 73 | +- Standalone DBR helper scripts need license initialization too, not just the GUI app. |
| 74 | +- Treat any example template in this folder as a reference point, not a default first move. |
| 75 | + |
| 76 | +## Output Requirements |
| 77 | + |
| 78 | +When using this skill, return: |
| 79 | + |
| 80 | +- a short visual diagnosis based on the image itself |
| 81 | +- a short diagnosis of the likely failure mode |
| 82 | +- the smallest candidate template change that tests the diagnosis |
| 83 | +- the exact direct-validation command to run next |
| 84 | +- whether any existing example template is relevant or should be ignored |
| 85 | +- a stop condition when evidence suggests the pixels are not recoverable by template tuning alone |
| 86 | + |
| 87 | +## References |
| 88 | + |
| 89 | +- Read the image symptom guide in [image-symptoms.md](./references/image-symptoms.md) |
| 90 | +- Read the tuning matrix in [parameter-playbook.md](./references/parameter-playbook.md) |
0 commit comments