1
私は簡単なOCRアプリケーションを作成しています。私はアプリをコンパイル/構築しようとしたが、エラーTesseract OCR原因:java.lang.IllegalArgumentException:データパスが存在しません
Caused by: java.lang.IllegalArgumentException: Data path does not exist!
以下の私のコードを取得しています今&を行っているすべてがある:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ts.myapplicationtest1/com.ts.myapplicationtest1.MainActivity}: java.lang.IllegalArgumentException: Data path does not exist!
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalArgumentException: Data path does not exist!
at com.googlecode.tesseract.android.TessBaseAPI.init(TessBaseAPI.java:303)
at com.googlecode.tesseract.android.TessBaseAPI.init(TessBaseAPI.java:280)
at com.ts.myapplicationtest1.MainActivity.onCreate(MainActivity.java:34)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
を:私は取得しています
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
private Bitmap bitmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.textimage);
bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init("/mnt/sdcard/tesseract/tessdata/eng.trainedata", "eng");
/* Also tried
baseApi.init("/mnt/sdcard/tesseract/", "eng");
baseApi.init("/mnt/sdcard/tesseract/tessdata/", "eng");
*/
baseApi.setImage(bitmap);
Log.v("....Text...", "....");
String recognizedText = baseApi.getUTF8Text();
Log.v("....Text...", " " + recognizedText);
baseApi.end();
}
}
エラーデータセットについては、私の電話帳のスクリーンショットを参照してください:
@rmthesisこれを解決してください。 – VVB