패키지, 저장소 및 앱 카테고리 검색

edge_detection 표지
패키지 상세v1.1.3

edge_detection

객체의 가장자리 감지, 종이 스캔, 모서리 감지, 사각형 감지를 위한 플러터 플러그인입니다. 감지된 객체 이미지의 자르기를 허용하고 자른 이미지의 경로를 반환합니다.

AndroidiOS
30일 다운로드
408
좋아요
310
Pub 점수
150

패키지 설치

flutter pub add edge_detection

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

이미지 내 에지, 모서리 및 사각형을 감지하기 위한 플러터 플러그인으로, 문서 스캔에 적합합니다. 감지된 객체를 자동으로 자르고 자른 이미지의 경로를 반환합니다. OCR 및 컴퓨터 비전 응용 프로그램용으로 설계되었으며, 안드로이드와 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트