Live data from Hacker News

Reading QR codes without a computer

qr.blinry.org

11–20 of 93 posts

Re: Reading QR codes without a computer

#11

> So is the rest all content? Not quite! There is also error correction, which is used to make sure that the QR code can still be read even if some parts are damaged, blurry, or missing. The error correction is generated by some fancy math, and we don't care about it here for the purpose of reading it by hand. This should be explained better... I mean sure, the math can be hard.. but is the error correction appended…

the data in the code is encoded as a bitstream using possibly different alphabets, byte is just one of them.

Then, depending on the size and error correction level (not covered in the article where this is decoded from) the bitstream is split up into blocks, ecc data is calculated for both, and then the blocks are interleaved.

So this method will fail for any qr version above 5 for any level of ecc, and 3-5 with high levels of ecc.

Re: Reading QR codes without a computer

#12
post #6

Stupid 'trivia' question, but could someone generate the 'darkest' (most black pixels) and 'brightest (most white pixels) QR codes possible?

It’s of course possible, but the spec is trying to avoid this. There are multiple “masking patterns”, and the algorithm should choose one that gives fewest “penalty points”. Large single color areas are a lot of penalty points, so QR algorithm is trying to avoid them.

An encoder should try to avoid them, but in theory it doesn't have to, right?

Re: Reading QR codes without a computer

#13
Related submissions:

Decoding small QR codes by hand (2012) - https://news.ycombinator.com/item?id=36173441 - Jun 2023 (69 comments)

How a QR code works - https://news.ycombinator.com/item?id=32837565 - Sep 2022 (114 comments)

Creating a QR Code step by step - https://news.ycombinator.com/item?id=24119124 - Aug 2020 (41 comments)

Creating a QR Code step by step - https://news.ycombinator.com/item?id=18360847 - Nov 2018 (34 comments)

Re: Reading QR codes without a computer

#14
My friends often joke that a person who is checking our tickets is able to do precisely this mentally in their head – when that person is satisfied by seeing a QR code rather than scanning it.

It became very popular over here with the Green Passes (EU Digital Covid Vaccination Certificates). Waiters, etc. were supposed to check whether the guests are vaccinated, but 99% of them just demanded any random QR code to be shown to them, took a look at it and considered it done.

Unless we are a country of hidden math geniuses :)

Re: Reading QR codes without a computer

#15
post #12

Earlier quoted context omitted.

It’s of course possible, but the spec is trying to avoid this. There are multiple “masking patterns”, and the algorithm should choose one that gives fewest “penalty points”. Large single color areas are a lot of penalty points, so QR algorithm is trying to avoid them.

An encoder should try to avoid them, but in theory it doesn't have to, right?

Yeah, it's not mandatory. The specification itself recommends a very concrete algorithm though, and one of its criteria is literally the average density [1].

[1] https://github.com/lifthrasiir/qr.js/blob/52f0409a22c5ece6a5...

Re: Reading QR codes without a computer

#16
post #4
post #3

I tried reading them manually about ten years ago, but gave up because of the mask. The mask pattern needs to be applied (xor) before you can even tell as much as the data type... Does anyone know how much it actually helps QR code readers to have this mask pattern applied? Last month, I tried to find out what the optimal error correction setting is (answer: none, if the matrix isn't damaged, like in my use-case wher…

The error correction is funny. If you don't use it, your message takes up less space, and the QR is smaller. If you have a fixed space to fit it in (e.g. printing to a sticker), that means your pixels can be physically bigger. For reliable reading, I found that physically bigger pixels helped more than the error correction itself. Depending on the length of your message, sometimes you can turn up the error correction…

This is actually "cameras can't focus close, and QR scanners aren't good at seeing a code which is tiny in the frame".

By making the pixels of the code bigger, the camera can be a bit blurry to get the code big enough, and then it'll read.

Re: Reading QR codes without a computer

#17
post #4

Earlier quoted context omitted.

The error correction is funny. If you don't use it, your message takes up less space, and the QR is smaller. If you have a fixed space to fit it in (e.g. printing to a sticker), that means your pixels can be physically bigger. For reliable reading, I found that physically bigger pixels helped more than the error correction itself. Depending on the length of your message, sometimes you can turn up the error correction…

This is actually "cameras can't focus close, and QR scanners aren't good at seeing a code which is tiny in the frame". By making the pixels of the code bigger, the camera can be a bit blurry to get the code big enough, and then it'll read.

[deleted]

Re: Reading QR codes without a computer

#18
post #4

Earlier quoted context omitted.

The error correction is funny. If you don't use it, your message takes up less space, and the QR is smaller. If you have a fixed space to fit it in (e.g. printing to a sticker), that means your pixels can be physically bigger. For reliable reading, I found that physically bigger pixels helped more than the error correction itself. Depending on the length of your message, sometimes you can turn up the error correction…

This is actually "cameras can't focus close, and QR scanners aren't good at seeing a code which is tiny in the frame". By making the pixels of the code bigger, the camera can be a bit blurry to get the code big enough, and then it'll read.

I mean, that's kinda the whole point? The precise details of the optic path don't really matter, bigger pixels will always be easier to resolve.

One might reasonably expect error correction to help with the decode of blurry inputs, but that wasn't really the case in my experiments.

Re: Reading QR codes without a computer

#20

> So is the rest all content? Not quite! There is also error correction, which is used to make sure that the QR code can still be read even if some parts are damaged, blurry, or missing. The error correction is generated by some fancy math, and we don't care about it here for the purpose of reading it by hand. This should be explained better... I mean sure, the math can be hard.. but is the error correction appended…

Barcodes use the last digit as a checksum. The checksum is some adding up the numbers and multiplying or something, then % 10 (only 0-9 possible values). As you can see with this math, the error checking has a 1/10 of a chance of coincidentally showing a correct checksum in cases where the data is incorrect. Either way, that last digit on barcodes is insignificant to the actual product's unique barcode ID.

Fun story: The barcode was ripped and the checksum # was frayed off of an item I was returning to Home Depot. I frantically tried to do the math quicker that the checker could manually look it up. But they won and I'll never forget it.

https://www.gs1.org/services/how-calculate-check-digit-manua...

https://www.simplybarcodes.com/barcode_check_digit_calculato...

Post reply on HN