请注意第一张图像,杯子模糊了,因为应该是人像照片(来自iOS Camera App)。
我正在遵循以下指南:Apple's "AVCam: Building a Camera App" Guide,但没有任何成功。
我的代码:
override func viewDidLoad() {
isPortrait = true
// Select a depth-capable capture device.
guard let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera,
for: .video, position: .unspecified)
else { fatalError("No dual camera.") }
guard let videoDeviceInput = try? AVCaptureDeviceInput(device: videoDevice),
self.captureSession.canAddInput(videoDeviceInput)
else { fatalError("Can't add video input.") }
// Set up photo input
self.captureSession.addInput(videoDeviceInput)
// Set up photo output for depth data capture.
self.photoOutput = AVCapturePhotoOutput()
if(self.photoOutput.isPortraitEffectsMatteDeliverySupported) {
self.photoOutput.isPortraitEffectsMatteDeliveryEnabled = true
}
else {
print("Can't add portrait effects")
}
self.captureSession.addOutput(photoOutput)
self.captureSession.sessionPreset = .photo
self.captureSession.commitConfiguration()
}
问题: 您如何在第三方应用程序上获得人像效果?还是肖像哑光效果不是我想的那样?