Search in sources :

Example 1 with Point

use of com.amazonaws.services.rekognition.model.Point in project amplify-android by aws-amplify.

the class RekognitionResultTransformers method fromPoints.

/**
 * Converts geometric polygon from Amazon Rekognition into
 * Amplify-compatible polygon object.
 * @param polygon the polygon object by Amazon Rekognition
 * @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);
}
Also used : PointF(android.graphics.PointF) ArrayList(java.util.ArrayList) Point(com.amazonaws.services.rekognition.model.Point) Nullable(androidx.annotation.Nullable)

Example 2 with Point

use of com.amazonaws.services.rekognition.model.Point in project amplify-android by aws-amplify.

the class RekognitionResultTransformersTest 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 = RekognitionResultTransformers.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);
}
Also used : PointF(android.graphics.PointF) ArrayList(java.util.ArrayList) Point(com.amazonaws.services.rekognition.model.Point) Polygon(com.amplifyframework.predictions.models.Polygon) Test(org.junit.Test)

Example 3 with Point

use of com.amazonaws.services.rekognition.model.Point in project amplify-android by aws-amplify.

the class RekognitionResultTransformersTest 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;
}
Also used : ArrayList(java.util.ArrayList) Point(com.amazonaws.services.rekognition.model.Point) Point(com.amazonaws.services.rekognition.model.Point)

Aggregations

Point (com.amazonaws.services.rekognition.model.Point)3 ArrayList (java.util.ArrayList)3 PointF (android.graphics.PointF)2 Nullable (androidx.annotation.Nullable)1 Polygon (com.amplifyframework.predictions.models.Polygon)1 Test (org.junit.Test)1