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

套件詳情v3.0.1

flutter_camera_ml_vision

一個顯示攝像頭畫面並允許在其中進行機器學習視覺識別的Flutter組件,可檢測條碼、標籤、文字、臉部等。

AndroidiOS
近 30 天下載
75
喜歡數
106
Pub 分數
130

安裝套件

flutter pub add flutter_camera_ml_vision

套件介紹

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

一個 Flutter 小部件,可顯示即時攝影機串流並啟用即時機器學習視覺功能,例如條碼、標籤、文字和人臉偵測。專為 Android 和 iOS 設計,可與 Flutter 應用程式無縫整合,提供裝置端影像分析。適用於文件掃描、物件辨識和自動資料輸入。該套件內部使用 ML Kit 以實現精確且高效能的處理。

適用情境

  • 文件掃描
  • 條碼讀取
  • 從圖像中提取文字
  • 人臉檢測
  • 圖像標註

主要特色

  • 即時攝像頭畫面
  • 設備端機器學習處理
  • 支援多種視覺 API
  • 跨平台(Android 與 iOS)
  • 與 Flutter 的簡單整合
  • 低延遲檢測

適合對象

  • 需要OCR的移動應用
  • 庫存管理工具
  • 智能文件掃描儀
  • 人臉辨識系統
  • 零售和物流應用

使用建議

  • 需要相機權限
  • 可能影響電池壽命
  • 性能因設備而異
  • 僅限支援的機器學習視覺類型
  • 需要對異步操作進行正確處理

原始 README

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

Flutter Camera Ml Vision

pub package

A Flutter package for iOS and Android to show a preview of the camera and detect things with Firebase ML Vision.

Installation

First, add flutter_camera_ml_vision as a dependency.

...
dependencies:
  flutter:
    sdk: flutter
  flutter_camera_ml_vision: ^2.2.4
...

Configure Firebase

You must also configure Firebase for each platform project: Android and iOS (see the example folder or https://firebase.google.com/codelabs/firebase-get-to-know-flutter#3 for step by step details).

iOS

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description. Or in text format add the key:
<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>

If you're using one of the on-device APIs, include the corresponding ML Kit library model in your Podfile. Then run pod update in a terminal within the same directory as your Podfile.

pod 'Firebase/MLVisionBarcodeModel'
pod 'Firebase/MLVisionFaceModel'
pod 'Firebase/MLVisionLabelModel'
pod 'Firebase/MLVisionTextModel'
Android

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

minSdkVersion 21

ps: This is due to the dependency on the camera plugin.

If you're using the on-device LabelDetector, include the latest matching ML Kit: Image Labeling dependency in your app-level build.gradle file.

android {
    dependencies {
        // ...

        api 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
    }
}

If you receive compilation errors, try an earlier version of ML Kit: Image Labeling.

Optional but recommended: If you use the on-device API, configure your app to automatically download the ML model to the device after your app is installed from the Play Store. To do so, add the following declaration to your app's AndroidManifest.xml file:

<application ...>
  ...
  <meta-data
    android:name="com.google.firebase.ml.vision.DEPENDENCIES"
    android:value="ocr" />
  <!-- To use multiple models: android:value="ocr,label,barcode,face" -->
</application>

Usage

1. Example with Barcode
CameraMlVision<List<Barcode>>(
  detector: FirebaseVision.instance.barcodeDetector().detectInImage,
  onResult: (List<Barcode> barcodes) {
    if (!mounted || resultSent) {
      return;
    }
    resultSent = true;
    Navigator.of(context).pop<Barcode>(barcodes.first);
  },
)

CameraMlVision is a widget that shows the preview of the camera. It takes a detector as a parameter here we pass the detectInImage method of the BarcodeDetector object. The detector parameter can take all the different FirebaseVision Detector. Here is a list :

FirebaseVision.instance.barcodeDetector().detectInImage
FirebaseVision.instance.cloudLabelDetector().detectInImage
FirebaseVision.instance.faceDetector().processImage
FirebaseVision.instance.labelDetector().detectInImage
FirebaseVision.instance.textRecognizer().processImage

Then when something is detected the onResult callback is called with the data in the parameter of the function.

Exposed functionality from CameraController

We expose some functionality from the CameraController class here a list of these :

  • value
  • prepareForVideoRecording
  • startVideoRecording
  • stopVideoRecording
  • takePicture

Getting Started

See the example directory for a complete sample app.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Technical Support

For any technical support, don't hesitate to contact us. Find more information in our website

For now, all the issues with the label support mean that they come out of the scope of the following project. So you can contact us as a support.

所屬分類

依賴

依賴清單 8 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。