搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。