Related | 5 Best Selfie Camera Apps for Android Wrapping Up- Zoom in Front Camera As noted, you can’t use it in portrait mode for obvious reasons. Also, the option is available only on the newer iPhone models.
All the code above relies on virtualDeviceSwitchOverVideoZoomFactors var, which is available only from iOS 13, but builtInDualCamera is available from iOS 10.
Is there any way to get it programmaticaly? Apple states 5x in iPhone specs, and there is AVCaptureDevice.maxAvailableVideoZoomFactor, but those values are different (for example, iPhone 13 pro has 15x in specs vs 123.75x in maxAvailableVideoZoomFactor).Ģ - Case builtInDualCamera (iPhone XS Max, for example). Guard #available(iOS 13, *) else + įatalError("this should not happen on a real device")ġ - We have to hardcode maxDigitalZoom. Seems like all iPhones limit digital zoom to 5x Let session: AVCaptureDevice.DiscoverySession( builtInQuadrupleCamera" in a couple of years, this code will have to be modified, because it won't include it automatically.Īs I suppose, final code should look something like this: let deviceTypes: ĭeviceTypes = Is there any universal way to get "the best" (i.e with all features) camera? For example, now I can specify for discovery session and pick the first item in devices array, but if Apple will release, lets say, some ". Why is it exactly 15x and where does it come from? (My assumption is that max digital zoom for all iPhones equals to 5x, so on 13 Pro telephoto camera zooms 3x as "usual" camera, thus we get 3x * 5x = 15x max zoom) back).devices.first!.maxAvailableVideoZoomFactor, it says 123.75 (iphone 13 pro), but in the default camera app max zoom value is 15x. What is the correct way to get max zoom value? If I try AVCaptureDevice.DiscoverySession(deviceTypes:, mediaType. Please clarify how it is actually calculated and correct me if my assumption is wrong. As I understand, Apple considers "usual" back camera as default (that is, 1x), and all other values are relative to it: 13mm is 0.5 * 26mm, so the first value on iphone 13 pro zoom control will be 0.5x, the second value is the "default" and is 1x (26mm), and telephoto camera is 77mm, so the third value is 3x (26mm * 3 = 78mm ~= 77mm). How can we determine zoom values to display in UI? The thing is that AVCaptureDevice's minZoomFactor always starts from 1x, but in the camera app we can see that on devices with ultrawide camera the scale starts at 0.5x, so there should be some way to map this values onto each other. (It is probably needed to determine zoom values, see the next question) Is it possible to get focal length value programmaticaly? There are labels like 13mm, 26mm for different back cameras in the default app, but there is no such property on AVCaptureDevice.
I did some research, and still have some questions about it. I'm making a zoom control for my app, and I'd like to make it advanced, like in default camera app from Apple: sample