When using the getBoundingBox method on an element extracted with the Firebase-MLKit library it gives you an output that looks like this
Rect(0, 0 - 13, 33)
what does each individual number represent?
relevant code
private void processTextRecognitionResults(FirebaseVisionText receipt) {
List<FirebaseVisionText.TextBlock> blocks = receipt.getTextBlocks();
List<FirebaseVisionText.Element> elements;
if (blocks.size() == 0) {
Toast.makeText(this, "No text found", Toast.LENGTH_SHORT).show();
return;
}
for (int runThroBlocks = 0; runThroBlocks < blocks.size(); runThroBlocks++) {
List<FirebaseVisionText.Line> lines = blocks.get(runThroBlocks).getLines();
for (int runThroLines = 0; runThroLines < lines.size(); runThroLines++) {
elements = lines.get(runThroLines).getElements();
for (int runThroElemnts = 0; runThroElemnts < elements.size(); runThroElemnts++) {
System.out.println("-----BOX-----");
System.out.println(elements.get(runThroElemnts).getText());
//This line prints the output given above
System.out.println(elements.get(runThroElemnts).getBoundingBox());
System.out.println("-----BOX-----");
}
}
}
Sorry if the question is not written well. Its my first time writing one Thank you for the help
The getBoundingBox()
function returns a android.graphics.Rect
object.
The toString
implementation that is invoked when you print elements.get(runThroElemnts).getText()
prints them as left
, top
, right
, and bottom
.
public String toString() { StringBuilder sb = new StringBuilder(32); sb.append("Rect("); sb.append(left); sb.append(", "); sb.append(top); sb.append(" - "); sb.append(right); sb.append(", "); sb.append(bottom); sb.append(")"); return sb.toString(); }