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

Cannot decode this image,But other software can #138

Open VKingi opened 5 years ago

VKingi commented 5 years ago

ims

TomasHubelbauer commented 5 years ago

Are you trying to decode this image as is shown or through a camera? I'm asking because I also had problems feeding this library images which were generated, but when I took a picture of them, then it worked.

VKingi commented 5 years ago

Are you trying to decode this image as is shown or through a camera? I'm asking because I also had problems feeding this library images which were generated, but when I took a picture of them, then it worked.

Run our demo through PC and scan this qr code picture in my phone, and decodethe error. Can you decode this image by jsQR?

totorelmatador commented 5 years ago

I've got the same issue with QRCode of that dimension. I'm running the code through PC, not with a camera. Nevertheless jsQR extract binaryData, but the data field is empty.

francovp commented 4 years ago

Any solution to decode binaryData?

eventualbuddha commented 4 years ago

FWIW, this is what I get with jsqr@1.3.0:

  binaryData: [
    176, 174, 201, 207,  82, 101,  98, 101,  99,  99,  97,  45,
    178, 169, 191, 205, 163, 172, 214, 187, 206, 170, 203, 188,
    196, 238, 182, 248, 189, 168, 161, 173, 161, 173,  13,  10,
    196, 227, 178, 187, 187, 225, 214, 170, 181, 192, 163, 172,
    213, 226, 212, 211, 194, 210, 181, 196, 182, 254, 206, 172,
    194, 235, 192, 239, 163, 172, 188, 196, 205, 208, 215, 197,
    206, 210, 182, 212, 196, 227, 181, 196, 206, 222, 207, 222,
    203, 188, 196, 238,  13,  10, 176, 174, 196, 227, 163, 172,
    213, 230, 181, 196,
    ... 14 more items
  ],
  data: '羇瞶籌羞罐豬',
  chunks: [
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '羇' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '瞶' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '籌' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '羞' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '罐' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '豬' },
    { type: 'byte', bytes: [Array], text: '' }
  ],

Is that what you expect, @VKingi?

VKingi commented 4 years ago

FWIW,这是我通过jsqr@1.3.0获得的:

  binaryData: [
    176, 174, 201, 207,  82, 101,  98, 101,  99,  99,  97,  45,
    178, 169, 191, 205, 163, 172, 214, 187, 206, 170, 203, 188,
    196, 238, 182, 248, 189, 168, 161, 173, 161, 173,  13,  10,
    196, 227, 178, 187, 187, 225, 214, 170, 181, 192, 163, 172,
    213, 226, 212, 211, 194, 210, 181, 196, 182, 254, 206, 172,
    194, 235, 192, 239, 163, 172, 188, 196, 205, 208, 215, 197,
    206, 210, 182, 212, 196, 227, 181, 196, 206, 222, 207, 222,
    203, 188, 196, 238,  13,  10, 176, 174, 196, 227, 163, 172,
    213, 230, 181, 196,
    ... 14 more items
  ],
  data: '羇瞶籌羞罐豬',
  chunks: [
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '羇' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '瞶' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '籌' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '羞' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '罐' },
    { type: 'byte', bytes: [Array], text: '' },
    { type: 'kanji', bytes: [Array], text: '豬' },
    { type: 'byte', bytes: [Array], text: '' }
  ],

@VKingi是您所期望的吗?

Yes, it seems to be the data I want! After analysis, the qr code data seems to be ANSI coding,Byte [] converted to string error.

VKingi commented 4 years ago

Existing solutions:

// Create the Uint8Array array
let uint8Array = new Uint8Array(code.binaryData);
// encodings: Specify the required encoding
alert( new TextDecoder(encodings).decode(uint8Array) );

Intelligent automatic recognition code would be better ... : )