depth data

后置摄像头优先级与types里的顺序有关

private let videoDeviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInTrueDepthCamera,

                                                                                            .builtInDualCamera,

                                                                                            .builtInWideAngleCamera],

                                                                              mediaType: .video,

                                                                              position: .unspecified)


一.添加输入,输出

video input

photo output

video data output

depth data output

二.设置outputSynchronizer

三.实现代理方法

func dataOutputSynchronizer(_ synchronizer: AVCaptureDataOutputSynchronizer, didOutput synchronizedDataCollection: AVCaptureSynchronizedDataCollection) {}

注意:开启photoOutput.isDepthDataDeliveryEnabled

并选择.builtInTrueDepthCamera/builtInDualCamera


demo 链接:https://github.com/licl19/DepthDataDemo.git

你可能感兴趣的:(depth data)