Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yushulx/flutter_document_scan_sdk
A Flutter Document Detection SDK built with Dynamsoft Document Normalizer
https://github.com/yushulx/flutter_document_scan_sdk
dart document-detection document-rectification flutter
Last synced: 3 months ago
JSON representation
A Flutter Document Detection SDK built with Dynamsoft Document Normalizer
- Host: GitHub
- URL: https://github.com/yushulx/flutter_document_scan_sdk
- Owner: yushulx
- License: mit
- Created: 2022-11-24T07:34:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T06:57:50.000Z (3 months ago)
- Last Synced: 2024-10-09T08:08:37.431Z (3 months ago)
- Topics: dart, document-detection, document-rectification, flutter
- Language: C++
- Homepage: https://pub.dev/packages/flutter_document_scan_sdk
- Size: 32.1 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flutter Document Detection SDK
The Flutter plugin is a wrapper for Dynamsoft's [Document Normalizer SDK v1.x](https://www.dynamsoft.com/document-normalizer/docs/introduction/). It enables you to build document detection and rectification applications for **Windows**, **Linux**, **web**, **Android** and **iOS**.## License Key
To use the SDK, you need a [license key for Dynamsoft Document Normalizer](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform). Make sure to get your trial or commercial license before using the library.## Try Document Rectification Example
```bash
cd example
flutter run # for Android
flutter run -d chrome # for Web
flutter run -d windows # for Windows
```![Flutter web document edge detection and normalization](https://www.dynamsoft.com/codepool/img/2024/10/flutter-document-scanner-detection-rectification.png)
## Supported Platforms
- Web
- Windows
- Linux
- Android
- iOS## Installation
Add `flutter_document_scan_sdk` as a dependency in your `pubspec.yaml` file.```yml
dependencies:
...
flutter_document_scan_sdk:
```### One More Step for Web
Include the JavaScript library of Dynamsoft Document Normalizer in your `index.html` file:```html
```
## API Compatibility
| Methods | Android | iOS | Windows | Linux | Web|
| ----------- | ----------- | ----------- | ----------- |----------- |----------- |
| `Future init(String key)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: |
| `Future?> detectFile(String file)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark: |
| `Future normalizeFile(String file, dynamic points)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark: |
| `Future setParameters(String params)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: |
| `Future getParameters()` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: |
| `Future?> detectBuffer(Uint8List bytes, int width, int height, int stride, int format)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark: |
| `Future normalizeBuffer(Uint8List bytes, int width, int height, int stride, int format, dynamic points)` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:heavy_check_mark: | :heavy_check_mark: |## Usage
- Initialize the document rectification SDK with a valid license key:```dart
final _flutterDocumentScanSdkPlugin = FlutterDocumentScanSdk();
await _flutterDocumentScanSdkPlugin.init(
"LICENSE-KEY");await _flutterDocumentScanSdkPlugin.setParameters(Template.grayscale);
```- Do document edge detection and return quadrilaterals:
```dart
List? detectionResults =
await _flutterDocumentScanSdkPlugin
.detectFile(file);
```
- Detect document edges from a buffer:```dart
List? detectionResults =
await _flutterDocumentScanSdkPlugin
.detectBuffer(bytes, width, height, stride, format);
```
- Rectify the document based on document corners:```dart
NormalizedImage? normalizedImage = await _flutterDocumentScanSdkPlugin.normalizeFile(
file, detectionResults[0].points);
```
- Rectify the document based on document corners from a buffer:```dart
NormalizedImage? normalizedImage = await _flutterDocumentScanSdkPlugin.normalizeBuffer(
bytes, width, height, stride, format, detectionResults[0].points);
```
- Save the rectified document image to a file:```dart
if (normalizedUiImage != null) {
const String mimeType = 'image/png';
ByteData? data = await normalizedUiImage!
.toByteData(format: ui.ImageByteFormat.png);
if (data != null) {
final XFile imageFile = XFile.fromData(
data.buffer.asUint8List(),
mimeType: mimeType,
);
await imageFile.saveTo(path);
}
}
```