use of com.amazonaws.services.textract.model.Point in project aws-doc-sdk-examples by awsdocs.
the class AnalyzeDocument method ShowPolygon.
// Shows polygon at supplied location
private void ShowPolygon(int imageHeight, int imageWidth, List<Point> points, Graphics2D g2d) {
g2d.setColor(new Color(0, 0, 0));
Polygon polygon = new Polygon();
// Construct polygon and display
for (Point point : points) {
polygon.addPoint((Math.round(point.getX() * imageWidth)), Math.round(point.getY() * imageHeight));
}
g2d.drawPolygon(polygon);
}
use of com.amazonaws.services.textract.model.Point in project aws-doc-sdk-examples by awsdocs.
the class DocumentText method ShowPolygon.
// Shows polygon at supplied location
private void ShowPolygon(int imageHeight, int imageWidth, List<Point> points, Graphics2D g2d) {
g2d.setColor(new Color(0, 0, 0));
Polygon polygon = new Polygon();
// Construct polygon and display
for (Point point : points) {
polygon.addPoint((Math.round(point.getX() * imageWidth)), Math.round(point.getY() * imageHeight));
}
g2d.drawPolygon(polygon);
}
use of com.amazonaws.services.textract.model.Point in project amplify-android by aws-amplify.
the class TextractResultTransformersTest method randomPolygon.
private List<Point> randomPolygon() {
final int minPoints = 3;
List<Point> points = new ArrayList<>();
for (int i = 0; i < minPoints; i++) {
points.add(new Point().withX(random.nextFloat()).withY(random.nextFloat()));
}
return points;
}
use of com.amazonaws.services.textract.model.Point in project amplify-android by aws-amplify.
the class TextractResultTransformersTest method testPolygonConversion.
/**
* Tests that the polygonal boundary from Textract in the form
* of list of points is converted to an Amplify shape for polygons.
*/
@Test
public void testPolygonConversion() {
List<Point> randomPolygon = randomPolygon();
Polygon polygon = TextractResultTransformers.fromPoints(randomPolygon);
List<PointF> actualPoints = polygon.getPoints();
List<PointF> expectedPoints = new ArrayList<>();
for (Point point : randomPolygon) {
expectedPoints.add(new PointF(point.getX(), point.getY()));
}
assertEquals(expectedPoints, actualPoints);
}
use of com.amazonaws.services.textract.model.Point in project amplify-android by aws-amplify.
the class TextractResultTransformers method fromPoints.
/**
* Converts geometric polygon from Amazon Textract into
* Amplify-compatible polygon object.
* @param polygon the polygon object by Amazon Textract
* @return the polygon object representing vertices
*/
@Nullable
public static Polygon fromPoints(@Nullable List<Point> polygon) {
if (Empty.check(polygon)) {
return null;
}
List<PointF> points = new ArrayList<>();
for (Point point : polygon) {
PointF androidPoint = new PointF(point.getX(), point.getY());
points.add(androidPoint);
}
return Polygon.fromPoints(points);
}