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

iPhone 13 & 14 Pro - blurry images - no chance to scan a code

Open NiTRoeSE opened this issue 2 years ago • 21 comments

Hi,

we recognize that a iPhone 13 & 14 Pro are not able to use the scanner because the focus of the cam is not working. A iPhone 12 Pro works as expected.

Any chance to get a fix for this ?

Thanks in Advanced

NiTRoeSE avatar Jan 20 '23 08:01 NiTRoeSE

better to contact apple for the fix....

ROBERT-MCDOWELL avatar Jan 20 '23 12:01 ROBERT-MCDOWELL

better to contact apple for the fix....

The cameras are working fine in any other app. Its like the focus didn't work with html5-qrcode and or the switching to the macro mode of the cams. Like i said a iPhone 12 Pro work as expected ( it has no macro mode ) .. seems to me that html5-qrcode didn't support iPhone 13 & 14 Pro.

NiTRoeSE avatar Jan 20 '23 13:01 NiTRoeSE

the issue comes from apple and browsers, if html5-qrcode works on iphone 12 and not iphone 14 that's because there is an issue between javascript and the device itself.

ROBERT-MCDOWELL avatar Jan 20 '23 13:01 ROBERT-MCDOWELL

I'm having the same issue. Testing on iPhone 14 and latest iOS 16.2 and it will not switch to the macro lens. I've noticed the exact same problem in many 3rd party apps on the app store that worked fine on my iPhone 13. Googling or searching reddit you will find many people complaining. Calling apple is useless, they say app developers need to update their bugs.. IMG_9930CC3E3F7A-1

robdigital avatar Jan 23 '23 22:01 robdigital

Mismo problema con android

jefelon avatar Jan 24 '23 13:01 jefelon

@NiTRoeSE @robdigital check it now. You can toggle between multiple camera options. On my iPhone 13, with the wide angle camera, I'm able to scan code 128 barcodes without the blurriness

@jefelon for android you can add showZoomSliderIfSupported: true to the config. Tested on One Plus 6T and Im able to pick up the barcodes once doing so. See this for reference https://github.com/mebjas/html5-qrcode/releases/tag/v2.3.2

wickedvic avatar Feb 09 '23 04:02 wickedvic

@NiTRoeSE @robdigital check it now. You can toggle between multiple camera options. On my iPhone 13, with the wide angle camera, I'm able to scan code 128 barcodes without the blurriness

Hi, where can i find the updated code to test it ? (Github says last push in any branch is 3 weeks ago ) In Latest version i can only switch between front and back camera on iPhone 14Pro.

NiTRoeSE avatar Feb 09 '23 06:02 NiTRoeSE

play with zoom and focusMode continuous settings

ROBERT-MCDOWELL avatar Feb 09 '23 10:02 ROBERT-MCDOWELL

In IOS we cannot change zoom settings with JavaScript in that case is hard to scan barcodes. Have to wait until something changes Regards

jmldsilva avatar Feb 09 '23 11:02 jmldsilva

so that's the reason why it's much better to open an issue on iOS developer support website and ask them why they decided to lock the focus and zoom with javascript API, this has nothing to do with html5-qrcode.

ROBERT-MCDOWELL avatar Feb 09 '23 11:02 ROBERT-MCDOWELL

@NiTRoeSE @jmldsilva These are the camera options I see on my iPhone 13 Pro IOS 16.3. Both on the online demo as well as my local, Im able to switch between the extra cameras. Between last week and this week I haven't changed anything besides a software update to my phone (16.1 => 16.3). Before this I was also seeing only front/back camera options.

Update: I tested on another iphone 13 Pro on IOS 16.1 and I don't get these extra camera options. Only front and back camera

Update 2: Upgraded from IOS 16.1 => 16.3 on the second iPhone I tested. Went from front and back options to all 5 options shown in screenshot

IMG_1255

wickedvic avatar Feb 09 '23 15:02 wickedvic

Confirmed, this is fixed in iOS 16.3

iOS 16.2: image

iOS 16.3: Selecting Back Ultra Wide Camera on iPhone 14 gives me the best results. image

robdigital avatar Feb 14 '23 18:02 robdigital

I can confirm the same issue on Iphone 13. After Updating to iOS 16.3.1, I am still unable to scan a lot of barcodes (mostly smaller ones) even after changing the cameras. I haven't played around with zoom and focus yet.

alexcgrd avatar Feb 24 '23 15:02 alexcgrd

@NiTRoeSE @jmldsilva These are the camera options I see on my iPhone 13 Pro IOS 16.3. Both on the online demo as well as my local, Im able to switch between the extra cameras. Between last week and this week I haven't changed anything besides a software update to my phone (16.1 => 16.3). Before this I was also seeing only front/back camera options.

