搜尋套件、儲存庫與 APP 分類

套件詳情v0.7.0

mlkit_scanner

一個用於在 iOS 和 Android 上使用 Google MLKit API 檢測條碼、文字、臉部和物件的 Flutter 外掛

AndroidiOS
近 30 天下載
321
喜歡數
50
Pub 分數
150

安裝套件

flutter pub add mlkit_scanner

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個利用 Google MLKit 的 Flutter 插件,可在 Android 和 iOS 上實現條碼、文字、人臉和物件檢測。它為將強大的設備端機器學習功能整合到 Flutter 應用程式中提供簡單直觀的介面。該插件支援即時掃描與處理,非常適合需要快速且準確識別視覺資料的應用程式。此插件以原生效能為設計核心,使用直接於裝置上運行的優化模型,確保低延遲與高準確度。

適用情境

  • 零售應用中的條形碼掃描
  • 從圖像中提取文字
  • 照片應用中的面部檢測
  • 增強現實中的物體識別
  • 即時文件掃描
  • 自動數據輸入

主要特色

  • 支援多種檢測類型
  • 設備端處理以保障隱私
  • 即時掃描
  • 跨平台相容性
  • 簡單 API 結合
  • 高精度與MLKit

適合對象

  • 需要視覺識別的移動應用
  • 尋求離線功能的開發者
  • 需要快速響應時間的應用程式
  • 注重用戶隱私的項目
  • 使用 Flutter 進行跨平台開發的團隊

使用建議

  • 需要原生SDK設定才能使用全部功能
  • 僅限 Android 和 iOS 平台
  • 依賴於 Google MLKit 更新
  • 由於內建模型,可能會增加應用程式大小
  • 效能於舊裝置上有所差異

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

MLKit Scanner

A Flutter plugin to detect barcodes, text, faces, and objects using Google MLKit API for iOS and Android

This Plugin uses Android CameraView library and iOS AVFoundation APIs for detecting objects from device's camera.

Note: This plugin is under development, and some APIs might not be available yet.

Features:

  • Display camera preview in a widget.
  • Set size of the camera preview.
  • Set overlay for camera preview.
  • Set area for detect object.
  • Pause/Resume camera preview.
  • Toogle device flash.
  • Set a preview scale
  • Use camera Zoom
  • Lock autofocus
Google MLKit APIs: Android iOS
Barcode scanning ✅ ✅
------------------------ - -

Installation

First, add mlkit_scanner as a dependency in your pubspec.yaml.

iOS

iOS 11.0 of higher is needed to use the camera plugin.

Add key to the ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>...description...</string>
Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21
Example
import 'package:mlkit_scanner/mlkit_scanner.dart';

...

return SizedBox(
  height: 200.0                                 // CameraPreview needs height constraints, if you use widget 
                                                // in Column use SizedBox or Container with height.
  child: BarcodeScanner(
    cropOverlay: ScannerCropOverlay             // you can use default ScannerOverlay, create custom, or do not 
                                                // use it at all

    onScannerInitialized: _onScannerInitialized // callback with BarcodeScannerController for control camera 
                                                // and detection when camera preview initialize.
    
    onCameraInitializeError: (error) {          // Handling error if camera can't initialize on device.
      // handleError.
    }
    onScan: (barcode) {                         // Calls on success barcode recognition
      // Do anything with the code.
    },
  ),
);

Future<void> _onScannerInitialized(BarcodeScannerController controller) async {
    await controller.startScan(100)             // Detection starts only after this call.
                                                // 100 - delay in milliseconds between detection for decreasing 
                                                // CPU consumption. Detection happens every 100 milliseconds 
                                                // skipping frames during delay. Use 0 to turn off delay.

    await controller.stopScan()                 // You can stop detection.

    await controller.setDelay(200)              // Or set delay while detection is going.

    await controller.toggleFlash()              // Toggle device flash. Can throw an Exception if device 
                                                // doesn't have flash.

    await controller.pauseCamera()              // Pause camera preview, detection also stops.

    await controller.resumeCamera()             // Resume camera preview, detection resumes too if 
                                                // controller.startScan calls before.
                                                
    await controller.setZoom(0.5)               // Set camera zoom. Values must be in range 0...1                            
}

Contributing:

Contributions are welcome.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。