Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when returning result from image #1

Open
jagged91 opened this issue Apr 20, 2016 · 14 comments
Open

Crash when returning result from image #1

jagged91 opened this issue Apr 20, 2016 · 14 comments

Comments

@jagged91
Copy link

Hi,

Building the sample app, I get the following crash when returning the image to the activity:

04-20 16:18:07.068 454-1975/com.wordpress.priyankvex.easyocrscanner E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.wordpress.priyankvex.easyocrscanner, PID: 454 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:304) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.wordpress.priyankvex.easyocrscanner-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libpngt.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:988) at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:43) at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.scanImage(ImageProcessingThread.java:142) at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.doInBackground(ImageProcessingThread.java:58) at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.doInBackground(ImageProcessingThread.java:26) at android.os.AsyncTask$2.call(AsyncTask.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)  at java.lang.Thread.run(Thread.java:818)  04-20 16:18:07.838 454-454/com.wordpress.priyankvex.easyocrscanner E/WindowManager: android.view.WindowLeaked: Activity com.wordpress.priyankvex.easyocrscannerdemo.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{285963da V.E..... R......D 0,0-1368,464} that was originally added here at android.view.ViewRootImpl.<init>(ViewRootImpl.java:527) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:287) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:87) at android.app.Dialog.show(Dialog.java:325) at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onOcrScanStarted(MainActivity.java:59) at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.onPreExecute(ImageProcessingThread.java:51) at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:591) at android.os.AsyncTask.execute(AsyncTask.java:539) at com.wordpress.priyankvex.easyocrscannerdemo.EasyOcrScanner.onImageTaken(EasyOcrScanner.java:44) at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onActivityResult(MainActivity.java:46) at android.app.Activity.dispatchActivityResult(Activity.java:6808) at android.app.ActivityThread.deliverResults(ActivityThread.java:4698) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4745) at android.app.ActivityThread.access$1500(ActivityThread.java:197) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1730) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6872) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

@gsiqueira
Copy link

gsiqueira commented May 1, 2016

I had exactly the same issue. Is there any way to solve this? It happens right after you take the picture. It tries to scan for a while, then crashes. That's my first time working with an OCR API, and I must say your code helped me a lot to have the basis. If you could tell how to go through this, it would be great. Thanks!

@priyankvex
Copy link
Owner

I am having my exams. Will look into this after exams. If you write steps to reproduce it, that would be great.

@gsiqueira
Copy link

gsiqueira commented May 27, 2016

Thanks for your reply. I repeated all the steps carefully to run the app, and for some reason it works now. One thing I dont now how to deal with is the quality of the recognition and also the time spent, very long sometimes, and not returning a satisfactory result after it. Do you know how I could improve this?

Thanks again.

@priyankvex
Copy link
Owner

@gsiqueira Time spent depends on the quality of the image. Large image size means more time needed to process it.

@gsiqueira
Copy link

gsiqueira commented Jun 2, 2016

Yes, I tried some things to solve this problem, I reduced the size (640x460 and smaller) of the image taken, tried to binarize it, turn flash on, to improve brightness, but I still get the same result, which takes about one and two minutes to finish the process. The image I used to test has just 10 short lines, is this normal?

I was looking at the code here, and I found the following:

https://cloud.githubusercontent.com/assets/7751486/15730868/c7a96e24-2846-11e6-8c09-5de5607f2443.png

It is strange, because android studio builds the app and it works. I am just showing you this because I don't know if it has something to do with my problem.

Below you find the image I used and the best result I took. Thank you a lot for your attention in my problem.

Source image
https://cloud.githubusercontent.com/assets/7751486/15731177/83f3e27e-2849-11e6-8975-08bb5604edf2.jpg

Result
https://cloud.githubusercontent.com/assets/7751486/15731159/559518f8-2849-11e6-9368-9f0cfd988663.png

@priyankvex
Copy link
Owner

Well the accuracy of OCR is not 100% accurate, at least this is the case for the ones those are open sourced.

@rdobrich
Copy link

Hi, I had received exactly the same error.

@eSigTech
Copy link

i have also issue.facing crash.Any solution priyankvex.
Thanks in advance

logcat result:

01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: Activity com.wordpress.priyankvex.easyocrscannerdemo.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41f8c370 V.E..... R......D 0,0-304,96} that was originally added here
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: android.view.WindowLeaked: Activity com.wordpress.priyankvex.easyocrscannerdemo.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41f8c370 V.E..... R......D 0,0-304,96} that was originally added here
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.view.ViewRootImpl.(ViewRootImpl.java:409)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:218)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.Dialog.show(Dialog.java:281)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onOcrScanStarted(MainActivity.java:59)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.onPreExecute(ImageProcessingThread.java:51)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.os.AsyncTask.execute(AsyncTask.java:534)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.wordpress.priyankvex.easyocrscannerdemo.EasyOcrScanner.onImageTaken(EasyOcrScanner.java:44)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onActivityResult(MainActivity.java:46)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.Activity.dispatchActivityResult(Activity.java:5311)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.ActivityThread.deliverResults(ActivityThread.java:3521)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3568)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.ActivityThread.access$1100(ActivityThread.java:162)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.os.Handler.dispatchMessage(Handler.java:107)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.os.Looper.loop(Looper.java:194)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at android.app.ActivityThread.main(ActivityThread.java:5371)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at java.lang.reflect.Method.invokeNative(Native Method)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at java.lang.reflect.Method.invoke(Method.java:525)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-02 00:54:02.801 19607-19607/com.wordpress.priyankvex.easyocrscanner E/WindowManager: at dalvik.system.NativeStart.main(Native Method)

@TNT-Apps1
Copy link

From the original post...

couldn't find "libpngt.so"

I ran into this before. In Android studio, right click the module, select "Open Module Settings", click the "Dependencies" tab, remove the "easy_ocr_library", click "OK". Then right click the "easy_ocr_library" in your project, select "Open Module Settings" and remove the "easy_ocr_library" module by using the red "-". Close Android Studio then go to your folder that contains the "easy_ocr_library" and delete the whole "easy_ocr_library" folder and rebuild it from new.

This doesn't solve the core problem but gets you back to where you were I've found.

@akki10
Copy link

akki10 commented Aug 22, 2016

Facing the same issue. Any solution?

Here is my log:

08-22 15:14:39.674 15432-16033/com.wordpress.priyankvex.easyocrscanner D/OcrScanner: tessdata already present
08-22 15:14:39.721 15432-16033/com.wordpress.priyankvex.easyocrscanner E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.wordpress.priyankvex.easyocrscanner, PID: 15432
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-support-annotations-22.2.1_d1acf46021f20f049c52e8e8d2eef24d273c7976-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-internal_impl-22.2.1_e15adb6504281a2254b4ee3bf34531e1c042464d-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-com.android.support-support-v4-22.2.1_f36f4d36fecc7b76b177aa9708feabdb64dd924c-classes.dex", dex file "/data/data/com.wordpress.priyankvex.easyocrscanner/files/instant-run/dex/slice-com.android.support-appcompat-v7-22.2.1_4daf6349f79e575f360e5411107bef913a07530a-classes.dex"],nativeLibraryDirectories=[/data/app/com.wordpress.priyankvex.easyocrscanner-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpngt.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at com.googlecode.tesseract.android.TessBaseAPI.(TessBaseAPI.java:43)
at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.scanImage(ImageProcessingThread.java:142)
at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.doInBackground(ImageProcessingThread.java:58)
at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.doInBackground(ImageProcessingThread.java:26)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
08-22 15:14:40.139 15432-15432/com.wordpress.priyankvex.easyocrscanner E/WindowManager: android.view.WindowLeaked: Activity com.wordpress.priyankvex.easyocrscannerdemo.MainActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{7e5d8de V.E...... R......D 0,0-1026,348} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:368)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:302)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:86)
at android.app.Dialog.show(Dialog.java:322)
at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onOcrScanStarted(MainActivity.java:59)
at com.wordpress.priyankvex.easyocrscannerdemo.ImageProcessingThread.onPreExecute(ImageProcessingThread.java:51)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:604)
at android.os.AsyncTask.execute(AsyncTask.java:551)
at com.wordpress.priyankvex.easyocrscannerdemo.EasyOcrScanner.onImageTaken(EasyOcrScanner.java:44)
at com.wordpress.priyankvex.easyocrscannerdemo.MainActivity.onActivityResult(MainActivity.java:46)
at android.app.Activity.dispatchActivityResult(Activity.java:6508)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3702)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3749)
at android.app.ActivityThread.access$1400(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5438)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

@hrajalin
Copy link

Hi,

I get the same error, while running in LG G3:

10-31 09:58:20.790 19999-22301/com.wordpress.priyankvex.easyocrscanner E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.wordpress.priyankvex.easyocrscanner, PID: 19999
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
...

@gsiqueira
Do you have any ideas what was the root cause in your case?

@l1va
Copy link

l1va commented Nov 16, 2016

Hi all, seems studio removes build directory, i fixed the problem by: git checkout easy_ocr_library/libs/tess-two/build/* Check that needed files not deleted by git status.

@tair-rhyme
Copy link

Changing the dependency of easy_ocr_library module should solve the problem:

  1. Delete tess-two module
  2. Add a maven dependencycom.rmtheis:tess-two:6.1.1

@prakashsatyani
Copy link

Still not working for me...!! Cannot resolve ImageProcessingThread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests