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

所属分类

源码仓库

使用此插件的项目

暂无相关数据。