Skip to content
pubscout

google_mlkit_selfie_segmentation

1.0.3, released 8 days ago by flutter-ml.dev

Flutter plugin to use Google's ML Kit Selfie Segmentation API.

$ flutter pub add google_mlkit_selfie_segmentation
Source repository

What it does

A Flutter plugin that uses Google's ML Kit Selfie Segmentation API to separate the background from users within a scene. It passes calls via platform channels to native iOS and Android APIs, returning segmentation masks with confidence scores.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to separate users from backgrounds in selfies or video streams on Android and iOS.
  • You want to leverage on-device machine learning for real-time segmentation.

Skip it when

  • You are targeting web or desktop platforms.
  • You require custom model training or custom architecture beyond Google's pre-built selfie segmentation.

Strengths

  • Leverages optimized native Google ML Kit APIs.
  • Supports both single images and stream modes with configurable options.

Weaknesses

  • Mobile only (Android and iOS); web or other platforms are not supported.
  • Running segmentation inference on Apple Silicon iOS simulators requires physical hardware or specific setup limitations.

Setup

Kind
Plugin (native code)
Effort
High
Code generation
No
Direct dependencies
1

Requires setting minimum iOS deployment target to 15.0, configuring Xcode linker flags (-ObjC and -all_load), downloading ML Kit resource bundles manually via Swift Package Manager setup, and configuring Android minimum SDK to 21 with compileSdk 36.

final segmenter = SelfieSegmenter(
  mode: SegmenterMode.stream,
  enableRawSizeMask: true,
);
final SegmentationMask? mask = await segmenter.processImage(inputImage);
segmenter.close();

Alternatives

Packages that do the same job and could replace google_mlkit_selfie_segmentation.

  • native_cutout

    On-device background removal for iOS and Android using native vision and segmentation APIs.

Works with

Packages commonly used together with google_mlkit_selfie_segmentation: ones it builds on, ones built on it, and its own family.