what are QR codes and how does my phone camera associate them with a link or URL


what are QR codes and how does my phone camera associate them with a link or URL

In: 103

They are pretty much visual binary code. The black/white squares are 1s and 0s to encode pretty much any data you like. Then there is a part that helps to find the alignment (so it still works when flipped) and the data is slightly redundant (so you can block part of the QR Code and still read it).

Your phone has a program that knows how exactly the bits are to be read, and then interprets that binary number as a series of ASCII characters that form the link.

A bit more detailed: the phone knows wich order to read the squares. It starts and reads Black/Black/White/Black, transforms that to 1101, wich is 13 in decimal, and could be the letter N (made up example)

A QR code is a barcode but in 2 dimensions.

A barcode, when scanned in one direction, represents a set of numbers and/or letters. A barcode is easier for a machine to read than writing out the numbers/letters. If you scratch out text, you can’t read it but a barcode can take a few scratches and scrapes while still being readable.

A QR code stores more information than a barcode because it can use 2 dimensions to store numbers and letters. That’s why it can be scanned and represent a hyperlink. They can also be smaller than writing out the entire link. They have some protections against damage but not as much as the simple barcode.

A QR code is basically just a fancy barcode.

Look at any product and you will find a barcode on it somewhere – a pattern of white and black stripes designed so that a computer can easily scan it and tell what that item is. In this case the thickness of each bar corresponds to a digit between 0-9, so the computer scans it, reads out a number, and that number will refer to an item on a big list.

QR codes follow the same ideas, just a bit fancier. When the computer spots a QR code, or scans over the block and notes whether each square in the pattern is black or white, reading out a long number made up of ones and zeros – which it turns out is the same system computers use to store data.

So the same way a barcode reader will read out a ~13 digit number, a QR reader will read out a string of ASCII text (which can vary in length, up to a free thousand characters long for some larger format codes).

The reason you phone knows what these are is because it has been programmed to. In the same way that your camera will be programmed to recognise a face in an image, it will also recognise the distinctive patterns of a QR code and try to read it – if you look at different QR codes, you may see certain common details between them all, such as the same markers placed in the corners of each pattern that a camera can look for.

A QR code, or Quick Response code, is a way of encoding text into a visual format that’s easy for computers to read. These days, it’s possible to point a camera at a piece of text and have a powerful computer like the ones in most smartphones work out what that text is, but it’s prone to error because of differences in fonts and writing styles, and there’s no effective way to detect if there has been an error with what the computer has read. QR codes are a way to solve these issues, and were also developed back when it wasn’t easy to detect text in a photo. The computer works out the orientation of the QR code by searching for the large squares in 3 of the corners, and then looks at the white and black squares in between to work out the encoded message. Letters are represented by groups of squares with a certain pattern of black and white, and there is a specific order to read these groups in based on the size of the QR code. Then, there is a complicated system to detect if there is an error in the design of the QR code or how it was read. If it all goes correctly, then your computer is able to decode the QR code into a short piece of text, and if the text is a link, then it will take you to that link.

You’re sort of familiar with the idea of Morse code, right? The long-short-long pulses they’d send over telegraph wires in the olden days?

Imagine taking a string of text, like a website URL, and converting it to some kind of Morse-like code. You could write it down as a sequence of dots and dashes on some notebook paper.

Those dots and dashes are kind of hard for a computer to read using a camera. Perhaps instead of dots and dashes, we can use light and dark. Those are pretty easy to pick out. Let’s swap out our notebook for a graph paper notebook, so we can use the little graph squares. Instead of writing dots and dashes, we can instead create a sequence of filled-in squares and blank squares to represent our message.

If you took that string of squares and extended them up and down so it became a series of lines (which makes them even easier for a computer to see), you will have essentially invented the barcode. Just like the ones the scanners at the store use.

So, what if the thing you’re trying to write out is really long? That would create a looong barcode. What could you do? Well, if you were writing that long URL in regular text in a notebook, and you ran out of room, what would you do there? Snap it off somewhere and start writing it on the next line, right? You can do that with your barcode, too. Once your run out of squares on your graph paper, just start writing on the next line, and keep going until your whole message is encoded. If you’re really clever with this, you can even do it in such a way that the final result looks kind of square-ish.

And that’s it. You’ve essentially invented the QR code. A computer can take a picture of that, use scanning software to pick out the light and dark squares, convert it to a string of Morse-like code, and decode it into plain text. It can then recognize it as a URL (if it is one) and may even open that URL right away without needing to be asked. The computer is so quick at this that it all happens basically instantly.

There are nuances that I glossed over, of course. QR codes are more complex than that. For instance, the funny square patterns in only three of the corners. Those markers are essentially the same thing as the “THIS SIDE UP” marking on a cardboard box. It tells the computer which part of the code is the starting point. With that info built-in, you can photograph a QR code sideways, right side up, upside down, or any other orientation and the computer can just figure it out and read it anyway. There’s also some clever error-correction stuff crammed in there so that even if small bits of the code are obscured, or blurry, the computer can still correctly guess the message.