Skip to content
pubscout

google_mlkit_subject_segmentation

0.3.2, released 10 days ago by flutter-ml.dev

Flutter plugin for Google's ML Kit Subject Segmentation API to separate subjects from backgrounds.

$ flutter pub add google_mlkit_subject_segmentation
Source repository

What it does

A Flutter plugin that uses Google's ML Kit Subject Segmentation API to easily separate multiple subjects from the background in a picture. It provides masks and bitmaps for individual subjects as well as foreground processing, handling objects, pets, and humans.

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

Use it when

  • You need to separate multiple subjects from backgrounds in static images on mobile.
  • You want to build features like sticker creation or background swapping.
  • You require on-device image processing to preserve user privacy.

Skip it when

  • You need support for web or desktop platforms.
  • You require iOS support for subject segmentation (currently only available for Android in beta).

Strengths

  • On-device processing preserving user privacy.
  • Supports multi-subject segmentation with confidence masks and bitmaps.
  • Uses Google's native ML Kit APIs via platform channels.

Weaknesses

  • iOS support is not currently available for subject segmentation.
  • Feature is still in Beta and limited to static images.

Setup

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

Requires minimum Android SDK requirements (minSdkVersion: 24, targetSdkVersion: 36, compileSdkVersion: 36) and optional AndroidManifest.xml dependency declarations for model downloading.

final options = SubjectSegmenterOptions(
  enableForegroundBitmap: false,
  enableForegroundConfidenceMask: true,
  enableMultipleSubjects: SubjectResultOptions(
    enableConfidenceMask: true,
    enableSubjectBitmap: false,
  ),
);
final segmenter = SubjectSegmenter(options: options);
final result = await segmenter.processImage(inputImage);
segmenter.close();

Alternatives

Packages that do the same job and could replace google_mlkit_subject_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_subject_segmentation: ones it builds on, ones built on it, and its own family.