Tuesday, 7 May 2019

Portrait Photo Effect returns Normal Image

What I Want: Portrait Image

What I Get: Regular Image

Notice the first image, the cup is blurred out, as a Portrait photo should be (from the iOS Camera App).

I am following this guide: Apple's "AVCam: Building a Camera App" Guide but I don't have any success.

My Code:

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()
}

Question: How do you get the Portrait effect on 3rd party app? Or is the Portrait Matte Effect not what I think it is?



from Portrait Photo Effect returns Normal Image

No comments:

Post a Comment