Created
October 15, 2018 07:14
-
-
Save tsh-code/e35b299bf2f629c1ff72aff90b1d4add 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 blocks = text.blocks | |
val blocksRect = blocks.mapNotNull { it.boundingBox } | |
val lines = blocks.flatMap { it.lines } | |
val linesRect = lines.mapNotNull { it.boundingBox } | |
val elements = lines.flatMap { it.elements } | |
val elementsRect = elements.mapNotNull { it.boundingBox } | |
// copy bitmap and make it mutable if necessary (optional step) | |
// depends on how do you get your bitmap | |
val mutableBitmap = inputBitmap.copy(inputBitmap.config, true) | |
// draw all bounding boxes on bitmap | |
with(Canvas(mutableBitmap)) { | |
blocksRect.forEach { drawRect(it, blocksPaint) } | |
linesRect.forEach { drawRect(it, linesPaint) } | |
elementsRect.forEach { drawRect(it, elementsPaint) } | |
} | |
imageView.setImageBitmap(mutableBitmap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment