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

Wont scan if canvas is small. #66

Closed MickyDNet closed 6 years ago

MickyDNet commented 6 years ago

I've had to create a large canvas and a small canvas because it will not scan the qr code if the main canvas is small. This is making my page extremely slow :/

cozmo commented 6 years ago

As mentioned here jsQR is built to be agnostic around where the image data comes from. It has no specific support for webcams vs just providing images directly etc. All it needs is raw image data that may contain a QR code. If you pass it an image too small to read (whether it be from a webcam or otherwise) it won't be able to find a code within.

I am not a webcam expert and I don't your constraints so unfortunately I may not be able to provide much help here. One idea that might be worth trying is shrinking your canvas with CSS so that the underlying canvas is full resolution, but visually it's shrunk to fit wherever you need it. I tried this real quick with our example code and it seems to work quite well.

If that doesn't work I'd suggest you try stack overflow or some other place where users may have more knowledge around webcams and canvas elements.