Studying QR Code Degradation

It’s fair to say that QR codes are a technology that has finally come of age. A decade or more ago they were a little over-hyped and sometimes used in inappropriate or pointless ways, but now they are an accepted and useful part of life.

They’re not without their faults though, one of which is that despite four increasingly redundant levels of error correction, there comes a point at which a degraded QR code can no longer be read. [HumanQR] is soliciting these broken QR codes for research purposes and inclusion in an eventual open-source database, and they’ll even have a shot at repairing your submissions for you.

It’s a problem inherent to all digital media, that once the limit of whatever error correction they contain has been reached, they arrive at a cliff-edge at which they go immediately from readability to non readability. The example given in the linked article is a locator tag on a stray cat, it had been rubbed away in part. Improving its contrast, sharply defining its edges, and improving the definition of its fiducials was able to revive it, we hope leading to the cat being returned home.

The idea is that by studying enough damaged codes it should be possible to identify the means by which they become degraded, and perhaps come up with a way to inform some repair software. Meanwhile if you are interested, you might want to learn more about how they work, the hard way.

Archiving Data On Paper Using 2D Images

It seems like only yesterday we covered a project using QR codes to archive data on paper (OK, it was last Thursday), so here’s another way to do it, this time with a dedicated codec using the full page. Optar or OPTical ARchiver is a project capable of squeezing a whopping 200 Kb of data onto a single A4 sheet of paper, with writing and reading achieved with a standard laser printer and a scanner. It’s a bit harder than you might think to get that much data on the page, given that even a 600 DPI printer can’t reliably place every dot each time. Additionally, paper is rarely uniform at the microscopic scale, so Optar utilizes a forward error-correcting coding scheme to cater for a little irregularity in both printing and scanning.

The error-correcting scheme selected was an Extended Golay code (24, 12, 8),  which, interestingly, was also used for image transmission by the NASA Voyager 1 and 2 missions. In information theory terms, this scheme has a minimum Hamming Distance of 8, giving detection of up to seven bit errors. This Golay code implementation is capable of correcting three-bit errors in each 24-bit block, with 12 bits available for payload. That’s what the numbers in those brackets mean.

Another interesting problem is paper stretch during printing. A laser printer works by feeding the paper around rollers, some of which are heated. As a printer wears or gets dirty, the friction coefficient along the rollers can vary, leading to twisting and stretching of the paper during the printing process. Water absorbed by the paper can also lead to distortion. To compensate for these effects, Optar regularly inserts calibration targets throughout the bit image, which are used to locally resynchronize the decoding process as the image is processed. This is roughly similar to how the alignment patterns work within larger QR codes. Finally, similar to the position detection targets (those square bits) in QR codes, Optar uses a two-pixel-wide border around the bit image. The border is used to align to the corners well enough to locate the rows of bits to be decoded.

In the distant past of last week, we covered a similar project that uses QR codes. This got us thinking about how QR codes work, and even if encoding capacity can be increased using more colors than just black and white?

Thanks to [Petr] for the tip!

Wolverine Gives Your Python Scripts The Ability To Self-Heal

[BioBootloader] combined Python and a hefty dose of of AI for a fascinating proof of concept: self-healing Python scripts. He shows things working in a video, embedded below the break, but we’ll also describe what happens right here.

The demo Python script is a simple calculator that works from the command line, and [BioBootloader] introduces a few bugs to it. He misspells a variable used as a return value, and deletes the subtract_numbers(a, b) function entirely. Running this script by itself simply crashes, but using Wolverine on it has a very different outcome.