FaceDetectApp { public static void annotateWithFaces(BufferedImage img, List<FaceAnnotation> faces) { for (FaceAnnotation face : faces) { annotateWithFace(img, face); } } FaceDetectApp(Vision vision); static void main(String[] args); static Vision getVisionService(); List<FaceAnnotation> detectFaces(Path path, int maxResults); static void annotateWithFaces(BufferedImage img, List<FaceAnnotation> faces);  }
@Test public void annotateWithFaces_manyFaces_outlinesFaces() throws Exception { ImmutableList<FaceAnnotation> faces = ImmutableList.of( new FaceAnnotation() .setFdBoundingPoly( new BoundingPoly() .setVertices( ImmutableList.of( new Vertex().setX(10).setY(5), new Vertex().setX(20).setY(5), new Vertex().setX(20).setY(25), new Vertex().setX(10).setY(25)))), new FaceAnnotation() .setFdBoundingPoly( new BoundingPoly() .setVertices( ImmutableList.of( new Vertex().setX(60).setY(50), new Vertex().setX(70).setY(60), new Vertex().setX(50).setY(60))))); BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); FaceDetectApp.annotateWithFaces(img, faces); assertWithMessage("img face #1 vertex (10, 5) green channel") .that(img.getRGB(10, 5) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #1 vertex (20, 5) green channel") .that(img.getRGB(20, 5) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #1 vertex (20, 25) green channel") .that(img.getRGB(20, 25) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #1 vertex (10, 25) green channel") .that(img.getRGB(10, 25) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #2 vertex (60, 50) green channel") .that(img.getRGB(60, 50) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #2 vertex (70, 60) green channel") .that(img.getRGB(70, 60) & 0x00ff00) .isEqualTo(0x00ff00); assertWithMessage("img face #2 vertex (50, 60) green channel") .that(img.getRGB(50, 60) & 0x00ff00) .isEqualTo(0x00ff00); }