use of com.google.cloud.vision.v1p4beta1.ImageSource in project java-vision by googleapis.
the class ITSystemTest method detectLandmarksUrlTest.
@Test
public void detectLandmarksUrlTest() throws Exception {
ImageSource imgSource = ImageSource.newBuilder().setImageUri(SAMPLE_URI + "landmark/pofa.jpg").build();
Image img = Image.newBuilder().setSource(imgSource).build();
Feature feat = Feature.newBuilder().setType(Type.LANDMARK_DETECTION).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
List<String> actual = new ArrayList<>();
int tryCount = 0;
int maxTries = 3;
while (tryCount < maxTries) {
try {
actual = addResponsesToList(request);
break;
} catch (StatusRuntimeException ex) {
tryCount++;
System.out.println("retrying due to request throttling or DOS prevention...");
TimeUnit.SECONDS.sleep(30);
}
}
assertThat(actual).contains("Palace of Fine Arts");
}
Aggregations