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.63k stars 600 forks source link

Any Idea why this Qr Can Not be Parsed? #201

Open ewkonzo opened 3 years ago

ewkonzo commented 3 years ago

5c8a3959-89b0-48cb-9a91-2b32843417af

azack commented 3 years ago

Works for me with jsqr@^1.4.0 and upng-js@^2.1.0 as a helper (since this is a test):

 const pngBuffer = fs.readFileSync(
      "tests/unit/src/views/data/115042899-92ee0c00-9edc-11eb-9a4b-b0298453765d.png"
    );
    const pngData: upng.Image = upng.decode(pngBuffer);
    const qrArray = new Uint8ClampedArray(upng.toRGBA8(pngData)[0]);
    const mockImageData: ImageData = {
      data: qrArray,
      height: 1125,
      width: 576
    };
    ...
     const code = jsQR(
        mockImageData.data,
        mockImageData.width,
        mockImageData.height
      );
    if (code) {
      console.log("Found QR code", code);
    }
   Found QR code {
      binaryData: [
        104, 116, 116, 112, 115, 58,
         47,  47,  97,  98,  99, 46,
        107, 111, 110, 122, 111, 46,
        120, 121, 122,  47
      ],
      data: 'https://abc.konzo.xyz/',
      chunks: [ { type: 'byte', bytes: [Array], text: 'https://abc.konzo.xyz/' } ],
      version: 3,
      location: {
        topRightCorner: { x: 346, y: 865 },
        topLeftCorner: { x: 230, y: 865 },
        bottomRightCorner: { x: 346, y: 981 },
        bottomLeftCorner: { x: 230, y: 981 },
        topRightFinderPattern: { x: 332, y: 879 },
        topLeftFinderPattern: { x: 244, y: 879 },
        bottomLeftFinderPattern: { x: 244, y: 967 },
        bottomRightAlignmentPattern: { x: 320, y: 955 }
      }
    }