jsQR
jsQR copied to clipboard
Hello, may I ask if the QR code with lighter color can not be recognized? (请问是不能识别颜色较浅的二维码吗?)
The first two light-colored codes cannot be recognized. Is there a solution? (前两个颜色浅的码识别不了,有办法解决吗?)
With ZBar.wasm(https://github.com/undecaf/zbar-wasm, https://github.com/samsam2310/zbar.wasm), I create an online live sample which outperforming jsQR with ability to detect multiple codes in one frame supporting multiple code types: https://output.jsbin.com/nidonin
Open the link above and point to your colorful QR codes :-)
Here is also a sample based on jsQR for comparision: https://output.jsbin.com/zevavin
You can apply darken filter to your original image data, try both orginal and altered one with jsQR.
We can even make it pure black and white by using the following calculations:
black = 0 - 382 white = 383 - 765
I used follows code, these qr code can be decode.
for (i = 0; i < imgData.data.length; i += 4) {
let count = imgData.data[i] + imgData.data[i + 1] + imgData.data[i + 2];
let colour = 0;
if (count > 383) colour = 255;
imgData.data[i] = colour;
imgData.data[i + 1] = colour;
imgData.data[i + 2] = colour;
imgData.data[i + 3] = 255;
}
Thanks.