How QR codes work

The first elements to consider are the boxes in the corners, they serve as the skeleton of the code.

The pandemic has opened new uses of the QR code, such as the mobility pass scanner to carry out certain activities. In addition to being used in plane trips, buses and even food menus. It is an intuitive mechanism that we already have standardized.

But well, what is behind QR codes? How do they work?

To begin, the first elements to consider are the boxes in the corners, they serve as skeleton of the code. When a QR code is scanned with the cell phone, a program on the device begins to look for patterns in the image, its main guide is the upper corners and in the lower part the left corner.

Depending on the number of dots and squares it has, it will contain more or less information. More technically it is explained that the bytes, or 8-bit blocks, are represented in the QR code as blocks of 8 white or black points. For each bit that I want to "draw", I will put a white square if the bit is 0 or a black square if it is 1.

The point density of a QR code represents the amount of information it contains. There are images that are configured to store the address to a web page, which is enough with a few pixels, but the more text stored, the more spots and spaces within the code. Also, being in black and white makes it easier for cameras to capture them quickly.

Although QR codes can be customized in color and shape, the generic choice of black and white is no accident. Contrast helps cameras identify codes even in low light. In addition, the codes are surrounded by a frame without content, the so-called "still zone", which helps to isolate it from the rest of the environment to make it more recognizable for our cameras.

The smaller squares, called alignment squares, help the device to correct the position and orientation of the code in the image, so that they can read the code even if we are taking the photo upside down.