Eli5: how do QR codes work

234 views

QR codes have revolutionised how we share information. How does QR code work and what does the scanner scan in this scenario

In: 0

3 Answers

Anonymous 0 Comments

A QR code is just a 2D version of the barcodes you see on pricetags for items at the supermarket.

Computer cameras are *bad* at reading complex things like text. They’re improving, but still nowhere near a point where you can let a text detection program loose on millions of random people, let them point their crummy phone cameras at some text in awful lighting conditions at strange angles and get consistently correct results. We want something that computers can read now, accurately, quickly, and consistently, in a wide variety of bad photo conditions.

If a computer is good at discerning anything in pictures, it’s noticing the difference between bright and dark spots. It’s just not that great at discerning the thin, swoopy curves of printed text. So instead of text, we write out alternating black and white blobs that encode information in a sort-of Morse code. Instead of dot-dot-dash you get light-light-dark, etc. To be clear, it is not actual Morse code, I’m only bringing up the comparison to demonstrate how alternating light and dark patches can store data.

Bar codes on price tags are an extremely simple use for this idea. The tall bars give the scanner lots of wiggle room to see them, you can twist the little scanner laser to nearly any angle and still get a reading. The bars at the two ends are special, and tell the scanner which side is the start and which side is the end. This allows the scanner to read bar codes even if they are upside-down–if the start and stop ends are flipped the wrong way, the scanner will simply read it backwards. It then proceeds to read the light and dark patches in order, like you’d read words on a page, to decode the message. For a bar code, it’s almost certainly the product ID number of the item you’re buying. The digits tend to be printed below the bars for humans to read.

If reading a barcode was like reading a one-line sentence, then a QR code is like reading a full book page. The QR code is basically many, many barcodes stacked on top of each other that are all read together, just like a book page is many, many sentences stacked on top of one another and all read together. The funny squares in the corners tell the camera which way is up, so just like a barcode you can read QR codes rotated any which way. It then reads the dot pattern like you’d read a book page, scanning left-to-right first and moving down one line at a time (I think QR codes actually do it exactly backwards from that, but that’s aside the point). The data stored in most QR codes you see tend to be website links, written exactly as you’d type them yourself in the address bar. But QR codes can store essentially whatever data you like. Just not a whole lot of it.

You are viewing 1 out of 3 answers, click here to view all answers.