Java Code Examples for com.google.android.gms.vision.text.TextBlock#getBoundingBox()
The following examples show how to use
com.google.android.gms.vision.text.TextBlock#getBoundingBox() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OcrGraphic.java From flutter_mobile_vision with MIT License | 6 votes |
/** * Draws the text block annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { TextBlock text = textBlock; if (text == null) { return; } // Draws the bounding box around the TextBlock. RectF rect = new RectF(text.getBoundingBox()); rect = translateRect(rect); canvas.drawRect(rect, rectPaint); // Break the text into multiple lines and draw each one according to its own bounding box. List<? extends Text> textComponents = text.getComponents(); for (Text currentText : textComponents) { float left = translateX(currentText.getBoundingBox().left); float bottom = translateY(currentText.getBoundingBox().bottom); if (showText) { canvas.drawText(currentText.getValue(), left, bottom, textPaint); } } }
Example 2
Source File: OcrGraphic.java From flutter_mobile_vision with MIT License | 5 votes |
/** * @return RectF that represents the graphic's bounding box. */ public RectF getBoundingBox() { TextBlock textBlock = this.textBlock; if (textBlock == null) { return null; } RectF rect = new RectF(textBlock.getBoundingBox()); rect = translateRect(rect); return rect; }
Example 3
Source File: OcrGraphic.java From OCR-Reader with MIT License | 5 votes |
/** * Checks whether a point is within the bounding box of this graphic. * The provided point should be relative to this graphic's containing overlay. * @param x An x parameter in the relative context of the canvas. * @param y A y parameter in the relative context of the canvas. * @return True if the provided point is contained within this graphic's bounding box. */ public boolean contains(float x, float y) { TextBlock text = mText; if (text == null) { return false; } RectF rect = new RectF(text.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return (rect.left < x && rect.right > x && rect.top < y && rect.bottom > y); }
Example 4
Source File: OcrGraphic.java From Moneycim with MIT License | 5 votes |
/** * Checks whether a point is within the bounding box of this graphic. * The provided point should be relative to this graphic's containing overlay. * @param x An x parameter in the relative context of the canvas. * @param y A y parameter in the relative context of the canvas. * @return True if the provided point is contained within this graphic's bounding box. */ public boolean contains(float x, float y) { TextBlock text = mText; if (text == null) { return false; } RectF rect = new RectF(text.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return (rect.left < x && rect.right > x && rect.top < y && rect.bottom > y); }
Example 5
Source File: OcrGraphic.java From Questor with MIT License | 5 votes |
/** * Checks whether a point is within the bounding box of this graphic. * The provided point should be relative to this graphic's containing overlay. * @param x An x parameter in the relative context of the canvas. * @param y A y parameter in the relative context of the canvas. * @return True if the provided point is contained within this graphic's bounding box. */ public boolean contains(float x, float y) { TextBlock text = mText; if (text == null) { return false; } RectF rect = new RectF(text.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return (rect.left < x && rect.right > x && rect.top < y && rect.bottom > y); }
Example 6
Source File: OcrGraphic.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
/** * Checks whether a point is within the bounding box of this graphic. * The provided point should be relative to this graphic's containing overlay. * * @param x An x parameter in the relative context of the canvas. * @param y A y parameter in the relative context of the canvas. * @return True if the provided point is contained within this graphic's bounding box. */ public boolean contains(float x, float y) { TextBlock text = mText; if (text == null) { return false; } RectF rect = new RectF(text.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return (rect.left < x && rect.right > x && rect.top < y && rect.bottom > y); }
Example 7
Source File: OcrGraphic.java From android-vision with Apache License 2.0 | 5 votes |
/** * Checks whether a point is within the bounding box of this graphic. * The provided point should be relative to this graphic's containing overlay. * @param x An x parameter in the relative context of the canvas. * @param y A y parameter in the relative context of the canvas. * @return True if the provided point is contained within this graphic's bounding box. */ public boolean contains(float x, float y) { TextBlock text = mText; if (text == null) { return false; } RectF rect = new RectF(text.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return (rect.left < x && rect.right > x && rect.top < y && rect.bottom > y); }
Example 8
Source File: MyTextBlock.java From flutter_mobile_vision with MIT License | 4 votes |
public MyTextBlock(TextBlock textBlock) { this.language = textBlock.getLanguage(); this.value = textBlock.getValue(); this.boundingBox = textBlock.getBoundingBox(); }