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.73k stars 607 forks source link

Error: Malformed data passed to binarizer. #237

Open jarawin opened 1 year ago

crapthings commented 1 year ago

same here, what is wrong?

LaserKaspar commented 1 year ago

You need to provide more detail. This error usually comes up when the passed in image data has something other than 4 channels. This can either be fixed by converting your input to rgba:

for (let i = 0; i < rgbArray.length; i += 3) {
  rgbaArray[i] = rgbArray[i];
  rgbaArray[i + 1] = rgbArray[i + 1];
  rgbaArray[i + 2] = rgbArray[i + 2];
  rgbaArray[i + 3] = 255; // Alpha channel set to 255 (fully opaque)
}

or by editing the source to understand rgb <- Way more efficient, but would need to be done by a maintainer of the reop.