パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.8

google_ml_vision

Google ML Kit のデバイス内ビジョンAPI用のFlutterプラグインです。バーコードスキャン、画像ラベル付け、テキスト認識、顔検出を含みます。

AndroidiOS
30日間ダウンロード
88
いいね数
135
Pub ポイント
140

パッケージをインストール

flutter pub add google_ml_vision

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Google ML Kit のデバイス内ビジョン API を統合する Flutter プラグインで、バーコードスキャン、画像ラベル付け、テキスト認識(OCR)、顔検出を Flutter アプリ内で直接実行できます。低遅延のリアルタイム処理を目的としており、Android および iOS デバイス上でローカルで実行されるため、プライバシーとパフォーマンスが確保されます。このプラグインは、一般的なコンピュータビジョンタスクの実装を簡単にする方法を提供しており、クラウドサービスに依存せずにスマートな画像分析が必要なモバイルアプリに最適です。

用途

  • 小売アプリにおけるバーコードスキャン
  • 画像からのテキスト抽出
  • 写真アプリにおける画像分類
  • 拡張現実のための顔検出
  • ドキュメントスキャンとOCR

主な機能

  • デバイス内処理
  • 複数のビジョンタスクをサポート
  • 低遅延パフォーマンス
  • Privacy-preserving
  • シンプルなAPI統合

適している対象

  • リアルタイムビジョン機能を必要とするモバイルアプリ
  • ユーザーのプライバシーを最優先する開発者
  • オフライン機能を必要とするアプリ
  • ドキュメントまたはARツールを構築しているスタートアップ
  • ネイティブML機能を使用するFlutter開発者

注意事項

  • Android 5.0+ または iOS 10.0+ を必要とします
  • サポートされているビジョンモデルに限定
  • クラウドベースの強化機能なし
  • パフォーマンスはデバイスによって異なります
  • iOS では手動設定が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Google ML Kit Vision Plugin

(https://pub.dev/packages/google_ml_vision)

A Flutter plugin to use the capabilities of on-device Google ML Kit Vision APIs

Usage

To use this plugin, add google_ml_vision as a dependency in your pubspec.yaml file.

Using an ML Vision Detector

1. Create a GoogleVisionImage.

Create a GoogleVisionImage object from your image. To create a GoogleVisionImage from an image File object:

final File imageFile = getImageFile();
final GoogleVisionImage visionImage = GoogleVisionImage.fromFile(imageFile);
2. Create an instance of a detector.
final BarcodeDetector barcodeDetector = GoogleVision.instance.barcodeDetector();
final FaceDetector faceDetector = GoogleVision.instance.faceDetector();
final ImageLabeler labeler = GoogleVision.instance.imageLabeler();
final TextRecognizer textRecognizer = GoogleVision.instance.textRecognizer();

You can also configure all detectors, except TextRecognizer, with desired options.

final ImageLabeler labeler = GoogleVision.instance.imageLabeler(
  ImageLabelerOptions(confidenceThreshold: 0.75),
);
3. Call detectInImage() or processImage() with visionImage.
final List<Barcode> barcodes = await barcodeDetector.detectInImage(visionImage);
final List<Face> faces = await faceDetector.processImage(visionImage);
final List<ImageLabel> labels = await labeler.processImage(visionImage);
final VisionText visionText = await textRecognizer.processImage(visionImage);
4. Extract data.

a. Extract barcodes.

for (Barcode barcode in barcodes) {
  final Rectangle<int> boundingBox = barcode.boundingBox;
  final List<Point<int>> cornerPoints = barcode.cornerPoints;

  final String rawValue = barcode.rawValue;

  final BarcodeValueType valueType = barcode.valueType;

  // See API reference for complete list of supported types
  switch (valueType) {
    case BarcodeValueType.wifi:
      final String ssid = barcode.wifi.ssid;
      final String password = barcode.wifi.password;
      final BarcodeWiFiEncryptionType type = barcode.wifi.encryptionType;
      break;
    case BarcodeValueType.url:
      final String title = barcode.url.title;
      final String url = barcode.url.url;
      break;
  }
}

b. Extract faces.

for (Face face in faces) {
  final Rectangle<int> boundingBox = face.boundingBox;

  final double rotY = face.headEulerAngleY; // Head is rotated to the right rotY degrees
  final double rotZ = face.headEulerAngleZ; // Head is tilted sideways rotZ degrees

  // If landmark detection was enabled with FaceDetectorOptions (mouth, ears,
  // eyes, cheeks, and nose available):
  final FaceLandmark leftEar = face.getLandmark(FaceLandmarkType.leftEar);
  if (leftEar != null) {
    final Point<double> leftEarPos = leftEar.position;
  }

  // If classification was enabled with FaceDetectorOptions:
  if (face.smilingProbability != null) {
    final double smileProb = face.smilingProbability;
  }

  // If face tracking was enabled with FaceDetectorOptions:
  if (face.trackingId != null) {
    final int id = face.trackingId;
  }
}

c. Extract labels.

for (ImageLabel label in labels) {
  final String text = label.text;
  final String entityId = label.entityId;
  final double confidence = label.confidence;
}

d. Extract text.

String text = visionText.text;
for (TextBlock block in visionText.blocks) {
  final Rect boundingBox = block.boundingBox;
  final List<Offset> cornerPoints = block.cornerPoints;
  final String text = block.text;
  final List<RecognizedLanguage> languages = block.recognizedLanguages;

  for (TextLine line in block.lines) {
    // Same getters as TextBlock
    for (TextElement element in line.elements) {
      // Same getters as TextBlock
    }
  }
}
5. Release resources with close().
barcodeDetector.close();
faceDetector.close();
labeler.close();
textRecognizer.close();

Getting Started

See the example directory for a complete sample app using Google Machine Learning.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。