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

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

所屬分類

原始碼儲存庫

使用此套件的專案