当添加AVCaptureVideoPreviewLayer图层以进行视频预览时,AVDepthData depthMaps始终处于连线状态,但是如果我们不添加并说我们使用uiimageview分配连续的视频帧,则它看起来是正确的,是任何面临相同问题的人,那么请帮助。
使用以下代码时:
let previewCameraLayer = AVCaptureVideoPreviewLayer.init(session: self.session)
previewCameraLayer.name = "Camera_Preview"
previewCameraLayer.backgroundColor = UIColor.clear.cgColor
previewCameraLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
if let previewRootLayer = self.vwPreview?.layer {
//previewRootLayer.masksToBounds = true
previewCameraLayer.frame = previewRootLayer.bounds
previewRootLayer.addSublayer(previewCameraLayer)
深度图是: See how wired it is appearing
但如果对此行发表评论:
previewRootLayer.addSublayer(previewCameraLayer)
它非常完美: Same depth map without AVCaptureVideoPreviewLayer added