I am creating an Android App in Kotlin in which I want to remove background from a person's portrait image in real time.
(This code is meant to be imbedded in a video calling app whose one of the feature is to remove person's background during video calls for privacy issues.)
I have downloaded the starter app of TensorFlow Lite from here. It is generating a mask and an overlay of mask and the captured image. How can we use that mask to take a cut-out of the person and replace background with any image from the gallery.
I haven't done any work with TensorFlow Lite in the past, so any help would be highly appreciated.
Thanks in advance.
The project of TF Lite works fine and you get the generated mask from input image... Then you have to use something different to achieve the desired result. Just check out PorterDuff.Mode!
I have created for you a helper function to use it and get the desired bitmap. From there you can continue and load it inside an ImageView: