0

I was watching the Image Editing with Depth WWDC video from 2017 (link), where they take the background of a portrait mode and make it black. They also showed some code but I'm not sure how to use it. Could anyone provide some sample code?

Portrait Image with Black Background: enter image description here Code: enter image description here

kerbelda
  • 285
  • 1
  • 4
  • 12
  • Does this Q&A help? https://stackoverflow.com/questions/44506934/how-to-capture-depth-data-from-camera-in-ios-11-and-swift-4 – dfd Nov 05 '17 at 23:29

1 Answers1

0

I believe what you want to do is change:

vec4 result = vec4(imageColor.rgb * scaleFactor, imageColor.a);

to:

if disparity < cutoff {
    vec4 result = vec4(imageColor.rgb, 0);
}

where cutoff is the disparity(depth) that you want to stop showing.

I've been working with AVDepthData, but am not experienced with filters.

Hope that helps!

  • Hey Stephen, thank you for the answer. The issue is I just don't know how you use this code: kernel vec4 into_darkness(__sample imageColor, __sample normalizedDisparity, float power) {} – kerbelda Dec 06 '17 at 16:39