Skip to main content

mediapipe_vision 0.1.2 copy "mediapipe_vision: ^0.1.2" to clipboard
mediapipe_vision: ^0.1.2 copied to clipboard

Google's MediaPipe vision tasks for Flutter: face, hand, pose and holistic landmarks, gestures, object detection, classification, embeddings and segmentation.

example/example.dart

import 'dart:io';

import 'package:mediapipe_vision/mediapipe_vision.dart';

/// Finds the faces in a photo from the command line with Google's pinned
/// BlazeFace model: `dart run example/example.dart photo.jpg`.
///
/// A Dart program has no app bundle, so this downloads the model once into
/// `.dart_tool/mediapipe_models/`, checks its SHA-256 and passes its path. A
/// Flutter app bundles the model instead, by listing `face_detector` under
/// `hooks.user_defines.mediapipe_vision.models` and running
/// `dart run mediapipe_core:bundle_models`, then passes
/// `model: VisionModels.faceDetector`.
Future<void> main(List<String> arguments) async {
  final store = ModelStore(
    cacheDirectory: Directory('.dart_tool/mediapipe_models').absolute.path,
  );
  final model = await store.get(VisionModels.faceDetector);
  final detector = await FaceDetector.create(
    FaceDetectorOptions(modelPath: model.path),
  );
  try {
    final result = await detector.detect(
      VisionImage.fromFile(arguments.single),
    );
    print(
      '${result.detections.length} face(s) in a '
      '${result.imageWidth} x ${result.imageHeight} image',
    );
    for (final face in result.detections) {
      final box = face.boundingBox;
      print(
        'score ${face.categories.first.score.toStringAsFixed(3)}, '
        'box (${box.left}, ${box.top}) ${box.width} x ${box.height}',
      );
    }
  } finally {
    await detector.dispose();
  }
}
0
likes
160
points
46
downloads

Documentation

API reference

Publisher

verified publishergoogle.dev

Weekly Downloads

Google's MediaPipe vision tasks for Flutter: face, hand, pose and holistic landmarks, gestures, object detection, classification, embeddings and segmentation.

Repository (GitHub)
View/report issues
Contributing

Topics

#mediapipe #machine-learning #computer-vision #face-detection #pose-estimation

License

BSD-3-Clause (license)

Dependencies

code_assets, ffi, flutter, flutter_web_plugins, hooks, mediapipe_core, meta, web

More

Packages that depend on mediapipe_vision

Packages that implement mediapipe_vision