Update: I tested on another iphone 13 Pro on IOS 16.1 and I don't get these extra camera options. Only front and back camera

Update 2: Upgraded from IOS 16.1 => 16.3 on the second iPhone I tested. Went from front and back options to all 5 options shown in screenshot

IMG_1255

Hello , But if you try your code in android you can play with zoom settings, with that,scanning is fantastic.

jmldsilva avatar Feb 24 '23 16:02 jmldsilva

I can confirm the same issue on Iphone 13. After Updating to iOS 16.3.1, I am still unable to scan a lot of barcodes (mostly smaller ones) even after changing the cameras. I haven't played around with zoom and focus yet.

Ive shared the code I use in my workflow. For our use case I'm able to scan code 128, QR codes and data matrixs without an issue. Play around with the parameters passed on your local especially qr box. Ive found this setup to be able to scan all the barcodes i've needed on Mac Chrome/Safari, IOS 13 Pro (>=16.3 with Back Ultra Wide Camera) and Android One Plus 6t

import { Html5QrcodeScanner, Html5QrcodeScanType } from "html5-qrcode";
import React, { useEffect, useState } from "react";
import "./BarcodeScanner.css";

function ScannerComponent({ childToParentScanner, cameraToggle }) {
  useEffect(() => {
    if (Html5QrcodeScanner) {
      let html5QrcodeScanner = new Html5QrcodeScanner(
        "reader",

        {
          fps: 10,
          disableFlip: false,
          focusMode: "continuous",
          advanced: [{ zoom: 2.0 }],
          rememberLastUsedCamera: true,
          experimentalFeatures: {
            useBarCodeDetectorIfSupported: true,
          },
          willReadFrequently: true,
          supportedScanTypes: [
            // Html5QrcodeScanType.SCAN_TYPE_FILE,
            Html5QrcodeScanType.SCAN_TYPE_CAMERA,
          ],
          qrbox: {
            width: window.screen.width < 600 ? 200 : 300,
            height: window.screen.width < 600 ? 100 : 100,
          },
        },
        /* verbose= */ false
      );

      function onScanSuccess(data) {
        childToParentScanner(data);

        // Stop scanning
        html5QrcodeScanner
          .clear()
          .then((_) => {
            // the UI should be cleared here
          })
          .catch((error) => {
            console.log("Closing Camera Error");
            // Could not stop scanning for reasons specified in `error`.
            // This conditions should ideally not happen.
          });
      }

      function onScanFailure(error) {
        cameraToggle(html5QrcodeScanner);
        // handle scan failure, usually better to ignore and keep scanning
        console.warn(`QR error = ${error}`);
      }

      html5QrcodeScanner.render(onScanSuccess, onScanFailure);
    }
  }, [Html5QrcodeScanner]);

  return <div id="reader"></div>;
}
export default ScannerComponent;

wickedvic avatar Feb 24 '23 17:02 wickedvic

I can confirm the same issue on Iphone 13. After Updating to iOS 16.3.1, I am still unable to scan a lot of barcodes (mostly smaller ones) even after changing the cameras. I haven't played around with zoom and focus yet.

Ive shared the code I use in my workflow. For our use case I'm able to scan code 128, QR codes and data matrixs without an issue. Play around with the parameters passed on your local especially qr box. Ive found this setup to be able to scan all the barcodes i've needed on Mac Chrome/Safari, IOS 13 Pro (>=16.3 with Back Ultra Wide Camera) and Android One Plus 6t

import { Html5QrcodeScanner, Html5QrcodeScanType } from "html5-qrcode";
import React, { useEffect, useState } from "react";
import "./BarcodeScanner.css";

function ScannerComponent({ childToParentScanner, cameraToggle }) {
  useEffect(() => {
    if (Html5QrcodeScanner) {
      let html5QrcodeScanner = new Html5QrcodeScanner(
        "reader",

        {
          fps: 10,
          disableFlip: false,
          focusMode: "continuous",
          advanced: [{ zoom: 2.0 }],
          rememberLastUsedCamera: true,
          experimentalFeatures: {
            useBarCodeDetectorIfSupported: true,
          },
          willReadFrequently: true,
          supportedScanTypes: [
            // Html5QrcodeScanType.SCAN_TYPE_FILE,
            Html5QrcodeScanType.SCAN_TYPE_CAMERA,
          ],
          qrbox: {
            width: window.screen.width < 600 ? 200 : 300,
            height: window.screen.width < 600 ? 100 : 100,
          },
        },
        /* verbose= */ false
      );

      function onScanSuccess(data) {
        childToParentScanner(data);

        // Stop scanning
        html5QrcodeScanner
          .clear()
          .then((_) => {
            // the UI should be cleared here
          })
          .catch((error) => {
            console.log("Closing Camera Error");
            // Could not stop scanning for reasons specified in `error`.
            // This conditions should ideally not happen.
          });
      }

      function onScanFailure(error) {
        cameraToggle(html5QrcodeScanner);
        // handle scan failure, usually better to ignore and keep scanning
        console.warn(`QR error = ${error}`);
      }

      html5QrcodeScanner.render(onScanSuccess, onScanFailure);
    }
  }, [Html5QrcodeScanner]);

  return <div id="reader"></div>;
}
export default ScannerComponent;

