Androidアプリ開発の勉強中です
tess-twoを用いて画像の文字認識をするサンプルプログラムを試しているのですが、
Data file not found at /data/user/0/com.websarva.wings.android.ocr_sample2/files/tessdata/eng.traineddata
というエラーがでます
app/assets/tessdata/eng.traineddata
に言語データをおいています
どこをどう改善すればエラーがなくなるでしょうか
エラーメッセージ
D/tag: msg D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.websarva.wings.android.ocr_sample2, PID: 4879 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:109 flg=0x43 }} to activity {com.websarva.wings.android.ocr_sample2/com.websarva.wings.android.ocr_sample2.MainActivity}: java.lang.IllegalArgumentException: Data file not found at /data/user/0/com.websarva.wings.android.ocr_sample2/files/tessdata/eng.traineddata at android.app.ActivityThread.deliverResults(ActivityThread.java:4360) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.IllegalArgumentException: Data file not found at /data/user/0/com.websarva.wings.android.ocr_sample2/files/tessdata/eng.traineddata at com.googlecode.tesseract.android.TessBaseAPI.init(TessBaseAPI.java:339) at com.googlecode.tesseract.android.TessBaseAPI.init(TessBaseAPI.java:303) at com.websarva.wings.android.ocr_sample2.OCR_act.getString(OCR_act.kt:67) at com.websarva.wings.android.ocr_sample2.MainActivity.onActivityResult(MainActivity.kt:88) at android.app.Activity.dispatchActivityResult(Activity.java:7454) at android.app.ActivityThread.deliverResults(ActivityThread.java:4353) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
###ソースコード
kotlin
1 ... 2 bitmap?.let { 3 image.setImageBitmap(it) 4 val langId = radio_group.getCheckedRadioButtonId() 5 val langText = findViewById<RadioButton>(langId).text.toString() 6 Log.d("tag","msg") 7 ocr.text = ocract.getString(applicationContext, it, OCR_act.Companion.LangType.getLangType(langText).str) 8 Log.d("tag1","msg") 9 } ?: run { 10 ocr.text = "bitmap is null" 11 12 }
利用環境
Android Studio 3.6
Windows10
補足
https://qiita.com/tarumzu/items/9eaa9c13041a4f8ed63c
を参考にしています
回答1件
あなたの回答
tips
プレビュー