cozmo/jsQR

Error: Malformed data passed to binarizer.

Opened this issue · 2 comments

Error: Malformed data passed to binarizer.

same here, what is wrong?

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.