Android OCR强制关闭

时间:2012-12-11 18:47:49

标签: android ocr

我正在关注教程here

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

然而,当我点击它时,我得到一个“强制关闭错误”。

当我从电脑上拔下手机时,我已经拍摄了照片,但当我去拍摄时,我发现力量接近错误。

我正在使用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

1 个答案:

答案 0 :(得分:0)

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