Tesseract OCR integrated Android studio for OCR recognition introduction
Tesseract OCR Google Open source OCR recognition engine, supporting multi-country text including Simplified Chinese and traditional. The latest version is 3.x. Can be installed on the machine through the installation program and then run the program through the command line to identify the text in a variety of pictures, but also provides two development packages, support two times development including C, C + + language. It can also be ported to the Android platform to implement the OCR recognition app for mobile applications.
Download
Using Tesseract OCR on the Android platform first to download the TESS2 project, it was compiled specifically for the Android platform, as follows-Https://github.com/rmtheis/tess-two. After the download is uncompressed, you will see the following directory structure:
Then open Android Studio to create a new project app, select Import module and select Import Tess-two folder in red Circle, after import you will see the following:
The project must be in support of the NDK, so specify the path to the NDK in project structure. The reason is that Tess-two is an NDK project and cannot be compiled without NDK support.
You may also encounter errors that are not Android-maven, add the following script to the top of Build.gradle:
Buildscript {
repositories {
Jcenter ()
}
dependencies {
Classpath ' com.android.tools.build:gradle:2.1.2 '
Classpath ' org.codehaus.groovy:groovy-backports-compat23:2.3.5 '
Classpath ' com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0 '
Classpath ' com.github.dcendents:android-maven-gradle-plugin:1.5 '
}
}
If all goes well, you will finish importing and compiling, see the directory structure of the successful import, the second one shows. Here's how to add the initialization code to your activity as follows:
private void Inittessbasedata () {
mtess = new Tessbaseapi ();
String datapath = environment.getexternalstoragedirectory () + "/tesseract/";
String language = "num";
String language = "eng";
File dir = new file (datapath + "tessdata/");
if (!dir.exists ())
Dir.mkdirs ();
Mtess.init (DataPath, language);
}
Then the Click event Response recognition action by listening for the "identify" button is as follows:
Https://github.com/tesseract-ocr/tessdata
Also, don't forget to add Tess-two as a dependency to the app.
Tesseract OCR integrated Android studio for OCR recognition