Is there a way to detect full-sized, horizontal lines (max width) instead of text blocks in images using Google's Text Recognition API? Say, if I wanted to retrieve the total due from a receipt image like this:
... because as of now, the API detects texts in blocks instead in an arbitrary order like this:
... and no, TextBlock's getComponents()
only retrieves the Lines within each TextBlock since TextBlock is at the top of the Text hierarchy (TextBlock contains Line) as mentioned in the docs here. If only this API could start off with Lines instead of TextBlocks for an image bitmap's frame...
I even tried resizing the text blocks' bounding box (rectangle) with hard-coded coordinates to hopefully detect the full line of text, "Chicken Bowl... 7.15", but to no avail as shown below:
val textRecognizer = TextRecognizer.Builder(this).build()
if (textRecognizer.isOperational) {
val imageFrame = Frame.Builder()
.setBitmap(imageBitmap)
.build()
val textBlocks = textRecognizer.detect(imageFrame)
for (i in 0 until textBlocks.size()) {
val textBlock = textBlocks.get(textBlocks.keyAt(i))
textBlock.boundingBox.set(97, 1244, 1235, 1292)
val textValue = textBlock.value
Log.d(LOG_TAG, "textValue: " + textValue)
}
}