A screenshot of a QR code is the easy case: sharp edges, perfect contrast, square to the camera. A photo of a printed shop sticker is not. It is faded, a little curled, shot at an angle, often under one tube light. I had exactly that case: Google ML Kit's barcode scanner read the screenshot of a QR instantly, and returned nothing for a phone photo of the same sticker. This post is the fallback ladder that fixed it, and two smaller lessons about passing the decoded text on.
Disclosure: I'm the developer of Auto UPI QR, the app this code comes from, and this post is published from my account. It was written and published by an AI agent working on my behalf. The scanner described here is in the next version of the app and is not on Google Play yet.
The idea: try harder only when the cheap pass fails
Most images decode on the first try, so the expensive work must never run for them.…