-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
21,008 additions
and
1,288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build and Deploy Flutter Web | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Flutter | ||
uses: subosito/flutter-action@v1 | ||
with: | ||
channel: 'stable' | ||
- name: Get dependencies | ||
run: | | ||
cd example | ||
flutter pub get | ||
- uses: bluefireteam/flutter-gh-pages@v7 | ||
with: | ||
baseHref: /flutter_ocr_sdk/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 1.2.0 | ||
- Support AGP 8 for Android. | ||
- Update example code. | ||
|
||
## 1.1.4 | ||
- Fixed dependency issue for iOS. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,21 @@ | ||
# flutter_ocr_sdk | ||
# Flutter MRZ SDK | ||
|
||
A wrapper for [Dynamsoft OCR SDK](https://www.dynamsoft.com/label-recognition/overview/) with MRZ detection model. It helps developers build Flutter applications to detect machine-readable zones (**MRZ**) in passports, travel documents, and ID cards. | ||
A wrapper for [Dynamsoft Label Recognizer v2.x](https://www.dynamsoft.com/label-recognition/overview/) with MRZ detection model. It helps developers build Flutter applications to detect machine-readable zones (**MRZ**) in passports, travel documents, and ID cards. | ||
|
||
## Try MRZ Detection Example | ||
## License Key | ||
To use the SDK, you need a [license key for Dynamsoft Label Recognizer](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. | ||
|
||
### Mobile: Android and iOS | ||
```bash | ||
cd example | ||
flutter run | ||
``` | ||
## Try Flutter MRZ Detection Example | ||
|
||
![Flutter Passport MRZ recognition](https://www.dynamsoft.com/codepool/img/2021/07/flutter-passport-mrz-recognition.jpg) | ||
|
||
### Web | ||
```bash | ||
cd example | ||
flutter run -d chrome | ||
flutter run # for Android | ||
flutter run -d chrome # for Web | ||
flutter run -d windows # for Windows | ||
``` | ||
|
||
![Flutter MRZ recognition in web](https://www.dynamsoft.com/codepool/img/2023/01/flutter_mrz_ocr_web.png) | ||
|
||
### Desktop: Windows and Linux | ||
```bash | ||
cd example | ||
flutter run -d windows | ||
|
||
# flutter run -d linux | ||
``` | ||
![Flutter Passport MRZ recognition](https://www.dynamsoft.com/codepool/img/2024/10/flutter-passport-mrz-reader-scanner.png) | ||
|
||
![Flutter MRZ OCR in Windows](https://www.dynamsoft.com/codepool/img/2023/01/flutter-mrz-ocr-windows.png) | ||
|
||
## Supported Platforms | ||
- Android | ||
|
@@ -46,8 +33,8 @@ dependencies: | |
flutter_ocr_sdk: | ||
``` | ||
### One More Step for Web | ||
Include the JavaScript library of Dynamsoft Label Recognizer in your `index.html` file: | ||
### Additional Step for Web | ||
To support web functionality, include the JavaScript library of Dynamsoft Label Recognizer in your `index.html` file: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dlr.js"></script> | ||
|
@@ -64,7 +51,7 @@ Include the JavaScript library of Dynamsoft Label Recognizer in your `index.html | |
|
||
|
||
## Usage | ||
- Initialize the MRZ detector with a [valid license key](https://www.dynamsoft.com/customer/license/trialLicense/?product=dlr): | ||
- Initialize the MRZ detector with a valid license key: | ||
|
||
```dart | ||
FlutterOcrSdk _mrzDetector = FlutterOcrSdk(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: adc687823a831bbebe28bdccfac1a628ca621513 | ||
revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: android | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: ios | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: linux | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: macos | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: web | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
- platform: windows | ||
create_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
base_revision: f92f44110e87bad5ff168335c36da6f6053036e6 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
# Flutter MRZ Scanner | ||
|
||
A Flutter project that demonstrates how to use [Dynamsoft Label Recognizer](https://www.dynamsoft.com/label-recognition/overview/) to scan MRZ (Machine Readable Zone) from passport, visa, and ID cards. | ||
|
||
https://github.com/yushulx/flutter_ocr_sdk/assets/2202306/bb10f353-bcfc-4b41-a1ef-fc7fcb6a25ef | ||
|
||
## Supported Platforms | ||
- **Web** | ||
- **Android** | ||
- **iOS** | ||
- **Windows** | ||
- **Linux** (Without camera support) | ||
|
||
## Known Issues | ||
When the application is executed on desktop browsers, the camera frame appears mirrored. This has been observed to cause failures in the Machine Readable Zone (MRZ) detection process. Therefore, it's necessary to address this issue within the [Flutter camera plugin](https://pub.dev/packages/camera). | ||
|
||
![flutter camera issue for web](https://github.com/yushulx/flutter-MRZ-scanner/assets/2202306/7bdd7e57-7340-4149-a081-75f4622851aa) | ||
|
||
A temporary workaround is to disable the camera flip code in [https://github.com/flutter/packages/blob/main/packages/camera/camera_web/lib/src/camera_web.dart](https://github.com/flutter/packages/blob/main/packages/camera/camera_web/lib/src/camera_web.dart): | ||
|
||
```dart | ||
// final bool isBackCamera = getLensDirection() == CameraLensDirection.back; | ||
// Flip the picture horizontally if it is not taken from a back camera. | ||
// if (!isBackCamera) { | ||
// canvas.context2D | ||
// ..translate(videoWidth, 0) | ||
// ..scale(-1, 1); | ||
// } | ||
``` | ||
|
||
|
||
## Getting Started | ||
1. Apply for a [30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) and replace the license key in the `global.dart` file with your own: | ||
|
||
```dart | ||
Future<int> initMRZSDK() async { | ||
await mrzDetector.init( | ||
"LICENSE-KEY"); | ||
return await mrzDetector.loadModel() ?? -1; | ||
} | ||
``` | ||
2. Run the project: | ||
``` | ||
flutter run | ||
# flutter run -d windows | ||
# flutter run -d edge | ||
# flutter run -d linux | ||
``` | ||
## Try Online Demo | ||
[https://yushulx.me/flutter-MRZ-scanner/](https://yushulx.me/flutter-MRZ-scanner/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,44 @@ | ||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('local.properties') | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
} | ||
|
||
def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
if (flutterRoot == null) { | ||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
} | ||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
if (flutterVersionCode == null) { | ||
flutterVersionCode = '1' | ||
plugins { | ||
id "com.android.application" | ||
id "kotlin-android" | ||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. | ||
id "dev.flutter.flutter-gradle-plugin" | ||
} | ||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
if (flutterVersionName == null) { | ||
flutterVersionName = '1.0' | ||
} | ||
|
||
apply plugin: 'com.android.application' | ||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
|
||
android { | ||
compileSdkVersion flutter.compileSdkVersion | ||
ndkVersion flutter.ndkVersion | ||
namespace = "com.example.mrzscanner" | ||
compileSdk = flutter.compileSdkVersion | ||
ndkVersion = flutter.ndkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
defaultConfig { | ||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
applicationId "com.dynamsoft.flutter_ocr_sdk_example" | ||
applicationId = "com.example.mrzscanner" | ||
// You can update the following values to match your application needs. | ||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. | ||
minSdkVersion 21 | ||
targetSdkVersion flutter.targetSdkVersion | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
// For more information, see: https://flutter.dev/to/review-gradle-config. | ||
minSdk = flutter.minSdkVersion | ||
targetSdk = flutter.targetSdkVersion | ||
versionCode = flutter.versionCode | ||
versionName = flutter.versionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig signingConfigs.debug | ||
signingConfig = signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source '../..' | ||
source = "../.." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
example/android/app/src/main/java/com/dynamsoft/flutter_ocr_sdk_example/MainActivity.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...t/flutter_ocr_sdk_example/MainActivity.kt → ...in/com/example/mrzscanner/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+16.8 KB
(3300%)
example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.8 KB
(2600%)
example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+23.3 KB
(3400%)
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+40.5 KB
(4100%)
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+58.9 KB
(4300%)
example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.