cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.64k stars 602 forks source link

Doesnt recognize a 1 pixel QR code #177

Open rob-lutrons opened 4 years ago

rob-lutrons commented 4 years ago

Hi,

I have a 1D bit array which represents entire QR code, including finder modules. I tried converting to RGBa bitmap 1 -> 0,0,0,255 and 0 -> 255,255,255,255 so I could pass it to jsQR. jsQR finds nothing.

When I write the bitmap to file, it looks fine visually and looks like the actual QR code its based on.

Is this the right approach? Is there a function I can just pass the raw data to?

I'm working on a nodeJS solution.

Thanks.

Here's a zoomed in view of the output image... image

rob-lutrons commented 4 years ago

Oh, and I'm able to decode the image using https://zxing.org/

tyomitch commented 3 years ago

Because of https://github.com/cozmo/jsQR/blob/master/src/binarizer/index.ts#L100-L104 jsQR cannot handle images smaller than 33x33 pixels. (This should probably be documented?) Passing an image with single-pixel modules on a 33x33 white background works fine. Do remember also that there must be a one-module-wide white margin around the code.

cozmo commented 2 years ago

Oh interesting, this isn't a case we'd though of I don't think. I think rather than documenting it might make sense to instead just pad the image before the binarize step...