Thank you for the code snippet. I have played around with the zoom and focus configurations but I didn't notice any differences. I have also copied your config into the Html5QrcodeScanner and it didn't make a difference.

On further testing I noticed that cameraCapabilities.zoomFeature().isSupported() returns false on my Iphone 13 in Chrome and in Safari. Is there any reason why it is not supported? The torch feature is also not supported.

I am testing this with Code 39 Barcodes. I am able to scan barcodes with bigger sizes but once they reach a certain size, it becomes impossible to scan. Native Apps don't have any trouble scanning them.

alexcgrd avatar Feb 27 '23 15:02 alexcgrd

@NiTRoeSE @jmldsilva These are the camera options I see on my iPhone 13 Pro IOS 16.3. Both on the online demo as well as my local, Im able to switch between the extra cameras. Between last week and this week I haven't changed anything besides a software update to my phone (16.1 => 16.3). Before this I was also seeing only front/back camera options.

Update: I tested on another iphone 13 Pro on IOS 16.1 and I don't get these extra camera options. Only front and back camera

Update 2: Upgraded from IOS 16.1 => 16.3 on the second iPhone I tested. Went from front and back options to all 5 options shown in screenshot

IMG_1255

Do we have any official article from Apple about this? I can't find any. Thanks!

ErwinThompsonF avatar Aug 11 '23 07:08 ErwinThompsonF

Hi,

we recognize that a iPhone 13 & 14 Pro are not able to use the scanner because the focus of the cam is not working. A iPhone 12 Pro works as expected.

Any chance to get a fix for this ?

Thanks in Advanced

Initialize this class Html5Qrcode into your component you will find function

  • getRunningTrackCameraCapabilities(): CameraCapabilities; under CameraCapabilities interface you see zoomFeature(): RangeCameraCapability; use this function to set min and max values then apply the values using apply(value:T) method this function will return promise.

This will help you to zoom the camera and able to scan small QR.

rahulsharma991 avatar Apr 30 '24 20:04 rahulsharma991

Hi, we recognize that a iPhone 13 & 14 Pro are not able to use the scanner because the focus of the cam is not working. A iPhone 12 Pro works as expected.

Any chance to get a fix for this ? Thanks in Advanced

Initialize this class Html5Qrcode into your component you will find function

  • getRunningTrackCameraCapabilities(): CameraCapabilities; under CameraCapabilities interface you see zoomFeature(): RangeCameraCapability; use this function to set min and max values then apply the values using apply(value:T) method this function will return promise.

This will help you to zoom the camera and able to scan small QR.

Which values?

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

Hi, we recognize that a iPhone 13 & 14 Pro are not able to use the scanner because the focus of the cam is not working. A iPhone 12 Pro works as expected.

Any chance to get a fix for this ? Thanks in Advanced

Initialize this class Html5Qrcode into your component you will find function

  • getRunningTrackCameraCapabilities(): CameraCapabilities; under CameraCapabilities interface you see zoomFeature(): RangeCameraCapability; use this function to set min and max values then apply the values using apply(value:T) method this function will return promise.

This will help you to zoom the camera and able to scan small QR.

Which values?

Sorry for the confusion by setting min and max values. Min and Max values are already provided by detecting your device.

Like - zoomFeature().max() — You will get the max zoom Level value relative to device. zoomFeature().min() — You will get the min zoom level value relative to device

If you want to apply those value accordingly to your speciation you can use apply(minValue) method.

To get more specific You have to dig deep inside the library on code level.

rahulsharma991 avatar May 04 '24 16:05 rahulsharma991

try to modify the resolution to make it clear. html5Qrcode.start( { facingMode: "environment", }, { aspectRatio: 1.777778, // 16:9 focusMode: "continuous", fps: 15, videoConstraints: { facingMode: 'environment', width: 9999, // It may be useful!! }, qrbox: { width: 280, height: 280, }, },

T-mac-one avatar Aug 16 '24 03:08 T-mac-one