Created
April 19, 2019 07:22
-
-
Save bapspatil/c72cf083a1a8d8aa1fafaea60fc2ebff to your computer and use it in GitHub Desktop.
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
val result = recognizer.processImage(image) | |
.addOnSuccessListener { result -> | |
// Task completed successfully | |
// Text recognition results | |
val resultText = result.text | |
// `FirebaseVisionText` is made of `TextBlock`s... | |
for (block in result.textBlocks) { | |
// ...and each `TextBlock` has | |
// text, confidence level, list of recognized languages and corner points and frame in which the text was detected... | |
val blockText = block.text | |
val blockConfidence = block.confidence | |
val blockLanguages = block.recognizedLanguages | |
val blockCornerPoints = block.cornerPoints | |
val blockFrame = block.boundingBox | |
// ...and each `TextBlock` is made of `Line`s... | |
for (line in block.lines) { | |
// ...which again have text, confidence level, list of recognized languages, corner points and the frame in which the text was detected... | |
val lineText = line.text | |
val lineConfidence = line.confidence | |
val lineLanguages = line.recognizedLanguages | |
val lineCornerPoints = line.cornerPoints | |
val lineFrame = line.boundingBox | |
// ... and each `Line` is further made of `Element`s... | |
for (element in line.elements) { | |
// ...and each `Element` has | |
// text, confidence level, list of recognized languages, corner points and the frame in which the text was detected. | |
val elementText = element.text | |
val elementConfidence = element.confidence | |
val elementLanguages = element.recognizedLanguages | |
val elementCornerPoints = element.cornerPoints | |
val elementFrame = element.boundingBox | |
} | |
} | |
} | |
} | |
.addOnFailureListener { | |
// Task failed with an exception | |
longToast("Failed to recognize text!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment