Giter Club home page Giter Club logo

flutter-document-scanner's Introduction

Flutter Document Scanner

A Flutter project that demonstrates how to use Dynamsoft Document Normalizer to rectify and enhance document images on Android, iOS, Windows, Linux, and web.

Demo Video

flutter-document-scanner.mp4

Supported Platforms

  • Web
  • Android
  • iOS
  • Windows
  • Linux (Without camera support)

Getting Started

  1. Apply for a 30-day trial license and replace the license key in the global.dart file with your own:

    Future<int> initDocumentSDK() async {
        int? ret = await docScanner.init(
            'LICENSE-KEY');
        if (ret == 0) isLicenseValid = true;
        await docScanner.setParameters(Template.color);
        return ret ?? -1;
    }
  2. Run the project:

    flutter run
    # flutter run -d windows
    # flutter run -d edge
    # flutter run -d linux
    

Known Issues

The rectified images are converted to base64 strings and saved with shared_preferences. When the total size of the images you're trying to save exceeds the size limitation of web local storage (typically around 5MB), it can lead to issues such as the app crashing or unexpected behavior.

web local storage size limitation

Try Online Demo

https://yushulx.me/flutter-document-scanner/

flutter-document-scanner's People

Contributors

yushulx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

flutter-document-scanner's Issues

License

I downloaded the source code and it already has a valid license in the global.dart, so will it ever stop?

Crashing while scanning in Android 13 (Pixel 4a)

I have just cloned the project and pasted the trial key in my project. While Scanning from camera the viewfinder becomes visible but after 3โ€“4 seconds the app crashes with some random string I am unable to find the issue.

Logs:
Launching lib/main.dart on Pixel 4a in debug mode...
Running Gradle task 'assembleDebug'...
โœ“ Built build/app/outputs/flutter-apk/app-debug.apk.
Debug service listening on ws://127.0.0.1:59160/feyODKkVxVM=/ws
Syncing files to device Pixel 4a...
D/TrafficStats(26159): tagSocket(110) with statsTag=0xffffffff, statsUid=-1
D/ProfileInstaller(26159): Installing profile for com.example.documentscanner
I/CameraManagerGlobal(26159): Connecting to camera service
D/CompatibilityChangeReporter(26159): Compat change id reported: 206033068; UID 10910; state: ENABLED
W/Camera (26159): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420
I/Camera (26159): startPreview
I/Camera (26159): CameraCaptureSession onConfigured
I/Camera (26159): Updating builder settings
D/Camera (26159): Updating builder with feature: ExposureLockFeature
D/Camera (26159): Updating builder with feature: ExposurePointFeature
D/Camera (26159): Updating builder with feature: ZoomLevelFeature
D/Camera (26159): Updating builder with feature: AutoFocusFeature
D/Camera (26159): Updating builder with feature: NoiseReductionFeature
I/Camera (26159): updateNoiseReduction | currentSetting: fast
D/Camera (26159): Updating builder with feature: FocusPointFeature
D/Camera (26159): Updating builder with feature: ResolutionFeature
D/Camera (26159): Updating builder with feature: SensorOrientationFeature
D/Camera (26159): Updating builder with feature: FlashFeature
D/Camera (26159): Updating builder with feature: ExposureOffsetFeature
D/Camera (26159): Updating builder with feature: FpsRangeFeature
I/Camera (26159): refreshPreviewCaptureSession
I/Camera (26159): startPreviewWithImageStream
I/Camera (26159): CameraCaptureSession onConfigured
I/Camera (26159): Updating builder settings
D/Camera (26159): Updating builder with feature: ExposureLockFeature
D/Camera (26159): Updating builder with feature: ExposurePointFeature
D/Camera (26159): Updating builder with feature: ZoomLevelFeature
D/Camera (26159): Updating builder with feature: AutoFocusFeature
D/Camera (26159): Updating builder with feature: NoiseReductionFeature
I/Camera (26159): updateNoiseReduction | currentSetting: fast
D/Camera (26159): Updating builder with feature: FocusPointFeature
D/Camera (26159): Updating builder with feature: ResolutionFeature
D/Camera (26159): Updating builder with feature: SensorOrientationFeature
D/Camera (26159): Updating builder with feature: FlashFeature
D/Camera (26159): Updating builder with feature: ExposureOffsetFeature
D/Camera (26159): Updating builder with feature: FpsRangeFeature
I/Camera (26159): refreshPreviewCaptureSession
I/Camera (26159): CameraCaptureSession onClosed
W/System (26159): A resource failed to call Surface.release.
F/libc (26159): Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6e23a6e001 in tid 26296 (pool-2-thread-1), pid 26159 (documentscanner)


Build fingerprint: 'google/sunfish/sunfish:13/TQ3A.230805.001/10316531:user/release-keys'
Revision: 'MP1.0'
ABI: 'arm64'
Timestamp: 2023-10-25 17:48:14.567885227+0530
Process uptime: 12s
Cmdline: com.example.documentscanner
pid: 26159, tid: 26296, name: pool-2-thread-1 >>> com.example.documentscanner <<<
uid: 10910
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x0000006e23a6e001
x0 b400006e2398d000 x1 0000000000000000 x2 00000000000e1000 x3 b400006e23418000
x4 b400006e23a6e000 x5 000000000000003d x6 0000000003000000 x7 0000000000000000
x8 0000000000000000 x9 0000000000000500 x10 0000000000000500 x11 00000000000002d0
x12 0000006da8394062 x13 0000006da8394862 x14 0000006da8394462 x15 0000006da8394662
x16 0000006da8394262 x17 0000000000000f00 x18 00000000000000ff x19 b400006efb62b3f0
x20 0000000000000060 x21 0000000000000060 x22 b400006e2398d000 x23 00000000000002d0
x24 b400006e23418000 x25 0000000000000500 x26 0000000000000500 x27 0000000000000018
x28 0000006e237c2000 x29 0000006e237bfc90
lr 0000006da8010820 sp 0000006e237bfbd0 pc 0000006da801089c pst 0000000020000000
backtrace:
#00 pc 000000000012589c /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftImageProcessing.so (dynamsoft::DMMatrix::ConvertYUVToRGB(unsigned char const*, int, int, int, int, int, int, dynamsoft::DMMatrix*)+288) (BuildId: 78e13e1d2bad0502e5a91d11f2bf7f593ccfbd8d)
#1 pc 0000000000124200 /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftImageProcessing.so (dynamsoft::DMMatrix::GetMatrixByBuffer(unsigned char const*, int, int, int, ImagePixelFormat, int&, int, dynamsoft::DMMatrix*, ColourChannelUsageType)+480) (BuildId: 78e13e1d2bad0502e5a91d11f2bf7f593ccfbd8d)
#2 pc 0000000000077eb8 /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftDocumentNormalizer.so (BuildId: 3918cc999edf6fffd8aaa74183a5f8581a794859)
#03 pc 00000000000788f4 /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftDocumentNormalizer.so (dynamsoft::ddn::DDNDetector::DetectQuad(dynamsoft::core::CImageData const&, DDNParameter*, int*)+76) (BuildId: 3918cc999edf6fffd8aaa74183a5f8581a794859)
#04 pc 00000000000527b0 /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftDocumentNormalizer.so (CDocumentNormalizerInner::DetectQuadFromBuffer(dynamsoft::core::CImageData const*, char const*, dynamsoft::ddn::CDetectedQuadResultArray**)+724) (BuildId: 3918cc999edf6fffd8aaa74183a5f8581a794859)
#05 pc 000000000004ff98 /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/lib/arm64/libDynamsoftDocumentNormalizer.so (Java_com_dynamsoft_ddn_DocumentNormalizer_nativeDetectQuadFromBuffer+148) (BuildId: 3918cc999edf6fffd8aaa74183a5f8581a794859)
#06 pc 000000000034dc30 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#07 pc 00000000003371a4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#08 pc 0000000000519790 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#09 pc 00000000004a3274 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+2040) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#10 pc 00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#11 pc 00000000001749a8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/base.apk] (com.dynamsoft.ddn.DocumentNormalizer.detectQuad+0)
#12 pc 000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#13 pc 000000000051a45c /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#14 pc 00000000004a2e3c /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+960) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#15 pc 00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#16 pc 000000000000c490 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~J1cyYW47Inxhrd3Ld6f5pA==/com.example.documentscanner-a2UN5rz-jOm6mwFrF_yAOw==/base.apk!classes2.dex] (com.dynamsoft.flutter_document_scan_sdk.FlutterDocumentScanSdkPlugin$2.run+0)
#17 pc 000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#18 pc 000000000051a45c /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#19 pc 00000000004a3ce8 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+4716) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#20 pc 00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#21 pc 00000000002488d8 /apex/com.android.art/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor.runWorker+0)
#22 pc 000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#23 pc 000000000051a45c /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#24 pc 00000000004a2e3c /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+960) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#25 pc 00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#26 pc 0000000000247774 /apex/com.android.art/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor$Worker.run+0)
#27 pc 000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#28 pc 000000000051a45c /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#29 pc 00000000004a3ce8 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+4716) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#30 pc 00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#31 pc 000000000010ee0c /apex/com.android.art/javalib/core-oj.jar (java.lang.Thread.run+0)
#32 pc 000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#33 pc 000000000036bff8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#34 pc 000000000034dd68 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#35 pc 00000000003371a4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#36 pc 000000000023ea64 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#37 pc 000000000054436c /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#38 pc 00000000000b63b0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 4e07915368c859b1910c68c84a8de75f)
#39 pc 00000000000530b8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 4e07915368c859b1910c68c84a8de75f)
Lost connection to device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.