This is a bug report for AV Foundation. I noticed this problem when creating nice vector versions of the 1D barcodes used in figures in my book. The problem with this is that if you are scanning Code39 barcodes you have no way to determine whether it was one with or without check digit.
It’s filed as rdar://18566595 and on Open Radar.
Update Oct 17th: Added Apple’s response “behaves as intended” with a very good explanation given.
If you enable both versions of Code39 detection (with and without Mod43 check digit) AV Foundation always reports the scanned barcode as Code39, regardless if you scan a version with or without check digit. The check digit is then output as extra character.
Steps to Reproduce
- Set up a metadata output to scan for AVMetadataObjectTypeCode39Code and AVMetadataObjectTypeCode39Mod43Code
- Create a Code39mod43 with contents “CONTENTS”
- Scan a Code39 barcode with Mod43 check digit
Expected Results
- code should be reported as “org.iso.Code39Mod43”
- code content should be “CONTENTS”
Actual Results
- code is reported as “org.iso.Code39”
- code contents is “CONTENTSA” (extra character)
Notes
If you remove the AVMetadataObjectTypeCode39Code type from the metadata output, then the scanned barcode is reported as described in expected results.
So the detection order might be the wrong way around. The problem is – as a developer – I have way to know which of the both Code39 variants was actually scanned. And thus I wouldn’t know if I can disregard the extra character.
Response
The bug report was closed and the following reason given:
Code 39 does not support autodiscrimination between variants with and without the mod43 check digit. As far as the decoder is concerned, CONTENTSA is a perfectly valid Code 39 symbol payload that also happens to satisfy the mod43-check. Based solely on the bar-space pattern, it is not possible to know if the intended message is CONTENTS or CONTENTSA. When the application enables both variants of the code39 decoder, we err on the side of caution and return the longer string. This way the application can perform the mod43 check, if appropriate.
I stand corrected.
Categories: Bug Reports