How do these little circles and lines you’re looking at right now (English text) convey information?
Simple: you’ve learned what certain circles and lines mean, and you can string patterns of circles and lines *together* to form words.
It’s the same concept with a QR code: it’s a standard language that QR readers know how to decode. Black and white pixels correspond to binary 0 and 1, depending on whether it’s found on an even or odd row, and then those patterns of 0s and 1s can be looked up in a table to make letters.
https://www.reddit.com/r/explainlikeimfive/search?q=qr&restrict_sr=on&include_over_18=on&sort=relevance&t=all
https://www.reddit.com/r/explainlikeimfive/comments/12h34tu/eli5_how_do_qr_codes_work/ This one looks good.
As someone else said, the letters you’re seeing as you read this hold data based on the light and dark patterns. QR codes are useful because they’re structured and relatively simple to interpret. (Getting a computer program to tell the difference between 0 and O and o is harder, for example.) The QR pattern is basically “this is the grid we’re looking at, look for dark and light spots here”. It then translates those into zero and ones, and then those zeros and ones can be interpreted as whatever data is needed. Computers treat text as just zeros and ones, not too much unlike saying A is 1, B is 2, etc.
Data in binary is just ones and zeroes. So we can do a very simple encoding simply by assuming anything black is a 0 and anything white is a 1.
Of course that doesn’t work too well on its own. We don’t know what is and isn’t data, or which way up it is. So we look for a pattern. QR codes have a square in 3 of the corners. Your phone looks for this pattern, works out how to rotate it and reads the data.
The actual data contains some extra information to correct for errors, and to indicate what type of data it is but that’s just data as well.
The outer three squares of a QR code is used to locate the existence of a code through a digital camera. Once the corners have been identified, it can use the expected size information to de-skew it. This takes the original photo’s QR code and stretches it into a square – so it looks like you are reading the QR code face-on. The corners are used to indicate how big each square is, what subtype of QR code it is, how it should read, and how much data there is to read.
Computer Vision is responsible for determining whether each square is on, or off. It does this by isolating each square and then iterating over each of the pixels on the image for that square. Using the average colour of all pixels in the square, we can determine if a square is black or white.
What we end up with in the end is a sequence of binary bits. Rather than just being binary string of the URL that is to be opened, it actually a sequence of patterns that fit the purpose of the QR code type. For a website, you have shortcuts for “https://”, “.com”, etc.
There are many kinds of QR codes. The basic QR code opens a website; modern QR codes are capable of opening applications, initiating phone calls, sending SMS, or simply just storing serial numbers on a washing machine. You can also customise some QR codes to show images like logos, or use different colours.
Latest Answers