How to achieve portrait mode like blurring the background of image in video of people programmatically, this feature exists in IOS natively now since the last update, I think we can achieve this using something like openGL shader or something or some setting in Camera2 API, the thing is I does not look straight forward at all. any help would be appreciated, https://www.xda-developers.com/how-to-use-portrait-mode/ this link has an image as an example of what I am trying to achieve, the article is not technical and not mentioning anything related to programming.
Building a good-quality portrait mode implementation by yourself is possible, of course, but you need strong expertise in computer vision and probably machine learning as well. The hard part is separating the foreground objects (or people) from the background, and for that a simple OpenGL shader won't really cut it.
Once you have the matte (which describes whether a given pixel is foreground or background or a mixture of the two), a blur shader is relatively straightforward, but that's the easy part.
That said, CameraX extensions allow devices to support Portrait mode for apps. And in Android 12 / API 31, camera2 also supports extensions.
So the simplest path is to just use CameraX and the extension feature there, and eventually Android 12 will be available on a large number of devices as well, allowing for the lower-level camera2 path.