use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectLabelsTest.
@Test
public void detectLabelsTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("wakeupcat.jpg", Type.LABEL_DETECTION, false);
List<String> actual = new ArrayList<>();
for (AnnotateImageResponse res : responses) {
for (EntityAnnotation annotation : res.getLabelAnnotationsList()) {
actual.add(annotation.getDescription());
}
}
assertThat(actual).contains("Whiskers");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectFacesGcsTest.
@Test
public void detectFacesGcsTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("face/face_no_surprise.jpg", Type.FACE_DETECTION, true);
for (AnnotateImageResponse res : responses) {
for (FaceAnnotation annotation : res.getFaceAnnotationsList()) {
assertEquals(Likelihood.LIKELY, annotation.getAngerLikelihood());
assertEquals(Likelihood.VERY_UNLIKELY, annotation.getJoyLikelihood());
assertEquals(Likelihood.LIKELY, annotation.getSurpriseLikelihood());
}
}
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectWebEntitiesIncludeGeoResultsGcsTest.
@Test
public void detectWebEntitiesIncludeGeoResultsGcsTest() {
ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(SAMPLE_BUCKET + "landmark/pofa.jpg").build();
Image img = Image.newBuilder().setSource(imgSource).build();
Feature feat = Feature.newBuilder().setType(Type.WEB_DETECTION).setMaxResults(MAX_RESULTS).build();
WebDetectionParams webDetectionParams = WebDetectionParams.newBuilder().setIncludeGeoResults(true).build();
ImageContext imageContext = ImageContext.newBuilder().setWebDetectionParams(webDetectionParams).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImageContext(imageContext).setImage(img).build();
BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(ImmutableList.of(request));
List<AnnotateImageResponse> responses = response.getResponsesList();
List<String> actual = new ArrayList<>();
System.out.println("WebEntitiesGeo SIZE");
System.out.println(actual.size());
for (AnnotateImageResponse imgResponse : responses) {
for (WebDetection.WebEntity entity : imgResponse.getWebDetection().getWebEntitiesList()) {
actual.add(entity.getDescription());
}
}
assertThat(actual).contains("The Palace Of Fine Arts");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectDocumentTextTest.
@Test
public void detectDocumentTextTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("text.jpg", Type.DOCUMENT_TEXT_DETECTION, false);
String actual = "";
for (AnnotateImageResponse imgResponse : responses) {
TextAnnotation annotation = imgResponse.getFullTextAnnotation();
actual = annotation.getText();
}
assertThat(actual).contains("After preparation is complete");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse 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%");
}
Aggregations