html5-qrcode icon indicating copy to clipboard operation
html5-qrcode copied to clipboard

Cannot read small QR codes

Open zibranyiszgabor opened this issue 4 years ago • 12 comments

Describe the bug Cannot read 1cm or smaller size codes. The phone's default focus is already far from the code .

Smartphone (please complete the following information):

  • Android: sometimes succeed
  • Iphone: never succeed

Additional context The camera's image is too far from the code. It would be a solution if we could add the camera starting zoom beside qrbox parameter or would work the zoom while reading.

zibranyiszgabor avatar Jul 07 '21 14:07 zibranyiszgabor

I think this is really depending on the camera quality. I have tested many different cameras, external and builtin from computers, laptop and smartphones and the results vary extremely.

ROBERT-MCDOWELL avatar Jul 27 '21 12:07 ROBERT-MCDOWELL

also, keep in mind the normal time use of cameras, it can be an iphone, but if this iphone had tough time in its life with the lens so the quality will be less and can affect the scanning.

ROBERT-MCDOWELL avatar Jul 27 '21 12:07 ROBERT-MCDOWELL

I try this with an iPhone 12 Pro Max. If a Barcode Code_39 is 3 cm in width and keeps only 5 Numbers, the iPhone is not able to read the Barcode. If the Barcode is at lest 4 cm width it works. With a nativ Barcode App its working also with the smaller Barcode. One reason is maybe the nativ App has autofocus und zoom functionality.

unimatrix73 avatar Aug 04 '21 05:08 unimatrix73

Even QR codes with the size of 2cm x 2cm are not scanned. (iPhone SE 14)

pyzenberg avatar Oct 04 '21 04:10 pyzenberg

This can probably be addressed with zoom feature - https://github.com/mebjas/html5-qrcode/issues/290#issuecomment-934566054

I'll work on it.

mebjas avatar Oct 05 '21 16:10 mebjas

Feature request for zoom feature: https://github.com/mebjas/html5-qrcode/issues/330

mebjas avatar Oct 21 '21 10:10 mebjas

Zoom feature suppprt added to Html5QrcodeScanner with version 2.3.2

Check release: https://github.com/mebjas/html5-qrcode/releases/tag/v2.3.2

mebjas avatar Nov 22 '22 12:11 mebjas

I used the latest update, 2.3.2, it works well for Android but for iOS it doesn't work for small dimensions shape (1cm * 1cm). It is 2D Data Matrix and the target system is iOS version 16 Please advise

ehabnady avatar Jan 23 '23 13:01 ehabnady

I do also have the problem that reading small QR-Codes does not work using an iPad. The QR-Codes do have a size of approx. 3x3cm. And I need to use the front camera on the same side as the display.

Larger codes do work perfectly! But for the small codes, you have to place them close to the lense and so they are out of focus. If you place them with a larger distance to the lense, they are too small to read.

Is there any advice on this? Any possibility to zoom in? Thank you.

tobias77X avatar Jun 28 '23 14:06 tobias77X

Same issue. Do you guys have any update on fixing it for iOS?

Thanks for all the good work!

luenib avatar Apr 24 '24 17:04 luenib

any solutions?

ssch-99 avatar May 03 '24 14:05 ssch-99

@luenib @ssch-99 @tobias77X

I solve this by using a barcode-detector polyfill and also increase the video constraints. Here is my working code (tested on iOS Safari):

import "barcode-detector/side-effects";
import { BarcodeDetector } from "barcode-detector/pure";

        try {
          // Use video without audio
          const constraints: MediaStreamConstraints = {
            video: {
              facingMode: { exact: "environment" },
              width: { min: 1024, ideal: 4096, max: 4096 },
              height: { min: 540, ideal: 2160, max: 2160 },
              frameRate: { ideal: 60, max: 60 },
            },
            audio: false,
          };

          // Start video stream
          stream = await navigator.mediaDevices.getUserMedia(constraints);
          videoElmRef.current.srcObject = stream;

          const barcodeDetector = new BarcodeDetector({
            formats: ["qr_code"],
          });

          const detectCode = async () => {
            if (videoElmRef.current) {
              // Start detecting codes on to the video element
              const codes = await barcodeDetector.detect(videoElmRef.current);

              // If no codes exit function
              if (codes.length === 0) return;

              setStartScanned(false);
              onDone(codes[0].rawValue);
            }
          };

          intervalId = setInterval(() => detectCode(), 100);
        } catch (e: any) {
          setErrorMessage(e);
        }
`

ngothanhtai avatar Jun 18 '24 06:06 ngothanhtai