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);
}
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);
}
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;
}