A library to add text recognition capability to your app built with Jetpack Compose, it internally uses ML Kit text recognition.
To get started with TextRecognizer just add the maven url and the TextRecognition dependency
build.gradle (Project level)
allprojects {
repositories {
...
//Add this url
maven { url 'https://jitpack.io' }
}
}
If you are using Android Studio Arctic Fox and above where you don't have allProjects in build.gradle then add following maven url in settings.gradle like below
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
//Add this url
maven { url 'https://jitpack.io' }
jcenter() // Warning: this repository is going to shut down soon
}
}
Once you have added the maven url now add the TextRecognition dependency in the build.gradle (module level)
implementation 'com.github.raipankaj:TextRecognition:0.1.1'
Congratulations, you have successfully added the dependency. Now to get started with TextRecognizer add the following code snippet
TextRecognizer(
onSuccess = {
//Action based on Text
},
onException = {
//Action based on exception
}
)
Following is a full fledged working sample code
var text by remember { mutableStateOf("") }
Surface(color = MaterialTheme.colors.background) {
TextRecognizer(
onSuccess = {
text = it.text
},
onException = { }
)
}
Also do not forget to request for camera permission.
Note: If you like this library, then please hit the star button! 😃