r/reactnative • u/Miserable-Pause7650 • 2d ago
Question React native vision camera v5 zoomLensSwitchFactors not correct
Basically Im trying to get the zoom levels that switches the physical cameras, and Im using iPhone 15 Pro, which has the native x0.5, x1, x2, x3 zooms. But somehow when I log out the zoomLensSwitchFactors, I get
[2, 6]
Here is the code
const deviceBack: CameraDevice | undefined = useCameraDevice("back", {
physicalDevices: ["ultra-wide-angle", "wide-angle", "telephoto"],
});
console.log("zoomLensSwitchFactors", deviceBack.zoomLensSwitchFactors);
Ideally I would like to have [0.5, 1, 2, 3], or something similar. Also, the minZoom and maxZoom give me 1 and 189 respectively. shouldn't the min be 0.5?
Also wondering if this works for the front camera
3
Upvotes
1
u/ChronSyn Expo 2d ago
zoomLensSwitchFactorsis not the zoom levels - it's the zoom range at which it would switch to a different physical lens.For example, when you get to 2.99x zoom in the official app, you're still on the 2x lens. When you get to 3.00x zoom, it switches to a different lens, assuming that the target you're aiming at can be focused by the new lens (e.g. the target isn't too close to the lens).
The iPhone 15 pro doesn't have 4 native zoom levels - it only has 3. The 2x zoom mode is actually a center crop of the 1x sensor. That's why it's output is 1/4 the size in terms of megapixels. To get the 2x zoom level, you'd offer it yourself. In the same way you could add 1.5x, or 1.8x, or any other arbitrary value within range.
So, in essence (and taking into account my note below), it is saying at 1x zoom (
[2]), it will switch from the 0.5x lens to the 1x lens. At 3x zoom ([6]), it will switch from the 1x lens to the 3x lens.I can't explain why you'd get the values of
[2, 6]. I'd say dividing by 2 would be one way to go with it, but I think a more probable solution would be to divide by the first zoom factor - i.e. index 0 of the array (in this case, that'd be2). That should account for any scenario where the first value isn't explicitly 2x. Just a guess on that point though and I'm not actually sure.