HACKER Q&A
📣 mdoms

How are QR scanners written?


I have been programming web and backend stuff for over a decade but I have never done any kind of image processing. I tried googling but there is so much noise in the QR space.

What I want to know is, how does QR scanner code work? How do you go from a photo of a QR to the encoded text within, allowing for all of the factors that will get in the way like poor quality cameras, off-center photos, blurriness etc? Is there a code-first tutorial or worked example somewhere?


  👤 muzani Accepted Answer ✓
Here's some code you can dig into: https://github.com/zxing/zxing

It's a very good one, and one that has been copied for a lot of custom QR scanners


👤 pavelgvay
On my first job at an internet provider company, they had no backend. They were using some proprietary software and SQL functions instead. One day the CEO came in and said: "Guys, we need to print a small QR code on mails to customers. ". The team lead responded: "Sure, our intern can do it."

Oh my gosh, that was a crazy task! I built a fully functional QR code generator on pure SQL from scratch! It was very fun.

Check out Wikipedia [1]. They explain how QR codes work really well. Well enough to build your own generator.

I also used ZXing code [2], that Muzani shared below here, as a reference.

[1] — https://en.wikipedia.org/wiki/QR_code

[2] — https://github.com/zxing/zxing