use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectLandmarksTest.
@Test
public void detectLandmarksTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("landmark.jpg", Type.LANDMARK_DETECTION, false);
List<String> actual = new ArrayList<>();
for (AnnotateImageResponse res : responses) {
for (EntityAnnotation annotation : res.getLandmarkAnnotationsList()) {
actual.add(annotation.getDescription());
}
}
assertThat(actual).contains("Palace of Fine Arts");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectTextTest.
@Test
public void detectTextTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("text.jpg", Type.TEXT_DETECTION, false);
List<String> actual = new ArrayList<>();
for (AnnotateImageResponse res : responses) {
for (EntityAnnotation annotation : res.getTextAnnotationsList()) {
actual.add(annotation.getDescription());
}
}
assertThat(actual).contains("PS4");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectLandmarksGcsTest.
@Test
public void detectLandmarksGcsTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("landmark/pofa.jpg", Type.LANDMARK_DETECTION, true);
List<String> actual = new ArrayList<>();
for (AnnotateImageResponse res : responses) {
for (EntityAnnotation annotation : res.getLandmarkAnnotationsList()) {
actual.add(annotation.getDescription());
}
}
assertThat(actual).contains("Palace of Fine Arts");
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method addResponsesToList.
private List<String> addResponsesToList(AnnotateImageRequest request) {
List<String> actual = new ArrayList<>();
BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(ImmutableList.of(request));
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.getError().getCode() == 14) {
throw new StatusRuntimeException(Status.UNAVAILABLE);
}
for (EntityAnnotation annotation : res.getLandmarkAnnotationsList()) {
actual.add(annotation.getDescription());
}
}
return actual;
}
use of com.google.cloud.vision.v1p3beta1.AnnotateImageResponse in project java-vision by googleapis.
the class ITSystemTest method detectPropertiesTest.
@Test
public void detectPropertiesTest() throws IOException {
List<AnnotateImageResponse> responses = getResponsesList("landmark.jpg", Type.IMAGE_PROPERTIES, false);
List<Float> actual = new ArrayList<>();
for (AnnotateImageResponse res : responses) {
DominantColorsAnnotation colors = res.getImagePropertiesAnnotation().getDominantColors();
for (ColorInfo color : colors.getColorsList()) {
actual.add(color.getPixelFraction());
}
}
assertThat(actual).contains((float) 0.14140345);
}
Aggregations