Live data from Hacker News

Tiny Code Reader: a $7 QR code sensor

excamera.substack.com

31–40 of 44 posts

Re: Tiny Code Reader: a $7 QR code sensor

#31
post #28

Earlier quoted context omitted.

Using https://duckduckgo.com/?q=qrcode%20decode%20by%20hand gives me a number of results like http://blog.qartis.com/decoding-small-qr-codes-by-hand/ https://beck-thompson.github.io/QRcodewebsite/ Reading QR codes without a computer! https://qr.blinry.org/ And then there are a number of OSS implementations for Android (check fdroid.orgl, Debian/Ubuntu, etc. Maybe study the code?

That’s not what I’m asking about: once you’ve found the QR code in the bag of pixels you got from your camera and converted it to a boolean array of module colours, then yes, all you have left is a bit error-correction math and some amusingly archaic Japanese character encoding schemes—definitely some work, but ultimately just some work. (For that matter, the Wikipedia article on QR codes contains enough detail to do…

> What has thus far remained a mystery to me is going from a bag of noisy pixels [...] to array of booleans.

Ah, OK. You can use software like ImageMagick to partition images into levels of gray or just black and white. I have some examples somewhere I played with some time ago, but not accessible online right now, sorry. If the contrast of the original image is high enough, just the qrcode would remain to be parsed.

Re: Tiny Code Reader: a $7 QR code sensor

#32
post #31

Earlier quoted context omitted.

That’s not what I’m asking about: once you’ve found the QR code in the bag of pixels you got from your camera and converted it to a boolean array of module colours, then yes, all you have left is a bit error-correction math and some amusingly archaic Japanese character encoding schemes—definitely some work, but ultimately just some work. (For that matter, the Wikipedia article on QR codes contains enough detail to do…

> What has thus far remained a mystery to me is going from a bag of noisy pixels [...] to array of booleans. Ah, OK. You can use software like ImageMagick to partition images into levels of gray or just black and white. I have some examples somewhere I played with some time ago, but not accessible online right now, sorry. If the contrast of the original image is high enough, just the qrcode would remain to be parsed.

Here's an example to start with: ImageMagick's -threshold or -adaptive-threshold (depending on the image's lighting) are what you want to look at, e.g. try something like

    magick input.jpg \
      -colorspace Gray \
      -adaptive-threshold 8x8+10% \
      candidate.png

Re: Tiny Code Reader: a $7 QR code sensor

#33
post #16

Anyone who knows of a cheap sensor that works in Linux and can read Digikey bag barcodes?

I'm unclear about a specific sensor, but it looks like the format you want to decode would be "Data Matrix ECC 200"

https://forum.digikey.com/t/digikey-product-labels-decoding-...

I think a smartphone and custom app would be the worst case scenario in terms of cost, and that could be pretty cheap.

Re: Tiny Code Reader: a $7 QR code sensor

#34
post #32
post #31

Earlier quoted context omitted.

> What has thus far remained a mystery to me is going from a bag of noisy pixels [...] to array of booleans. Ah, OK. You can use software like ImageMagick to partition images into levels of gray or just black and white. I have some examples somewhere I played with some time ago, but not accessible online right now, sorry. If the contrast of the original image is high enough, just the qrcode would remain to be parsed.

Here's an example to start with: ImageMagick's -threshold or -adaptive-threshold (depending on the image's lighting) are what you want to look at, e.g. try something like magick input.jpg \ -colorspace Gray \ -adaptive-threshold 8x8+10% \ candidate.png

And if you wanna go even lower, you'll "raw" read the image pixel by pixel to normalise colour to black/white and then read that matrix for the QR pattern.

And then, cause there are some inverted colour QRs, flip and scan again.

Re: Tiny Code Reader: a $7 QR code sensor

#35

Somewhat incidentally, is there an actual description of how a low-tech QR code reader would work? I’ve looked for this a few years ago and all solutions I could find were of two flavours: (1) use ZXing (“Zebra Crossing”, a now-unmaintained library[1] for every 1D and 2D barcode under the sun); (2) use OpenCV. Nowhere could I find any discussion of how one would actually deal with the image-processing part by hand. A…

There's zxing-cpp that is a fork of zxing and actively maintained: https://github.com/zxing-cpp/zxing-cpp

Re: Tiny Code Reader: a $7 QR code sensor

#36

Earlier quoted context omitted.

Just checked and the cost for a (non aliexpress) seller ESP32-CAM dev board is around £5-£6 or less than £1 from aliexpress

Aliexpress listings can have multiple different items, and the price displayed in the search results will be that of the first of those (in your case, probably just an antenna) rather than the actual item you searched for or even the item image shown on the results page.

Not just the first, seems like the cheapest. I did a quick search and one result listed the second object's price, which was some permanent adapter board. But it's hard to fix such a thing. For example what if you really did want to buy another antenna for the device? Ok so maybe you require the listed price be the maximum. But what about like a raspberry pi kit where maybe you don't want the case or high capacity sd card or RAM, which could bring down the cost dramatically.

Re: Tiny Code Reader: a $7 QR code sensor

#39

Somewhat incidentally, is there an actual description of how a low-tech QR code reader would work? I’ve looked for this a few years ago and all solutions I could find were of two flavours: (1) use ZXing (“Zebra Crossing”, a now-unmaintained library[1] for every 1D and 2D barcode under the sun); (2) use OpenCV. Nowhere could I find any discussion of how one would actually deal with the image-processing part by hand. A…

You can roughly divide barcode reading into a "frontend" and a "backend". The backend is the most well understood (but not necessarily trivial) part: you take a binary image, with each pixel corresponding to one little square in the QR code, and decode its payload. It doesn't need computer vision. The "frontend" is the part that takes the raw image containing the barcode and tries to find the barcode, and convert the barcode it finds into a nice, clean binary image for the backend. This is a computer vision problem and you can arbitrarily fancy, including up to using the latest trends in ML vision models. However, this isn't necessarily needed in most cases; after all, barcodes are designed to be easy to read for machines. With a large, sufficiently well focused and well exposed image of a barcode you can get away with simple classical computer vision algorithms like histogram-based binarization and some heuristics to identify the spatial extent of the barcode (for example, most barcode symbologies mandate "quiet space" (blank space) to be around the barcode, and have start and stop markers; QR codes have those prominent concentric squares on the corners).

As for implementation, Zxing-cpp [1] is still maintained, and pretty good as far as open source options go. At this point I'm not sure how related it is to the original zxing, as it has gone substantial development. It has python bindings which may be easier to use.

On mobile, Google MLkit and Apple vision also have barcode reading APIs, not open source but otherwise "free" as in beer.

[1] https://github.com/zxing-cpp/zxing-cpp

Re: Tiny Code Reader: a $7 QR code sensor

#40
post #28

Earlier quoted context omitted.

Using https://duckduckgo.com/?q=qrcode%20decode%20by%20hand gives me a number of results like http://blog.qartis.com/decoding-small-qr-codes-by-hand/ https://beck-thompson.github.io/QRcodewebsite/ Reading QR codes without a computer! https://qr.blinry.org/ And then there are a number of OSS implementations for Android (check fdroid.orgl, Debian/Ubuntu, etc. Maybe study the code?

That’s not what I’m asking about: once you’ve found the QR code in the bag of pixels you got from your camera and converted it to a boolean array of module colours, then yes, all you have left is a bit error-correction math and some amusingly archaic Japanese character encoding schemes—definitely some work, but ultimately just some work. (For that matter, the Wikipedia article on QR codes contains enough detail to do…

You can examine the code of zxing-cpp (which is fairly nice IMO) for a simple, "classical computer vision" approach to this. It's not the most robust implementation but it is pretty functional.

But in general, you can divide the problem more or less like this (not necessarily in this order) 1. find the rough spatial region of the barcode. Crop that out and only focus on this 2. Correct ("rectify") for any rotation or perspective skew of the barcode, turn it into a frontoparallel version of the barcode 3. Binarize the image from RGB or grayscale into pure black and white 4. Normalize the size so that each pixel is the smallest spatial unit of the barcode.

Post reply on HN