Skip to content

Commit

Permalink
Upgrade to Mlkit Beta
Browse files Browse the repository at this point in the history
fixes #6
  • Loading branch information
mtotschnig committed Apr 7, 2022
1 parent edc9e35 commit 9eac4aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
mlkit {
dimension "engine"
applicationIdSuffix ".mlkit"
minSdkVersion 19
}
tesseract {
dimension "engine"
Expand Down Expand Up @@ -74,7 +75,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
testImplementation 'junit:junit:4.13.2'
mlkitImplementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.0'
mlkitImplementation 'com.google.mlkit:text-recognition:16.0.0-beta3'
tesseractImplementation 'cz.adaptech:tesseract4android:4.1.1'
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
Expand Down
3 changes: 2 additions & 1 deletion app/src/mlkit/java/org/totschnig/ocr/OcrViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.net.Uri
import androidx.lifecycle.viewModelScope
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -22,7 +23,7 @@ class OcrViewModel(application: Application) : BaseViewModel(application) {
}?.let {
InputImage.fromBitmap(it, getOrientation(uri))
}?.let {
TextRecognition.getClient().process(it)
TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS).process(it)
.addOnSuccessListener { texts ->
result.postValue(Result.success(texts.wrap()))
}
Expand Down

0 comments on commit 9eac4aa

Please sign in to comment.