diff --git a/app/build.gradle b/app/build.gradle index c3c6ddf..1c6dcf2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,6 +30,7 @@ android { mlkit { dimension "engine" applicationIdSuffix ".mlkit" + minSdkVersion 19 } tesseract { dimension "engine" @@ -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" diff --git a/app/src/mlkit/java/org/totschnig/ocr/OcrViewModel.kt b/app/src/mlkit/java/org/totschnig/ocr/OcrViewModel.kt index de97d5a..babe05c 100644 --- a/app/src/mlkit/java/org/totschnig/ocr/OcrViewModel.kt +++ b/app/src/mlkit/java/org/totschnig/ocr/OcrViewModel.kt @@ -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 @@ -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())) }