Skip to content

Instantly share code, notes, and snippets.

@ibrahim4851
Created May 4, 2021 22:48
Show Gist options
  • Save ibrahim4851/ebc04691b9e5296899f3adb404125c85 to your computer and use it in GitHub Desktop.
Save ibrahim4851/ebc04691b9e5296899f3adb404125c85 to your computer and use it in GitHub Desktop.
DetectImageMlkit
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