Created
May 4, 2021 22:48
-
-
Save ibrahim4851/ebc04691b9e5296899f3adb404125c85 to your computer and use it in GitHub Desktop.
DetectImageMlkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun detectImage() { | |
val recognizer = TextRecognition.getClient() | |
bitmap?.let { | |
val image = InputImage.fromBitmap(it, 0) | |
recognizer.process(image) | |
.addOnSuccessListener { visionText -> | |
Toast.makeText(this, visionText.text, Toast.LENGTH_SHORT).show() | |
} | |
.addOnFailureListener { e -> | |
Toast.makeText(this, "Error: " + e.message, Toast.LENGTH_SHORT).show() | |
} | |
} | |
if (bitmap == null) Toast.makeText(this, "Please select image!", Toast.LENGTH_SHORT) | |
.show() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment