About the Tesseract identification tool there is a version of Google provides tesseract-android-tools, but there is also a tesseract-two is very useful, here we use Tesseract-two. Tesseract is implemented in C + + and requires encapsulation of Java APIs for Android platform calls. So before using Tesseract-two, download the android-ndk, download the NDK, unzip it to a folder on your computer, and configure the NDK referenced by Eclipse.
Unzip the downloaded NDK, because to use ndk-build this command and for the sake of convenience, without CD to CD to the ~ Configure the environment variables, in path to append the NDK extracted directory.
Tesseract-two is actually a git branch of tesseract tools for Android, which is chosen because it is simple to operate and integrates with Leptonica, a graphical processing tool. So you can download it on the Gitbub.
Https://github.com/rmtheis/tess-two
You can also use Git to get the resources you want.
Http://git-scm.com/download/win
The resources are ready, and then we compile with the NDK (Cmd entered under Windows) and enter the following command (compile time will be a bit longer)
CD tess-two ndk-build android update Project-t 1--path. Ant release cd . CD eyes-two ndk-build android update Project-t 1--path. Ant Release
The Android project in Eclipse imports the compiled library, a total of three items, Tess-two,tess-two-test and Eyes-two. Among them, Tess-two and Eyes-two are Android Lib projects that are referenced by other projects.
The Java code is then written, but errors are found. Due to the lack of language packs in the/mnt/sdcard/directory, the following two language packs will be placed below the root directory of the SD card (tessdata).
ImportCom.googlecode.tesseract.android.TessBaseAPI;Importandroid.app.Activity;ImportAndroid.graphics.Bitmap;Importandroid.graphics.BitmapFactory;ImportAndroid.os.Bundle;ImportAndroid.util.Log; Public classMainactivityextendsActivity {Private Static FinalString Tessbase_path = "/mnt/sdcard/"; Private Static FinalString default_language = "Eng"; Private Static FinalString chinese_language = "Chi_sim"; Private Static FinalString TAG = "Tesseract"; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Tessbaseapi Baseapi=NewTessbaseapi (); Baseapi.init (Tessbase_path, default_language); Baseapi.setpagesegmode (Tessbaseapi.psm_auto); //get a picture from a resourceBitmap Bitmap = Bitmapfactory.decoderesource (mainactivity. This. Getresources (), R.DRAWABLE.OCR); Baseapi.setimage (bitmap); FinalString Outputtext =Baseapi.getutf8text (); LOG.I (TAG,"Recognition Result:" +outputtext); Baseapi.end (); } }
Original:
Recognition results:
Use of tesseract for Android text recognition