Search in sources :

Example 36 with EntityAnnotation

use of com.google.cloud.vision.v1.EntityAnnotation in project java-vision by googleapis.

the class ITSystemTest method detectTextGcsTest.

@Test
public void detectTextGcsTest() throws IOException {
    List<AnnotateImageResponse> responses = getResponsesList("text/screen.jpg", Type.TEXT_DETECTION, true);
    List<String> actual = new ArrayList<>();
    for (AnnotateImageResponse res : responses) {
        for (EntityAnnotation annotation : res.getTextAnnotationsList()) {
            actual.add(annotation.getDescription());
        }
    }
    String joinedActual = String.join(" ", actual);
    assertThat(joinedActual).contains("37%");
}
Also used : AnnotateImageResponse(com.google.cloud.vision.v1.AnnotateImageResponse) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) EntityAnnotation(com.google.cloud.vision.v1.EntityAnnotation) Test(org.junit.Test)

Aggregations

EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)36 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)34 ArrayList (java.util.ArrayList)30 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)25 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)24 Feature (com.google.cloud.vision.v1.Feature)24 Image (com.google.cloud.vision.v1.Image)24 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)23 ByteString (com.google.protobuf.ByteString)19 ImageSource (com.google.cloud.vision.v1.ImageSource)11 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)9 FileInputStream (java.io.FileInputStream)8 Test (org.junit.Test)7 LocationInfo (com.google.cloud.vision.v1.LocationInfo)6 ModelAndView (org.springframework.web.servlet.ModelAndView)5 Path (java.nio.file.Path)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3