googlesamples / googlesamples/mlkit
[Bug report] Data Matrix codes with inverted colors (light-on-dark / white-on-black) are not detected
- Dominant language
- Kotlin
- Stars
- 4.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The barcode scanner fails to detect Data Matrix codes when they use inverted polarity — i.e., light/white modules on a dark/black background. Standard dark-on-light Data Matrix codes scan correctly, but inverted codes are not recognized at all, even under good lighting and focus conditions.
**To Reproduce**
1. Generate a standard Data Matrix code (dark modules on light background) — confirm it scans successfully.
2. Generate the same data as a Data Matrix code with inverted colors (light modules on dark background).
3. Start scanning with no format restriction.
4. Observe that the inverted code is never detected, while the normal-polarity version scans without issue.
**Expected behavior**
The scanner should detect and decode Data Matrix codes regardless of color polarity (dark-on-light or light-on-dark), consistent with the ISO/IEC 16022 spec, which explicitly supports both polarities.
**SDK Info:**
- SDK Name & Version: com.google.mlkit:barcode-scanning:17.3.0
**Smartphone:**
- Device/Simulator: Android physical devices
- Device/Simulator OS: Android 16 observed during testing
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue on an Android physical device with com.google.mlkit:barcode-scanning:17.3.0, using unrestricted format scanning and comparing standard and inverted Data Matrix images. Check whether the sample repository contains a barcode-scanning entry point or test path; done means confirming support for both polarities or documenting that the behavior belongs to the SDK dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- computer-vision, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100