Point ABN Signal at an invoice and the camera may pick up an Australian Business Number (ABN), a phone number, and an invoice number in the same pass. A blurred digit can also change between frames. The scanner needs to decide which strings are plausible and when it has seen enough to look one up.
OCR turns the writing in an image into text. The scanner then looks for numbers shaped like an ABN, checks whether they persist across frames, and finally looks up their records.
Filter by the structure of an ABN
The app runs ML Kit, Google’s on-device machine-learning toolkit for mobile apps, on the device and passes the recognized text to AbnTextExtractor. The extractor looks for 11 digits, written as a single run or grouped as XX XXX XXX XXX. It accepts several separators between groups, including line breaks, so it can recover a number that OCR split across two lines.
The tests use 51 824 753 556 as an example. Even if the last three digits wrap to a new line, the extractor can recover the same string, 51824753556. A checksum is a check computed from the digits themselves. The app follows the Australian Business Register’s format guidance: subtract 1 from the first digit, multiply the 11 digits by the weights 10, 1, 3, 5, 7, 9, 11, 13, 15, 17 and 19, add the products, and accept the number only if the sum is divisible by 89. ABN format and check digits
For the test ABN, subtracting 1 from the leading 5 gives 41824753556, and the weighted sum is:
4×10 + 1×1 + 8×3 + 2×5 + 4×7 + 7×9 + 5×11 + 3×13 + 5×15 + 5×17 + 6×19
= 40 + 1 + 24 + 10 + 28 + 63 + 55 + 39 + 75 + 85 + 114
= 534 = 89 × 6
The remainder is 0, so 51824753556 passes. Changing one digit moves the sum by the digit change times that position’s weight. Because 89 is prime and both factors are smaller than 89, that shift is never a multiple of 89, so a misread of a single digit always fails the check.
There is a subtle case when extracting those digits: two candidates can overlap. When the first candidate fails the checksum, the extractor advances one character and tries again. Skipping the whole match would miss a valid ABN that starts inside it.
Wait for the number to appear again
A checksum validates the structure of a number. A misread can still happen to pass. ScanCandidateDebounce confirms a number after it appears in two consecutive processed frames.
| Frame | Candidates passing checksum | Confirmed number |
|---|---|---|
| 1 | A | |
| 2 | B | |
| 3 | A | |
| 4 | A | A |
A starts a new streak in frame 3 because it was absent from frame 2. Two copies of A in the same frame count as a single sighting. If both A and B survive two frames, the scanner can confirm both and let the user choose the record to look up.
Drop frames while recognition is busy
ScanFrameProcessor leaves at least 500 ms between recognition starts and drops incoming frames while the previous one is still being processed. If the camera is moving, a backlog would keep the app reading parts of the invoice the user has already moved past. The trade-off is that the user must hold the camera steady long enough for two processed frames to capture the same number.
The lesson was to put the confirmation rules after recognition, where plain text and lists of numbers are all a test needs. The Dart tests cover one-frame misreads, empty frames, and duplicate candidates without setting up a camera. The subsequent lookup determines whether the confirmed ABN has a corresponding record.
Zoveso reads lottery tickets with a similar on-device pipeline, but from a single photo, so it relies on parsing fields such as the station and draw date instead of repeated frames.
Conclusion
A checksum can reject many malformed readings, and requiring the same candidate in two processed frames filters brief OCR glitches. Neither step proves that the number belongs to the invoice. The final lookup and the user’s choice remain separate checks.