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

edge_detection のカバー
パッケージ詳細v1.1.3

edge_detection

オブジェクトのエッジを検出、紙をスキャン、コーナーを検出、長方形を検出するためのFlutterプラグインです。検出されたオブジェクト画像のクロッピングを可能にし、クロップされた画像のパスを返します。

AndroidiOS
30日間ダウンロード
408
いいね数
310
Pub ポイント
150

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

flutter pub add edge_detection

パッケージ概要

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

画像内のエッジ、コーナー、長方形を検出するためのFlutterプラグインで、ドキュメントスキャンに最適です。検出されたオブジェクトを自動的にクロップし、クロップ後の画像へのパスを返します。OCRおよびコンピュータビジョンアプリケーション向けに設計されており、AndroidおよびiOSの両方のプラットフォームをサポートしています。このプラグインは画像処理技術を活用して境界を特定し、スキャンされた文書を最適化します。

用途

  • ドキュメントスキャン
  • 画像のクロッピング
  • ペーパーのデジタル化
  • オブジェクト境界検出
  • OCRの前処理
  • 長方形検出

主な機能

  • エッジ検出
  • コーナー検出
  • 長方形の識別
  • 自動画像のクロッピング
  • 切り抜かれた画像のパスを返す
  • クロスプラットフォーム対応(AndroidおよびiOS)

適している対象

  • モバイルドキュメントスキャナー
  • OCR アプリケーション
  • 画像処理ツール
  • 教育アプリ
  • 写真強化ツール

注意事項

  • カメラアクセス権限が必要です
  • 低性能デバイスではパフォーマンスが異なる場合があります
  • 高コントラスト画像で最良の結果が得られます
  • 2Dエッジ検出に制限
  • ぼやけた画像の前処理が必要になる場合があります

元の README

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

edge_detection

A flutter plugin to detect edges of objects, scan paper, detect corners, detect rectangles. It allows cropping of the detected object image and returns the path of the cropped image.

Usage:

iOS

iOS 13.0 or higher is needed to use the plugin. If compiling for any version lower than 13.0 make sure to check the iOS version before using the plugin. Change the minimum platform version to 13 (or higher) in your ios/Podfile file, and inform/request access to the permissions acording with permission_handler

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',

        ## dart: PermissionGroup.camera
         'PERMISSION_CAMERA=1',

        ## dart: PermissionGroup.photos
         'PERMISSION_PHOTOS=1',
      ]

    end
    # End of the permission_handler configuration
  end
end

Fix build on xCode 15

Add this line to your Podfile in your project:

pod 'WeScan', :path => '.symlinks/plugins/edge_detection/ios/WeScan-3.0.0'

=> like this below:

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  pod 'WeScan', :path => '.symlinks/plugins/edge_detection/ios/WeScan-3.0.0'
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Add below permission to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera 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>NSPhotoLibraryUsageDescription</key>
<string>Can I use the photos please?</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Can I use the photos please?</string>

Add to your need localizations to your app through XCode for localize actions buttons from WeScan (https://github.com/WeTransfer/WeScan/tree/master/WeScan/Resources/Localisation)

Android

The plugin code is written in kotlin 1.8.0 so the same has to be set to the android project of yours for compilation. Change the kotlin_version to 1.8.0 in your android/build.gradle file.

ext.kotlin_version = '1.8.0'

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

minSdkVersion 21
Add dependency:

Please check the latest version before installation.

dependencies:
  flutter:
    sdk: flutter
  edge_detection: ^1.1.3
  permission_handler: ^10.0.0
  path_provider: ^2.0.11
  path: ^1.8.2
Add the following imports to your Dart code:
import 'package:edge_detection/edge_detection.dart';
// Check permissions and request its
bool isCameraGranted = await Permission.camera.request().isGranted;
if (!isCameraGranted) {
    isCameraGranted = await Permission.camera.request() == PermissionStatus.granted;
}

if (!isCameraGranted) {
    // Have not permission to camera
    return;
}

// Generate filepath for saving
String imagePath = join((await getApplicationSupportDirectory()).path,
    "${(DateTime.now().millisecondsSinceEpoch / 1000).round()}.jpeg");

// Use below code for live camera detection with option to select from gallery in the camera feed.

try {
    //Make sure to await the call to detectEdge.
    bool success = await EdgeDetection.detectEdge(imagePath,
        canUseGallery: true,
        androidScanTitle: 'Scanning', // use custom localizations for android
        androidCropTitle: 'Crop',
        androidCropBlackWhiteTitle: 'Black White',
        androidCropReset: 'Reset',
    );
} catch (e) {
    print(e);
}

// Use below code for selecting directly from the gallery.

try {
    //Make sure to await the call to detectEdgeFromGallery.
    bool success = await EdgeDetection.detectEdgeFromGallery(imagePath,
        androidCropTitle: 'Crop', // use custom localizations for android
        androidCropBlackWhiteTitle: 'Black White',
        androidCropReset: 'Reset',
    );
} catch (e) {
    print(e);
}

Demo

Demo

Screenshots

Android

iOS

Using these native implementation
https://github.com/WeTransfer/WeScan

https://github.com/KePeng1019/SmartPaperScan

カテゴリー

ソースリポジトリ

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