I am trying to find a way of scanning a South Africa ID card. This does work, but not in a consistent manner, because of how the barcodes a printed on the card, the upper barcode only has the id number whilst the lower barcode has additional information which I am able to pass to various fields of my form. Is there a way of ensuring only the second barcode is scanned even if both are within the scanner box
As a follow-up to my question, the type of barcodes in the ID card are Code39 and PDF417. I posed this question in ODK Ask AI
can you specify the type of barcode e.g PDF147 in a form
No, you cannot specify or restrict the barcode type (e.g., PDF417, QR Code, EAN-13) directly in the XLSForm or ODK form definition. The ODK barcode widget supports scanning a wide range of barcode formats—including PDF417, QR Code, and others—but it does not provide a way to limit the scanner to only accept a specific type of barcode within the form settings. The widget will attempt to scan and decode any supported barcode type presented to it, and the form will capture whatever value is read from the barcode.
If you need to ensure that only a certain type of barcode is accepted, you would need to implement additional validation logic (e.g., using constraints or calculations to check the format of the scanned value), but you cannot configure the widget itself to only scan a specific barcode type like PDF417. The documentation explicitly lists the supported formats but does not mention any option to restrict the type at the form level Barcode widget.
If you have a specific barcode format requirement, you may need to instruct enumerators to only scan the correct type, or use post-processing to validate the scanned data.
Thanks for the detailed info on what you’re trying to do and for bringing in samples from the ML Kit issue!
First, I want to confirm that you’re using Collect v2025.3.x because prior versions used a different library for barcode scanning.
With the latest Collect v2025.3.1, I agree that the upper barcode on the Department of Home Affairs card causes interference. The most reliable way I’ve found to scan the bottom code is to put my finger on the upper barcode to block it from being read. When I do that, even just on a bit of the upper code, the bottom code is scanned quickly and reliably. Could you suggest that process in the form?
The driver’s license has an extremely dense PDF 147 code. It’s probably possible to read with a very high quality camera that is perfectly still in perfect lighting conditions but unfortunately that’s going to be hard to do reliably. In the past, we’ve seen projects make very simple rigs out of cardboard to hold a phone at an optimal focal distance. Have you experimented with a real physical card? The image provided has some resolution loss already.
That’s a good instinct! We don’t think this will make a difference – the problem is more likely to be actually capturing all the data rather than detecting the barcode format. Currently we read from the video feed which is lower resolution. The ML Kit issue makes it sound like others have had success with first taking a high-resolution still and then processing it.
Before going to far into exploring how to scan the code, you may want to spend some time seeing whether you actually would be able to use the value if you were to get it. I quickly skimmed this resource on the data format and it looks like at least some of the contents are encrypted. You would not be able to decrypt from the form. You can decode from base64. You should also consider that the entire scanned contents would be submitted with the form. That could make the submission big or could be problematic from a privacy standpoint.
I have tested this suggestion it does work (will use that for now), it would be nice to have this option maybe in future with resources permitting. I note Dynamsoft Barcode Scanner has settings to select the type of barcode format.
Even with a physical card I am unable to read the barcode (I also agree that it is encrypted). I then tried with Dynamsoft Barcode Scanner on the attached Drivers License and it was able to read and decode the barcode when selecting US Driver’s License and not with General Scan.
I will continue investigating - maybe find a third party app that I can open from Collect to read the barcode and get the decoded information - not sure if this is possible.
We’ve captured that feedback! The challenge we have is that barcode scanning is one of many functions that ODK provides so as you highlight, it’s hard to get the resources to focus on just that. Agreed that there are a lot of interesting things we could do to improve the scanning experience.
Yes, that would be possible but the external app has to return data in a particular way – see docs.
We’ve received more feedback about complex PDF147 barcodes and are working on a patch release that will at least make them scannable in landscape mode. We’re hoping to have that out for you to try within the next week. We’ve verified that it works smoothly with the sample SA license.