Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.priyankvex:Easy-Ocr-Scanner-Android:'
}
dependencies {
implementation("com.github.priyankvex:Easy-Ocr-Scanner-Android:")
}
<dependency>
<groupId>com.github.priyankvex</groupId>
<artifactId>Easy-Ocr-Scanner-Android</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.priyankvex" % "Easy-Ocr-Scanner-Android" % ""
:dependencies [[com.github.priyankvex/Easy-Ocr-Scanner-Android ""]]
# Easy-Ocr-Scanner-Android Easiest and simplest OCR scanner library for Android built using Tesseract and Leptonica.
<h2>About</h2>Easy OCR Library is made by having only one goal in mind: Making OCR as easy as possible. (Don't you just love when things actually mean what they show).
Easy OCR uses a fork of tesseract, <a href="https://github.com/rmtheis/tess-two">Tess Two</a>. But deals with all the pain of setting up and building the library using NDK.
<h2>Usage</h2>Using EasyOcrLibrary is as simple as it can get.
<b>Step 0</b>
Copy your trained data file into the assets/tessdata folder. You can download the required .traineddata file from <a href="https://code.google.com/p/tesseract-ocr/downloads/list">here</a>.
<b>Step 1</b>
NOTE : "eng" is the name of the traineddata file as here we are using eng.traineddata .
// initialize EasyOcrScanner instance.
mEasyOcrScanner = new EasyOcrScanner(MainActivity.this, "EasyOcrScanner",
Config.REQUEST_CODE_CAPTURE_IMAGE, "eng");
<b>Step 2</b>
Implement java EasyOcrScannerListener
.
implements EasyOcrScannerListener
Then define the callbacks.
<b>Step 3</b>
Start the scan!
mEasyOcrScanner.takePicture();
<b>Step 4</b>
Call java onImageTaken()
in java onActivityResult()
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Call onImageTaken() in onActivityResult.
if (resultCode == RESULT_OK && requestCode == Config.REQUEST_CODE_CAPTURE_IMAGE){
mEasyOcrScanner.onImageTaken();
}
}
<b>And you are done!</b>
Get the scaned text in the callback java onOcrScanFinished()
.
<em>For more info check the sample app in the app module.</em>