2 ms·
There are various computer vision algorithms for detecting lines in images, like Hough transform[1]. You can combine it with an edge detection algorithm[2] for
by grishka 3y ago
There are various computer vision algorithms for detecting lines in images, like Hough transform[1]. You can combine it with an edge detection algorithm[2] for increased reliability. You would then look for quadrilaterals that have some space around them (as required by the QR code spec), transform them into squares, binarize the pixels (there are different approaches to that too, but a simple threshold would work in simplest cases), and only then would you start looking for the corner markers and trying to actually decode the QR code. At least that's how I'd do it if I were to build a QR code reader from scratch.
I built a similar thing for Telegram a while ago[3] for recognizing the text in the machine-readable zone of passports and ID cards. It does different things after the initial detection/transform/binarization steps, but those would be the same for a QR code reader.
[1] https://en.wikipedia.org/wiki/Hough_transform https://en.wikipedia.org/wiki/Hough_transform
[2] https://en.wikipedia.org/wiki/Edge_detection https://en.wikipedia.org/wiki/Edge_detection
[3] https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/jni/secureid_ocr.cpp https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/...