Skip to content

Commit c8cc69f

Browse files
dpebotlesv
authored andcommitted
Auto-update dependencies. (GoogleCloudPlatform#908)
* Auto-update dependencies. * Updated Cloud Vision API Client Library references.
1 parent c0b17fb commit c8cc69f

File tree

20 files changed

+127
-124
lines changed

20 files changed

+127
-124
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
[![ghit.me](https://ghit.me/badge.svg?repo=GoogleCloudPlatform/java-docs-samples)](https://ghit.me/repo/GoogleCloudPlatform/java-docs-samples)
55
[![Coverage Status](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples/branch/master/graph/badge.svg)](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples)
66

7+
8+
While this library is still supported, we suggest trying the newer [Cloud Client Library](https://developers.google.com/api-client-library/java/apis/vision/v1) for Google Cloud Vision, especially for new projects. For more information, please see the notice on the [API Client Library Page](https://developers.google.com/api-client-library/java/apis/vision/v1).
9+
710
This is a repository that contains java code snippets on [Cloud Platform Documentation](https://cloud.google.com/docs/).
811

912
The repo is organized as follows:

appengine-java8/gaeinfo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Copyright 2017 Google Inc.
6565
<dependency>
6666
<groupId>org.thymeleaf</groupId>
6767
<artifactId>thymeleaf</artifactId>
68-
<version>3.0.8.RELEASE</version>
68+
<version>3.0.9.RELEASE</version>
6969
</dependency>
7070

7171
</dependencies>

appengine-java8/metadata/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Copyright 2017 Google Inc.
6060
<dependency>
6161
<groupId>org.thymeleaf</groupId>
6262
<artifactId>thymeleaf</artifactId>
63-
<version>3.0.8.RELEASE</version>
63+
<version>3.0.9.RELEASE</version>
6464
</dependency>
6565

6666
</dependencies>

appengine/sockets/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
6060
<groupId>org.jsoup</groupId>
6161
<artifactId>jsoup</artifactId>
62-
<version>1.10.3</version>
62+
<version>1.11.1</version>
6363
</dependency>
6464
</dependencies>
6565

compute/signed-metadata/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.auth0</groupId>
3232
<artifactId>java-jwt</artifactId>
33-
<version>3.2.0</version>
33+
<version>3.3.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>com.google.code.gson</groupId>

flexible/gaeinfo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Copyright 2017 Google Inc.
6565
<dependency>
6666
<groupId>org.thymeleaf</groupId>
6767
<artifactId>thymeleaf</artifactId>
68-
<version>3.0.8.RELEASE</version>
68+
<version>3.0.9.RELEASE</version>
6969
</dependency>
7070

7171
</dependencies>

vision/face-detection/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>com.google.apis</groupId>
4141
<artifactId>google-api-services-vision</artifactId>
42-
<version>v1-rev364-1.23.0</version>
42+
<version>v1-rev365-1.23.0</version>
4343
</dependency>
4444
<dependency>
4545
<groupId>com.google.api-client</groupId>

vision/face-detection/src/main/java/com/google/cloud/vision/samples/facedetect/FaceDetectApp.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
import com.google.api.client.json.jackson2.JacksonFactory;
2424
import com.google.api.services.vision.v1.Vision;
2525
import com.google.api.services.vision.v1.VisionScopes;
26-
import com.google.api.services.vision.v1.model.AnnotateImageRequest;
27-
import com.google.api.services.vision.v1.model.AnnotateImageResponse;
28-
import com.google.api.services.vision.v1.model.BatchAnnotateImagesRequest;
29-
import com.google.api.services.vision.v1.model.BatchAnnotateImagesResponse;
30-
import com.google.api.services.vision.v1.model.FaceAnnotation;
31-
import com.google.api.services.vision.v1.model.Feature;
32-
import com.google.api.services.vision.v1.model.Image;
33-
import com.google.api.services.vision.v1.model.Vertex;
26+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1AnnotateImageRequest;
27+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1AnnotateImageResponse;
28+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1BatchAnnotateImagesRequest;
29+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1BatchAnnotateImagesResponse;
30+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1FaceAnnotation;
31+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1Feature;
32+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1Image;
33+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1Vertex;
3434
import com.google.common.collect.ImmutableList;
3535

3636
import java.awt.BasicStroke;
@@ -81,7 +81,7 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept
8181
}
8282

8383
FaceDetectApp app = new FaceDetectApp(getVisionService());
84-
List<FaceAnnotation> faces = app.detectFaces(inputPath, MAX_RESULTS);
84+
List<GoogleCloudVisionV1FaceAnnotation> faces = app.detectFaces(inputPath, MAX_RESULTS);
8585
System.out.printf("Found %d face%s\n", faces.size(), faces.size() == 1 ? "" : "s");
8686
System.out.printf("Writing to file %s\n", outputPath);
8787
app.writeWithFaces(inputPath, outputPath, faces);
@@ -115,25 +115,25 @@ public FaceDetectApp(Vision vision) {
115115
/**
116116
* Gets up to {@code maxResults} faces for an image stored at {@code path}.
117117
*/
118-
public List<FaceAnnotation> detectFaces(Path path, int maxResults) throws IOException {
118+
public List<GoogleCloudVisionV1FaceAnnotation> detectFaces(Path path, int maxResults) throws IOException {
119119
byte[] data = Files.readAllBytes(path);
120120

121-
AnnotateImageRequest request =
122-
new AnnotateImageRequest()
123-
.setImage(new Image().encodeContent(data))
121+
GoogleCloudVisionV1AnnotateImageRequest request =
122+
new GoogleCloudVisionV1AnnotateImageRequest()
123+
.setImage(new GoogleCloudVisionV1Image().encodeContent(data))
124124
.setFeatures(ImmutableList.of(
125-
new Feature()
125+
new GoogleCloudVisionV1Feature()
126126
.setType("FACE_DETECTION")
127127
.setMaxResults(maxResults)));
128128
Vision.Images.Annotate annotate =
129129
vision.images()
130-
.annotate(new BatchAnnotateImagesRequest().setRequests(ImmutableList.of(request)));
130+
.annotate(new GoogleCloudVisionV1BatchAnnotateImagesRequest().setRequests(ImmutableList.of(request)));
131131
// Due to a bug: requests to Vision API containing large images fail when GZipped.
132132
annotate.setDisableGZipContent(true);
133133

134-
BatchAnnotateImagesResponse batchResponse = annotate.execute();
134+
GoogleCloudVisionV1BatchAnnotateImagesResponse batchResponse = annotate.execute();
135135
assert batchResponse.getResponses().size() == 1;
136-
AnnotateImageResponse response = batchResponse.getResponses().get(0);
136+
GoogleCloudVisionV1AnnotateImageResponse response = batchResponse.getResponses().get(0);
137137
if (response.getFaceAnnotations() == null) {
138138
throw new IOException(
139139
response.getError() != null
@@ -148,7 +148,7 @@ public List<FaceAnnotation> detectFaces(Path path, int maxResults) throws IOExce
148148
/**
149149
* Reads image {@code inputPath} and writes {@code outputPath} with {@code faces} outlined.
150150
*/
151-
private static void writeWithFaces(Path inputPath, Path outputPath, List<FaceAnnotation> faces)
151+
private static void writeWithFaces(Path inputPath, Path outputPath, List<GoogleCloudVisionV1FaceAnnotation> faces)
152152
throws IOException {
153153
BufferedImage img = ImageIO.read(inputPath.toFile());
154154
annotateWithFaces(img, faces);
@@ -158,19 +158,19 @@ private static void writeWithFaces(Path inputPath, Path outputPath, List<FaceAnn
158158
/**
159159
* Annotates an image {@code img} with a polygon around each face in {@code faces}.
160160
*/
161-
public static void annotateWithFaces(BufferedImage img, List<FaceAnnotation> faces) {
162-
for (FaceAnnotation face : faces) {
161+
public static void annotateWithFaces(BufferedImage img, List<GoogleCloudVisionV1FaceAnnotation> faces) {
162+
for (GoogleCloudVisionV1FaceAnnotation face : faces) {
163163
annotateWithFace(img, face);
164164
}
165165
}
166166

167167
/**
168168
* Annotates an image {@code img} with a polygon defined by {@code face}.
169169
*/
170-
private static void annotateWithFace(BufferedImage img, FaceAnnotation face) {
170+
private static void annotateWithFace(BufferedImage img, GoogleCloudVisionV1FaceAnnotation face) {
171171
Graphics2D gfx = img.createGraphics();
172172
Polygon poly = new Polygon();
173-
for (Vertex vertex : face.getFdBoundingPoly().getVertices()) {
173+
for (GoogleCloudVisionV1Vertex vertex : face.getFdBoundingPoly().getVertices()) {
174174
poly.addPoint(vertex.getX(), vertex.getY());
175175
}
176176
gfx.setStroke(new BasicStroke(5));

vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.fail;
2121

22-
import com.google.api.services.vision.v1.model.FaceAnnotation;
22+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1FaceAnnotation;
2323

2424
import org.junit.Before;
2525
import org.junit.Test;
@@ -45,7 +45,7 @@ public class FaceDetectAppIT {
4545
}
4646

4747
@Test public void detectFaces_withFace_returnsAtLeastOneFace() throws Exception {
48-
List<FaceAnnotation> faces =
48+
List<GoogleCloudVisionV1FaceAnnotation> faces =
4949
appUnderTest.detectFaces(Paths.get("data/face.jpg"), MAX_RESULTS);
5050

5151
assertThat(faces).named("face.jpg faces").isNotEmpty();

vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21-
import com.google.api.services.vision.v1.model.BoundingPoly;
22-
import com.google.api.services.vision.v1.model.FaceAnnotation;
23-
import com.google.api.services.vision.v1.model.Vertex;
21+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1BoundingPoly;
22+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1FaceAnnotation;
23+
import com.google.api.services.vision.v1.model.GoogleCloudVisionV1Vertex;
2424
import com.google.common.collect.ImmutableList;
2525

2626
import org.junit.Test;
@@ -36,21 +36,21 @@
3636
public class FaceDetectAppTest {
3737
@Test public void annotateWithFaces_manyFaces_outlinesFaces() throws Exception {
3838
// Arrange
39-
ImmutableList<FaceAnnotation> faces =
39+
ImmutableList<GoogleCloudVisionV1FaceAnnotation> faces =
4040
ImmutableList.of(
41-
new FaceAnnotation()
41+
new GoogleCloudVisionV1FaceAnnotation()
4242
.setFdBoundingPoly(
43-
new BoundingPoly().setVertices(ImmutableList.of(
44-
new Vertex().setX(10).setY(5),
45-
new Vertex().setX(20).setY(5),
46-
new Vertex().setX(20).setY(25),
47-
new Vertex().setX(10).setY(25)))),
48-
new FaceAnnotation()
43+
new GoogleCloudVisionV1BoundingPoly().setVertices(ImmutableList.of(
44+
new GoogleCloudVisionV1Vertex().setX(10).setY(5),
45+
new GoogleCloudVisionV1Vertex().setX(20).setY(5),
46+
new GoogleCloudVisionV1Vertex().setX(20).setY(25),
47+
new GoogleCloudVisionV1Vertex().setX(10).setY(25)))),
48+
new GoogleCloudVisionV1FaceAnnotation()
4949
.setFdBoundingPoly(
50-
new BoundingPoly().setVertices(ImmutableList.of(
51-
new Vertex().setX(60).setY(50),
52-
new Vertex().setX(70).setY(60),
53-
new Vertex().setX(50).setY(60)))));
50+
new GoogleCloudVisionV1BoundingPoly().setVertices(ImmutableList.of(
51+
new GoogleCloudVisionV1Vertex().setX(60).setY(50),
52+
new GoogleCloudVisionV1Vertex().setX(70).setY(60),
53+
new GoogleCloudVisionV1Vertex().setX(50).setY(60)))));
5454
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
5555

5656
// Act

0 commit comments

Comments
 (0)