Skip to content

Commit

Permalink
use compileOnly in mlkit
Browse files Browse the repository at this point in the history
  • Loading branch information
xanscale committed Nov 16, 2022
1 parent f5e67bf commit 8c56e46
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions mlkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ dependencies {
api("androidx.camera:camera-lifecycle:1.1.0")
api("androidx.camera:camera-view:1.1.0")

api("com.google.mlkit:barcode-scanning:17.0.2") // 3.2 MB
api("com.google.mlkit:text-recognition:16.0.0-beta6") // 4 MB
api("com.google.mlkit:image-labeling-custom:17.0.1") // 3.8 MB
compileOnly("com.google.mlkit:barcode-scanning:17.0.2") // 3.2 MB
compileOnly("com.google.mlkit:text-recognition:16.0.0-beta6") // 4 MB
compileOnly("com.google.mlkit:image-labeling-custom:17.0.1") // 3.8 MB
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import com.google.mlkit.vision.barcode.common.Barcode
import com.google.mlkit.vision.common.InputImage
import it.localhostsoftware.mlkit.vision.AbstractImageAnalyzer

/**
To use this class add this dependency
implementation("com.google.mlkit:barcode-scanning:17.0.2")
*/
class BarcodeScanner : AbstractImageAnalyzer<List<Barcode>>() {
override fun process(image: Image, rotationDegrees: Int) =
BarcodeScanning.getClient().process(InputImage.fromMediaImage(image, rotationDegrees))
BarcodeScanning.getClient().process(InputImage.fromMediaImage(image, rotationDegrees))
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import com.google.mlkit.vision.label.ImageLabelerOptionsBase
import com.google.mlkit.vision.label.ImageLabeling
import it.localhostsoftware.mlkit.vision.AbstractImageAnalyzer

/**
To use this class add this dependency
implementation("com.google.mlkit:image-labeling-custom:17.0.1")
*/
class ImageLabeler(private val options: ImageLabelerOptionsBase) : AbstractImageAnalyzer<List<ImageLabel>>() {
override fun process(image: Image, rotationDegrees: Int) =
ImageLabeling.getClient(options).process(InputImage.fromMediaImage(image, rotationDegrees))
ImageLabeling.getClient(options).process(InputImage.fromMediaImage(image, rotationDegrees))
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
import it.localhostsoftware.mlkit.vision.AbstractImageAnalyzer

/**
To use this class add this dependency
implementation("com.google.mlkit:text-recognition:16.0.0-beta6")
*/
class TextRecognizer : AbstractImageAnalyzer<Text>() {
override fun process(image: Image, rotationDegrees: Int) =
TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS).process(InputImage.fromMediaImage(image, rotationDegrees))
TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS).process(InputImage.fromMediaImage(image, rotationDegrees))
}

0 comments on commit 8c56e46

Please sign in to comment.