Live data from Hacker News

Reading QR codes without a computer

qr.blinry.org

81–90 of 93 posts

Re: Reading QR codes without a computer

#81
post #63
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…

Physically bigger pixels help a lot indeed. The encoding mode also helps make pixels bigger. This is very convenient when you control the QR reader and need to represent long numeric identifiers like UUIDs. For example: 9728983f-7d7d-4189-b624-f92781e36650 (lowercase UUID): => length=36, 15 pixels between markers JWM9GFVXFN0RKDH4Z4KR3RV6A0 (base32 UUID): => length=26, 11 pixels between markers 9728983F-7D7D-4189-B624…

You can also use base45 [1]:

  -4J5BJ+%F$C881NIMV-IG2.C (base45, 132 bits in QR)
  JWM9GFVXFN0RKDH4Z4KR3RV6A0 (base32, 143 bits in QR)
  200924207194334734815443970355691218512 (decimal, 130 bits in QR)
It will make use of all allowed characters in the alphanumeric mode, while being significantly shorter than base32 and as dense as decimal. And decimal encoding in general needs bignum, because there is no suitable 10^k which is only slightly larger than powers of two so no convenient binary-to-decimal encoding exists (conversely, QR code itself does make use of the fact 2^10 is only slightly larger than 10^3 for this mode). Base45 always works on three-byte groups and maintains the similar efficiency in comparison.

[1] https://datatracker.ietf.org/doc/html/rfc9285

Re: Reading QR codes without a computer

#82
post #63

Earlier quoted context omitted.

Physically bigger pixels help a lot indeed. The encoding mode also helps make pixels bigger. This is very convenient when you control the QR reader and need to represent long numeric identifiers like UUIDs. For example: 9728983f-7d7d-4189-b624-f92781e36650 (lowercase UUID): => length=36, 15 pixels between markers JWM9GFVXFN0RKDH4Z4KR3RV6A0 (base32 UUID): => length=26, 11 pixels between markers 9728983F-7D7D-4189-B624…

You can also use base45 [1]: -4J5BJ+%F$C881NIMV-IG2.C (base45, 132 bits in QR) JWM9GFVXFN0RKDH4Z4KR3RV6A0 (base32, 143 bits in QR) 200924207194334734815443970355691218512 (decimal, 130 bits in QR) It will make use of all allowed characters in the alphanumeric mode, while being significantly shorter than base32 and as dense as decimal. And decimal encoding in general needs bignum, because there is no suitable 10^k whi…

That's neat, especially for arbitrary binary data!

Re: Reading QR codes without a computer

#83
This would have been useful a few weeks back, especially the error correction part!

I was visiting an unmanned business (no-one around) and my phone was dead. I wanted to connect to the wireless but the WiFi sign had only a QR code and no plain text password. I didn't have a QR code scanner on my computer. One of my services uses a QR scanner on the web but I didn't have that project cloned on my MacBook.

Regardless I scanned dependencies of dependencies hoping that some useless NPM dependency or some python package would have a QR code scanner but to no avail.

In my search at least I found (several) parsers which knew how to scan the QR code (exactly what the article is describing) from a picture but no code to go from an image to the binary data. I didn't have OpenCV or any other library I'm familiar with to process images and I deemed it hard to do something without documentation - so I took a photo with PhotoBooth and started converting the picture manually square by square into 0 or 1.

A few minutes later (and plenty of double checking) I had the data and I piped it into one of the parsers et voilà, I had internet.

Re: Reading QR codes without a computer

#85

Earlier quoted context omitted.

When I worked at a grocery store in the 2000s, you didn't need the checksum digit when keying in a barcode by hand. In fact, manually entering the checksum digit would result in a "product not found" error. So I wonder if the checker had to manually look anything up, assuming it was only the checksum digit that was frayed off. Perhaps some POS systems do require the checksum digit for manually-entered barcodes, thoug…

>In fact, manually entering the checksum digit would result in a "product not found" error. That is hilarious to me. The obviously safer approach of checking the check digit was not merely neglected, but actively forbidden.

Barcodes are entered as text. Older barcode scanners used to plug into either the serial port or the PS2 keyboard port; often they had an inline adapter so you could plug it in between your computer and keyboard.

As a checksum, the last digit of the barcode is not part of the data (product number), it's metadata; when the barcode reader beeps, that means it has computed the check digit and it matches the digit on the barcode. The barcode data is sent to the computer, but the check digit is not. The check digit is not in the database. The computer using the UPC leaves it to the barcode reader or human to ensure the input is correct.

You'll might also notice that similar barcodes exist in multiple places as well--unopened cases of products might have an identifier that includes the UPC, and so does the price sticker on the shelf. Both of these include more data than just the UPC.

Re: Reading QR codes without a computer

#86
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 isn't meant for folks like us who think about things like "how can I make this message smaller to increase the readability of the QR code", it's for the people that take their entire tracking parameter-infected URL and dump it into a version 25 (117x117) code and plaster it onto a huge sign out front where a bird promptly shits on it and a teenager slaps a sticker on it and somehow the data remai…

I also have the impression that a common use of error correction is the "QR Code with a logo in the middle" style. With an appropriate level of error correction, you can carve an empty patch in the middle of the logo and slap a logo/icon there, and the QR code remains readable.

At least this is the way I did it years ago when I thought it would be fancy to have my contact data as a QR Code on my visit card.

Re: Reading QR codes without a computer

#88

Earlier quoted context omitted.

The error correction isn't meant for folks like us who think about things like "how can I make this message smaller to increase the readability of the QR code", it's for the people that take their entire tracking parameter-infected URL and dump it into a version 25 (117x117) code and plaster it onto a huge sign out front where a bird promptly shits on it and a teenager slaps a sticker on it and somehow the data remai…

I also have the impression that a common use of error correction is the "QR Code with a logo in the middle" style. With an appropriate level of error correction, you can carve an empty patch in the middle of the logo and slap a logo/icon there, and the QR code remains readable. At least this is the way I did it years ago when I thought it would be fancy to have my contact data as a QR Code on my visit card.

Yes, though I doubt that’s what the creators had in mind.

Re: Reading QR codes without a computer

#89
post #5

Slightly off topic: One day in the late 90s or early 2000s, I wanted to transfer the contents of my Atari 8-bit disks to my PC. I did know about SIO2PC, a cable that converts between Atari's SIO port and the PC's serial port and a piece of software to go with it. But I didn't have the electronics skills to build one (even though it is actually very easy). So I ended up writing a Basic program on the Atari to read dat…

That's definitely worthy of praise. Excellent work. How old were you at the time?

Re: Reading QR codes without a computer

#90

How does one detect the finder patterns when they are not squares?

Not sure. But I'm guessing that the finder patters represent a pattern that is not possible in the data encoding. That is, according the the encoding scheme you couldn't have data that, just by chance looked like a finder pattern.

Also: A more fun and technical sounding term for "finder pattern" is "Fiducial" https://en.wikipedia.org/wiki/Fiducial_marker

Post reply on HN