0

我正在关注这里的教程。

我已经完成了所有步骤,当我在 eclipse 中单击运行时,它似乎可以在应用程序进入我的手机时工作。

但是,当我单击它时,会出现“强制关闭错误”。

当我从电脑上拔下手机时,我可以拍照,但是当我对它进行 ocr 操作时,我得到了强制关闭错误。

我正在使用 Windows 7,阅读它应该工作的页面上的评论

这是我得到的一些 logcat 错误的打印 -

@Override
public void onCreate(Bundle savedInstanceState) {

    String[] paths = new String[] { DATA_PATH, DATA_PATH + "tessdata/" };

    for (String path : paths) {
        File dir = new File(path);
        if (!dir.exists()) {
            if (!dir.mkdirs()) {
                Log.v(TAG, "ERROR: Creation of directory " + path + " on sdcard failed");
                return;
            } else {
                Log.v(TAG, "Created directory " + path + " on sdcard");
            }
        }

    }

    // lang.traineddata file with the app (in assets folder)
    // You can get them at:
    // http://code.google.com/p/tesseract-ocr/downloads/list
    // This area needs work and optimization
    if (!(new File(DATA_PATH + "tessdata/" + lang + ".traineddata")).exists()) {
        try {

            AssetManager assetManager = getAssets();
            InputStream in = assetManager.open("tessdata/eng.traineddata");
            //GZIPInputStream gin = new GZIPInputStream(in);
            OutputStream out = new FileOutputStream(DATA_PATH
                    + "tessdata/eng.traineddata");

            // Transfer bytes from in to out
            byte[] buf = new byte[1024];
            int len;
            //while ((lenf = gin.read(buff)) > 0) {
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            //gin.close();
            out.close();

            Log.v(TAG, "Copied " + lang + " traineddata");
        } catch (IOException e) {
            Log.e(TAG, "Was unable to copy " + lang + " traineddata " + e.toString());
        }
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    // _image = (ImageView) findViewById(R.id.image);
    _field = (EditText) findViewById(R.id.field);
    _button = (Button) findViewById(R.id.button);
    _button.setOnClickListener(new ButtonClickHandler());

    _path = DATA_PATH + "/ocr.jpg";
    //_path = DATA_PATH + "/shuffledDigits.jpg";

}

错误日志

    12-11 18:09:14.097: E/jdwp(926): Failed sending req to debugger: Broken pipe (-1 of 27)
    12-11 18:09:14.097: E/jdwp(926): Failed sending req to debugger: Broken pipe (-1 of 27)
    12-11 18:09:14.097: E/jdwp(926): Failed sending reply to debugger: Broken pipe
    12-11 18:09:14.287: V/SimpleAndroidOCR.java(926): ERROR: Creation of directory /sdcard/SimpleAndroidOCR/ on sdcard failed
    12-11 18:09:14.287: D/AndroidRuntime(926): Shutting down VM
    12-11 18:09:14.287: W/dalvikvm(926): threadid=3: thread exiting with uncaught exception (group=0x40026160)
    12-11 18:09:14.287: E/AndroidRuntime(926): Uncaught handler: thread main exiting due to uncaught exception
    12-11 18:09:14.306: E/AndroidRuntime(926): android.app.SuperNotCalledException: Activity {com.datumdroid.android.ocr.simple/com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity} did not call through to super.onCreate()
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.app.ActivityThread.access$2200(ActivityThread.java:123)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.os.Handler.dispatchMessage(Handler.java:99)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.os.Looper.loop(Looper.java:123)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at android.app.ActivityThread.main(ActivityThread.java:4370)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at java.lang.reflect.Method.invokeNative(Native Method)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at java.lang.reflect.Method.invoke(Method.java:521)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    12-11 18:09:14.306: E/AndroidRuntime(926):  at dalvik.system.NativeStart.main(Native Method)
    12-11 18:09:14.597: D/dalvikvm(915): GC freed 1836 objects / 141248 bytes in 161ms
    12-11 18:09:14.657: W/ActivityManager(1233): Activity pause timeout for HistoryRecord{45b2f140 com.datumdroid.android.ocr.simple/.SimpleAndroidOCRActivity}
    12-11 18:09:14.657: E/SemcCheckin(926): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
    12-11 18:09:14.657: W/ActivityManager(1233): Unable to start service Intent { act=com.sonyericsson.android.jcrashcatcher.action.BUGREPORT_AUTO cmp=com.sonyericsson.android.jcrashcatcher/.JCrashCatcherService (has extras) }: not found
    12-11 18:09:14.667: I/Process(1233): Sending signal. PID: 926 SIG: 3
    12-11 18:09:14.667: I/dalvikvm(926): threadid=7: reacting to signal 3
    12-11 18:09:14.667: I/dalvikvm(926): Wrote stack trace to '/data/anr/traces.txt'
    12-11 18:09:14.677: I/Process(926): Sending signal. PID: 926 SIG: 9
    12-11 18:09:14.687: E/SemcCheckin(1704): Get Crash Level : java.io.FileNotFoundException: /data/semc-checkin/crashdump

    12-11 18:12:30.927: E/AndroidRuntime(1009): Uncaught handler: thread main exiting due to uncaught exception
    12-11 18:12:30.936: E/AndroidRuntime(1009): java.lang.ExceptionInInitializerError
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.Activity.dispatchActivityResult(Activity.java:3835)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3332)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3378)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.ActivityThread.access$2700(ActivityThread.java:123)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1900)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.os.Looper.loop(Looper.java:123)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at android.app.ActivityThread.main(ActivityThread.java:4370)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at java.lang.reflect.Method.invoke(Method.java:521)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at dalvik.system.NativeStart.main(Native Method)
    12-11 18:12:30.936: E/AndroidRuntime(1009): Caused by: java.lang.UnsatisfiedLinkError: Library lept not found
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at java.lang.Runtime.loadLibrary(Runtime.java:489)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at java.lang.System.loadLibrary(System.java:557)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47)
    12-11 18:12:30.936: E/AndroidRuntime(1009):     ... 15 more
    12-11 18:12:30.946: E/SemcCheckin(1009): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
4

1 回答 1

0

如我所见,您没有在您的 SimpleAndroidOCRActivity 的 onCreate(Bundle) 方法中调用 super.onCreate(savedInstanceState)

于 2012-12-11T19:06:15.150 回答