Code Monkey home page Code Monkey logo

android-document-scanner's People

Contributors

dmarcs avatar johnygqd avatar pierrenicol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

android-document-scanner's Issues

Doesn't function within a project

I have a big project going on and it seems theres something that creates conflict and doesn!t let the camera open. Says it doesnt find the source. However when I test it within a new project in a single activity works well. Any thoughts? Thanks

Increase Cropper size

Hey

Is there a way to increase cropper size? When adjusting corner I am covering almost all the cropper view with my tumb, I need to move my head around to see what's under that. Is there a way easy (or in a hacky way) to adjust it?
Btw, great library!

Greetings!

Error opening camera: Failed to find configured root that contains [filePath]

Hi!

I'm trying to integrate this library into an existing app but keep getting this error message:
V/documentscannerlogs: error - error opening camera: Failed to find configured root that contains /storage/emulated/0/Android/data/my.app.package/files/Pictures/DOCUMENT_SCAN_0_20230131_0958198508389360123480978.jpg

When I run the demo from this repo, it works fine. However, I've followed the instructions to the point, so I'm clueless where the error comes from. Do you have an idea?

Landscape is not working. The state is not saved

Nice work. But when staying in landscape the behaviour of the library is wrong.

simplest solution lock the orientation

    <activity
        android:name=".DocumentScannerActivity"
        android:screenOrientation="portrait"
        android:configChanges="orientation"
        android:theme="@style/Theme.FullScreen" />

Crash: ImageUtil.getImageMatrixFromFilePath

image

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.websitebeaver.documentscanner.utils.ImageUtil.getImageMatrixFromFilePath(ImageUtil.java:68) at com.websitebeaver.documentscanner.utils.ImageUtil.getImageFromFilePath(ImageUtil.java:86) at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.java:88) at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.java:75) at com.websitebeaver.documentscanner.utils.CameraUtil.startForResult$lambda-0(CameraUtil.java:41) at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:418) at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:375) at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:819) at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:164) at android.app.Activity.dispatchActivityResult(Activity.java:8192) at android.app.ActivityThread.deliverResults(ActivityThread.java:4965) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4292) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4338) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2057) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7649) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

I guess it can fix the problem: https://stackoverflow.com/questions/8442316/bitmap-is-returning-null-from-bitmapfactory-decodefilefilename.

Add document boundaries on preview (camera view)

It's really nice library that is also used in your react-native lib, but when compares to iOS, the only issue that we have is lack of preview for document boundaries. User do not know if the document has been found or not and need to capture image and then the crop can be set correctly, or totally not found and need to set it manually.

For improving user experience, it would be nice to see document boundaries in real-time on camera view

Update OpenCV version to 4.5.0

When will you be updated from v4.1.0 to v4.5.5 of OpenCV?

This version has a smaller application size, and upgrading to this version would be great.

Skipping middle screen

Hey
Is there a way to skip this screen and go directly to the picking corners one?
The whole process starts from taking photo screen, then it goes to this confirmation and and then to the last, picking corners screen. I would like to skip the second part as it brings no additional value.
Screenshot_20230203-152824

Thank you.

Force rear camera position

Is it possible to provide a property that specifies the camera's position to be used for scanning the documents?

Something like:

// open camera
startForResult.launch(takePictureIntent)

To

val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(takePictureIntent, REQUEST_CODE_CAMERA)

GL error: Out of memory!

I've encountered an "GL error: Out of memory!" error while using the application, specifically after taking a picture and while attempting to drag and drop pins. This issue has been observed on an Android 6.0 device running API 23. It seems to be related to a memory allocation problem. Any insights or assistance on resolving this issue would be greatly appreciated.

Pick image from gallery

Hello. This library is really useful. I just want to know that is there any option to pick image from gallery?

Thanks.

OpenCV(4.1.0) Error: Assertion failed (!_src.empty()) in cvtColor,

I tested the sample app on Pixel 2 XL Android 11 and I got this crash, however I tested it on pixel 5 Android 13 and it worked fine

A resource failed to call close.
OpenCV(4.1.0) Error: Assertion failed (!_src.empty()) in cvtColor, file /build/master_pack-android/open
imgproc::cvtColor_11() caught cv::Exception: OpenCV(4.1.0) /build/master_pack-android/opencv/modules/im
Shutting down VM
FATAL EXCEPTION: main
Process: com.websitebeaver.documentscanner.demo, PID: 13595
java.lang.RuntimeException: Unable to resume activity {com.websitebeaver.documentscanner.demo/com.websi
]
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4444)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=953472882
]
at android.app.ActivityThread.deliverResults(ActivityThread.java:5015)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4431)
... 11 more

Caused by: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.1.0) /build/master_pack-an
]
at org.opencv.imgproc.Imgproc.cvtColor_1(Native Method)
at org.opencv.imgproc.Imgproc.cvtColor(Imgproc.java:2309)
at com.websitebeaver.documentscanner.utils.ImageUtil.getImageFromFilePath(ImageUtil.kt:38)
at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerAct
at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerAct
at com.websitebeaver.documentscanner.utils.CameraUtil.startForResult$lambda-0(CameraUtil.kt:41)
at com.websitebeaver.documentscanner.utils.CameraUtil.$r8$lambda$QtmUm3JcXlX2aa1YkJnrPoMUzS8(Unknow
at com.websitebeaver.documentscanner.utils.CameraUtil$$ExternalSyntheticLambda0.onActivityResult(Un
at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:392)
at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:351)
at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:647)
at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
at android.app.Activity.dispatchActivityResult(Activity.java:8310)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5008)
... 12 more

Possible to add Share and Backbtn on Preview Page?

Hi,

i tried to add a share button and want also a "back" button to start on the last page where is just the preview.
I found the Place and tried to add it, but what can i use as uri for the intent.putExtra(Intent.EXTRA_STREAM, uri) of intent?

Here is full code

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // cropped image
        croppedImageView = findViewById(R.id.cropped_image_view)

        shareBtn = findViewById(R.id.shareBtn)
        shareBtn.setOnClickListener {
            val intent= Intent(Intent.ACTION_SEND)
            //intent.putExtra(Intent.EXTRA_TEXT,"Hey Check out this Great app:")
            //intent.type="text/plain"
            intent.putExtra(Intent.EXTRA_STREAM, uri)
            intent.type = "application/pdf"
            startActivity(Intent.createChooser(intent, null))
        }

        // start document scan
        documentScanner.startScan()
}

I just added the ShareBtn, also in layout but i get errors cause i didnt find an uri for the EXTRA_STREAM...

And is it also possible to add a function "back to start" there with a button too?
I am new to doing app things, so hope someone can help ๐Ÿ‘

OpenCV error

I keep getting this error

java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2)
at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method)
at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:114)
at com.websitebeaver.documentscanner.utils.ImageUtil.getImageFromFilePath(ImageUtil.kt:34)
at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.kt:98)
at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.kt:84)
at com.websitebeaver.documentscanner.utils.CameraUtil.startForResult$lambda-0(CameraUtil.kt:41)
at com.websitebeaver.documentscanner.utils.CameraUtil.$r8$lambda$QtmUm3JcXlX2aa1YkJnrPoMUzS8(Unknown Source:0)
at com.websitebeaver.documentscanner.utils.CameraUtil$$ExternalSyntheticLambda0.onActivityResult(Unknown Source:4)
at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:418)
at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:375)
at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:793)
at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
at android.app.Activity.dispatchActivityResult(Activity.java:8551)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5455)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4904)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4950)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2291)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1038)

I tried custom updating the documentScanner module but still no luck.

OpenCV assertion issue causing multiple crashes

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.ayumitra/com.websitebeaver.documentscanner.DocumentScannerActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2143666989, result=-1, data=null} to activity {com.ayumitra/com.websitebeaver.documentscanner.DocumentScannerActivity}: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.1.0) /build/master_pack-android/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
]
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5094)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5127)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
       at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2441)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:334)
       at android.app.ActivityThread.main(ActivityThread.java:8396)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2143666989, result=-1, data=null} to activity {com.ayumitra/com.websitebeaver.documentscanner.DocumentScannerActivity}: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.1.0) /build/master_pack-android/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
]
       at android.app.ActivityThread.deliverResults(ActivityThread.java:5651)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5081)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5127)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
       at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2441)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:334)
       at android.app.ActivityThread.main(ActivityThread.java:8396)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

Caused by org.opencv.core.CvException: cv::Exception: OpenCV(4.1.0) /build/master_pack-android/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

       at org.opencv.imgproc.Imgproc.cvtColor_1(Imgproc.java)
       at org.opencv.imgproc.Imgproc.cvtColor(Imgproc.java:2309)
       at com.websitebeaver.documentscanner.utils.ImageUtil.getImageFromFilePath(ImageUtil.kt:36)
       at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.kt:88)
       at com.websitebeaver.documentscanner.DocumentScannerActivity$cameraUtil$1.invoke(DocumentScannerActivity.kt:75)
       at com.websitebeaver.documentscanner.utils.CameraUtil.startForResult$lambda-0(CameraUtil.kt:41)
       at com.websitebeaver.documentscanner.utils.CameraUtil.lambda$QtmUm3JcXlX2aa1YkJnrPoMUzS8()
       at com.websitebeaver.documentscanner.utils.-$$Lambda$CameraUtil$QtmUm3JcXlX2aa1YkJnrPoMUzS8.onActivityResult(:4)
       at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:418)
       at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:375)
       at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:793)
       at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
       at android.app.Activity.dispatchActivityResult(Activity.java:8718)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:5644)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5081)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5127)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
       at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2441)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:334)
       at android.app.ActivityThread.main(ActivityThread.java:8396)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

Getting this crash for multiple users
Android build tools: 4.1.0
targetsdk 33

Not allowed to load resource: file:///storage/emulated/0/.....

Hi,

I have a webview. When I click on a button in the webview, the native app launch de document scanner.

The "success handler" return to me a path file : "file:///storage/emulated/0/Android/data/com.xxx/files/Pictures/DOCUMENT_SCAN_0_....jpg

On native app I can show the image in a ImageView.

but I can't show the image in the webview with an tag

Chrome response:
"Not allowed to load local resource: file:///storage/emulated/0/Android/data/com.xxx/files/Pictures/DOCUMENT_SCAN_0_xxxxxxx.jpg

And in my native app I've this settings:

myWebView.getSettings().setAllowContentAccess(true);
myWebView.getSettings().setAllowFileAccess(true);
myWebView.getSettings().setAllowFileAccessFromFileURLs(true);
myWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);

What's wrong ?

Crash on Landscape Camera Orientation

This library is working perfectly on portrait mode. I have locked my application activities to portrait mode but when camera is opened it can be changed to landscape mode and then app crashes. How can i resolve this issue?

Unable to install more than 1 app with this library due to hardcoded authority

Whenever you try to install another app with this library, gradle will fail:

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

List of apks:
[0] '[redacted]\app\build\intermediates\apk\release\app-release.apk'
Installation failed due to: 'Failed to commit install session 742080290 with command cmd package install-commit 742080290. Error: INSTALL_FAILED_CONFLICTING_PROVIDER: Scanning Failed.: Can't install because provider name com.websitebeaver.documentscanner.FileProvider (in package [redacted]) is already used by [redacted]'
Retry
Failed to launch an application on all devices

File not Found Exception

I was using older version of this library. It was working fine but crashed on camera orientation. Now i am using latest version but I am facing this issue.

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { (has extras) }} to activity {com.mgc.e_realtors/com.mgc.e_realtors.Realtor.Signup.Cnic.CnicActivity}: java.lang.RuntimeException: java.io.FileNotFoundException: /file:/storage/emulated/0/Android/data/com.mgc.e_realtors/files/Pictures/DOCUMENT_SCAN_0_20231202_1253008845266341652995473.jpg: open failed: ENOENT (No such file or directory)

I am setting the image using Picasso library. It was working fine in older version of the library.

Picasso.get().load(new File(result)).placeholder(R.color.light_gray).into(iv_cnicFront);

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.