AVCaptureDevice devices are empty
Not all iPhones contain dual camera, that's why devices
is empty.
You can try add this deviceTypes: [.builtInWideAngleCamera]
.
Here is all available device types for now.
Also there is a good answer to question about Dual Camera - check this.
Hope this will help you!
Capture frames from both cameras (TelePhoto and WideAngle) in the same time
Yes, it's possible.
Just pick the right configuration.
Capture device should be builtInDualCamera
:
let captureDevice = AVCaptureDevice.default(.builtInDualCamera, for: .video, position: .back)
Configure capture photo output after configuring capture session:
captureSession = AVCaptureSession()
captureSession?.sessionPreset = AVCaptureSession.Preset.photo
captureSession?.addInput(input)
captureSession?.addOutput(capturePhotoOutput!)
capturePhotoOutput?.isHighResolutionCaptureEnabled = true
capturePhotoOutput?.isDualCameraDualPhotoDeliveryEnabled = true
Configure photo settings before capture the photo:
let photoSettings = AVCapturePhotoSettings()
photoSettings.isAutoStillImageStabilizationEnabled = true
photoSettings.isHighResolutionPhotoEnabled = true
photoSettings.isAutoDualCameraFusionEnabled = false
photoSettings.isDualCameraDualPhotoDeliveryEnabled = true
Implement AVCapturePhotoCaptureDelegate
, and override next method:
public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)
You will receive 2 photoOutput
callbacks!
How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession
You can get the front camera with the following:
AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front)
The back camera:
AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)
And the microphone:
AVCaptureDevice.default(.builtInMicrophone, for: AVMediaType.audio, position: .unspecified)
Related Topics
How to Compile Latest Swift Version on Older Xcode
Peak Detection for Growing Time Series Using Swift
Xcode Swift How to Add Image to Uialertcontroller Options
Firebase Says That My Rules Are Insecure, Why
How to Instantiate a Storyboard from a File Within an iOS Playground
Example of Dispatch_Once in Swift
How to Make Apple Sign in Revoke Token Post Request
Detailed Instruction on Use of Nsopenpanel
How to Use Unsafemutablerawpointer to Fill an Array
How to Get All Days in Current Week in Swift
Class-Only Generic Constraints in Swift
Firebase Says That My Rules Are Insecure, Why
Get Just the Date (No Time) from Uidatepicker
Watchos3 Complication That Launches App
Po Swift String "Unresolved Identifier"
Correct Handling/Cleanup/Etc of Cadisplaylink in Swift Custom Animation