2

In my project, I am trying to support triple cameras system. But I don't know how to check whether a device has triple cameras?

Anonymone
  • 29
  • 1
  • You could identify the iPhone model (get hints on how to do here: https://stackoverflow.com/questions/19422322/method-to-find-devices-camera-resolution-ios). And from there know if it has triple camera. – claude31 Nov 04 '21 at 12:53
  • @claude31 No need to get that. It's often string based as well, which is a massive fail in itself :/ – Vollan Nov 04 '21 at 13:09

2 Answers2

6

you can do this with following code either device has builtin dual back camera or wide angle back camera

var currentDevice:AVCaptureDevice?
        if let device = AVCaptureDevice.default(.builtInDualCamera, for: AVMediaType.video, position: .back)
        {
            currentDevice = device
        }
        else if let device = AVCaptureDevice.default(.builtInTripleCamera, for: .video, position: .back)
        {
            currentDevice = device
        }
        else if let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)
        {
            currentDevice = device
        }
        else
        {
            print("Error: no camera available")
        }

Hope this will helps you

Muhammad Nawaz
  • 1,113
  • 6
  • 15
  • Does it means that a device support triple-camera system when type equals to builtInDualCamera, builtInTripleCamera or builtInWideAngleCamera? – Anonymone Nov 07 '21 at 08:30
4

In the AVFoundation kit you have an AVCaptureDevice, which have an DeviceType which you can put as the default.

if let device = AVCaptureDevice.default(.builtInTripleCamera, for: .video, position: .back) {
            
}
emrcftci
  • 3,355
  • 3
  • 21
  • 35
Vollan
  • 1,887
  • 11
  • 26