B4A Library [B4X] SelfieSegmentation with ML Kit

1717424669041.png

Image source: https://en.wikipedia.org/wiki/Selfie#/media/File:TWC_Hokitika_Gorge_•_Stewart_Nimmo_•_MRD_1.jpg

A B4A + B4i selfie segmentation feature based on Google ML Kit: https://developers.google.com/ml-kit/vision/selfie-segmentation
The result is a mask image. In the example it is overlayed over the original image using a semitransparent B4XImageView.

Usage itself is quite straightforward. See the example.
The configuration is a bit cumbersome.
Please go over the dependencies sections in the text recognition tutorial: https://www.b4x.com/android/forum/threads/b4x-textrecognition-based-on-mlkit.161210/#content

Don't miss:
- B4i dependencies + #PlistExtra (for MediaChooser) in Main module.
- B4i bundle files under Files\Special.
- B4A dependencies in Main module.
- B4A manifest editor. Snippets for MLKit and snippet for FileProvider (MediaChooser).

For B4A there is another step required (it will not be required once the SDK goes out of beta):
- Download mediapipe-internal-16.0.0.aar from: https://www.b4x.com/android/files/mediapipe-internal-16.0.0.aar
- Go to: <android sdk>\extras\b4a_remote\com\google\mlkit\mediapipe-internal\16.0.0
- Replace the existing mediapipe-internal-16.0.0.aar file with the one you downloaded.
- If you see a folder named unpacked-mediapipe-internal-16.0.0 then delete it.
 

Attachments

  • SelfieSegmentation.zip
    392.9 KB · Views: 32
Top