try! Swift 2019 demo app that converts Depth-less 2D images into Portrait mode.
How to build
opencv2.frameworkfrom here v3.4.x iOS pack, then put it into this folder.
Portrait.xcworkspacewith Xcode 10.x and build it
About this app
In iOS’s Portrait mode, you can take beautiful photos that keep your subject sharp while blurring the background.
This so-called bokeh effect can be done by using Depth.
In contrast, this app attempts to make Depth-less 2D images into Portrait mode by following steps.
This app uses “GrabCut” to perform segmentation of the subject and the background.
GrabCut with Rect
GrabCut with Mask
2. Color leak prevention
As it’s not beautiful if the subject color leaks into the background, this app tries to delete the subject from the background by using “Inpainting”.
Blur & Inpainting
“Depth-of-Field” is the range where the photo is in focus.
I implemented an adjusting function to blur an area.
Please give it a try !
Xcode 10.x+ iOS 12.0+