Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

iPhone 15 pro can't focus close up documents when using the scan utility.🐛 #2246

Closed
3 of 5 tasks
akichim21 opened this issue Dec 3, 2023 · 4 comments · Fixed by #2392
Closed
3 of 5 tasks

iPhone 15 pro can't focus close up documents when using the scan utility.🐛 #2246

akichim21 opened this issue Dec 3, 2023 · 4 comments · Fixed by #2392
Labels
🐛 bug Something isn't working

Comments

@akichim21
Copy link

akichim21 commented Dec 3, 2023

What's happening?

Since purchased the new iPhone 15 pro, it seems that the iOS app can't automatically switch to the macro lens (the ultra wide lens), so it can't focus small documents (like tickets or barcodes).

This same error occurs in other third party apps.

Apple says is the "developer fault" because they are making the wrong call to the camera function, and so it only uses the main camera, that in the 14 and 15 pro models can't close focus.

This topic has been addressed in a session at WWDC 2021: https://developer.apple.com/videos/play/wwdc2021/10047/?time=133

Essentially the solution is to use the minimumFocusDistance property of the capture device to derive a videoZoomFactor to make sure the users hold the phone at a larger distance than the minimumFocusDistance. This is also illustrated in this sample code: https://developer.apple.com/documentation/avfoundation/capture_setup/avcambarcode_detecting_barcodes...

Reproduceable Code

const device = useCameraDevice('back');
  const codeScanner = useCodeScanner({
    codeTypes: ['qr', 'ean-13'],
    onCodeScanned: onCodeScanned,
  });

  const _renderCamera = () => {
    if (device == null || !hasPermission || !isFocused) {
      return null;
    }

    return (
      <Camera
        style={styles.qrCamera}
        device={device}
        isActive={true}
        codeScanner={codeScanner}
        enableZoomGesture={true}
        torch={torchStatus}
      />
    );
  };

Relevant log output

None

Camera Device

None

Device

iPhone15 pro

VisionCamera Version

3.6.12

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

@akichim21 akichim21 added the 🐛 bug Something isn't working label Dec 3, 2023
@mrousavy
Copy link
Owner

Yes - I can expose minimumFocusDistance on the device.

@mrousavy
Copy link
Owner

mrousavy commented Jan 15, 2024

Created a PR: #2392

@mlazari
Copy link

mlazari commented Mar 15, 2024

For anyone else looking for a solution, try using this:

const device = useCameraDevice('back', {
  physicalDevices: [
    'ultra-wide-angle-camera',
    'wide-angle-camera',
    'telephoto-camera'
  ]
})

instead of

const device = useCameraDevice('back');

This fixed the issue for us.
Documentation: https://react-native-vision-camera.com/docs/guides/devices#selecting-multi-cams

@seba9999
Copy link

seba9999 commented Oct 31, 2024

@mrousavy Can we use this minimumFocusDistance in the getcameradevice's filters ?

Something similar to the format filters like minFPS ? Would be great to fix the iphone 14 pro ( and more ) problems with thoses new minim focus distances

Discussed HERE and THERE

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🐛 bug Something isn't working
Projects
None yet
4 participants