Can't do OCR with tess-two on Android Studio

all. I am trying to include the tess-two OCR library in an android project but am having some problems.

[What am I trying to do]

Do OCR with tess-two ( tess-two github link ) on Android Studio.
(I would like to develop some OCR applications)

[Where am I stuck]

Application forcibly quits when launched from Android Studio

[What I've done]

  • Downloaded tess-two
  • built it
ndk-build
android update project --path C:\...\tess-two  
ant release

      

  1. Made a new project "test" on Android Studio (API 16, Blank Activity).
  2. Place .jar classes for testing \ app \ libs
  3. Added .jar classes as a library for the application
  4. Place directories with .so files (armeabi-v7a, mips, x86) to check \ app \ src \ main \ jniLibs
  5. Place the following code in MainActivity.java
import com.googlecode.tesseract.android.TessBaseAPI;

public void testOCR(){
    String storagePath = Environment.getExternalStorageDirectory().getPath();
    Bitmap bitmap = null;
    ImageView img = (ImageView) findViewById(R.id.imageView);

    // Read an image
    File file = new File("storage/sdcard1/tess-two/ocr_sample.jpg");
    if (file.exists()) {
        bitmap = BitmapFactory.decodeFile(file.getPath());
        bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        img.setImageBitmap(bitmap);
    }else{
        Log.d("tess-two","File not found.");
        return;
    }

    // Init modules
    TessBaseAPI tessOCRAPI = new TessBaseAPI();
    tessOCRAPI.init(storagePath+"/tess-two/", "eng");

    // Set Image
    tessOCRAPI.setImage(bitmap);
    String recognizedText = tessOCRAPI.getUTF8Text();
    Log.d("tess-two",recognizedText);

    // Close OCR API
    tessOCRAPI.end();

}

      

  1. An application has been sent to the smartphone.

Then the application stopped. I debugged it and the program seemed to stop at TessBaseAPI tessOCRAPI = new TessBaseAPI();

. While debugging in debug windows the following suggestion appeared.

com.android.internal.os.ZygoteInit$MethodAndArgsCaller

Restoring and cleaning up the project and searching on google did not give any good results.

Can anyone suggest a way to solve this problem? Thank you in advance!

[My surrounding]

  • Windows 8.1 Pro 64 bit
  • Android studio 1.3
  • Xperia SO-04F

[Link]

+3


source to share





All Articles