diff --git a/vision/cloud-client/README.md b/vision/cloud-client/README.md index c8cdefa55a2..a62a7d7e44d 100644 --- a/vision/cloud-client/README.md +++ b/vision/cloud-client/README.md @@ -1,5 +1,8 @@ # Image Feature Detection Sample + +Open in Cloud Shell + [Google Cloud Vision API][vision] provides feature detection for images. This API is part of the larger collection of Cloud Machine Learning APIs. diff --git a/vision/cloud-client/pom.xml b/vision/cloud-client/pom.xml index a8e70a18b29..1c18ee679be 100644 --- a/vision/cloud-client/pom.xml +++ b/vision/cloud-client/pom.xml @@ -19,12 +19,14 @@ vision-google-cloud-samples jar - + - doc-samples - com.google.cloud - 1.0.0 - ../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index e25c6b29353..69d41864941 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1,18 +1,19 @@ /* - Copyright 2017, Google, Inc. + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ package com.example.vision; @@ -43,7 +44,6 @@ import com.google.cloud.vision.v1.WebDetection.WebPage; import com.google.cloud.vision.v1.Word; import com.google.protobuf.ByteString; - import java.io.FileInputStream; import java.io.IOException; import java.io.PrintStream; @@ -805,7 +805,8 @@ public static void detectWebDetections(String filePath, PrintStream out) throws } /** - * Detects whether the specified remote image on Google Cloud Storage has features you would want to moderate. + * Detects whether the specified remote image on Google Cloud Storage has features you would want + * to moderate. * * @param gcsPath The path to the remote file on Google Cloud Storage to detect safe-search on. * @param out A {@link PrintStream} to write the results to. diff --git a/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java b/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java index 53e840c43e0..c7d5bd2ec6f 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java +++ b/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java @@ -1,23 +1,25 @@ /* - Copyright 2017, Google, Inc. + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ package com.example.vision; // [START vision_quickstart] // Imports the Google Cloud client library + import com.google.cloud.vision.v1.AnnotateImageRequest; import com.google.cloud.vision.v1.AnnotateImageResponse; import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; @@ -27,7 +29,6 @@ import com.google.cloud.vision.v1.Image; import com.google.cloud.vision.v1.ImageAnnotatorClient; import com.google.protobuf.ByteString; - import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -68,7 +69,7 @@ public static void main(String... args) throws Exception { } for (EntityAnnotation annotation : res.getLabelAnnotationsList()) { - annotation.getAllFields().forEach((k, v)-> + annotation.getAllFields().forEach((k, v) -> System.out.printf("%s : %s\n", k, v.toString())); } } diff --git a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java index 6d4ee5767b3..5efdcf3ecff 100644 --- a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java +++ b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java @@ -1,33 +1,32 @@ /* - Copyright 2017, Google, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.example.vision; import static com.google.common.truth.Truth.assertThat; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; - /** Tests for vision "Detect" sample. */ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") diff --git a/vision/face-detection/README.md b/vision/face-detection/README.md index 25de0a9057b..c272b53accc 100644 --- a/vision/face-detection/README.md +++ b/vision/face-detection/README.md @@ -1,5 +1,8 @@ # Google Cloud Vision API Java Face Detection example + +Open in Cloud Shell + ## Download Maven This sample uses the [Apache Maven][maven] build system. Before getting started, be diff --git a/vision/face-detection/pom.xml b/vision/face-detection/pom.xml index 845d2372604..6138d2620df 100644 --- a/vision/face-detection/pom.xml +++ b/vision/face-detection/pom.xml @@ -21,12 +21,14 @@ com.google.cloud.vision.samples vision-face-detection - + - com.google.cloud - doc-samples - 1.0.0 - ../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/face-detection/src/main/java/com/google/cloud/vision/samples/facedetect/FaceDetectApp.java b/vision/face-detection/src/main/java/com/google/cloud/vision/samples/facedetect/FaceDetectApp.java index 67d9999de53..11d3c06634a 100644 --- a/vision/face-detection/src/main/java/com/google/cloud/vision/samples/facedetect/FaceDetectApp.java +++ b/vision/face-detection/src/main/java/com/google/cloud/vision/samples/facedetect/FaceDetectApp.java @@ -17,6 +17,7 @@ package com.google.cloud.vision.samples.facedetect; // [BEGIN import_libraries] + import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.json.JsonFactory; @@ -32,7 +33,6 @@ import com.google.api.services.vision.v1.model.Image; import com.google.api.services.vision.v1.model.Vertex; import com.google.common.collect.ImmutableList; - import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,6 @@ import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.util.List; - import javax.imageio.ImageIO; // [END import_libraries] diff --git a/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppIT.java b/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppIT.java index fadc06abb63..d6f07174c8e 100644 --- a/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppIT.java +++ b/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppIT.java @@ -20,16 +20,14 @@ import static org.junit.Assert.fail; import com.google.api.services.vision.v1.model.FaceAnnotation; - +import java.io.IOException; +import java.nio.file.Paths; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.List; - /** * Integration (system) tests for {@link FaceDetectApp}. */ diff --git a/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppTest.java b/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppTest.java index 24642005273..8004da49bb6 100644 --- a/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppTest.java +++ b/vision/face-detection/src/test/java/com/google/cloud/vision/samples/facedetect/FaceDetectAppTest.java @@ -22,13 +22,11 @@ import com.google.api.services.vision.v1.model.FaceAnnotation; import com.google.api.services.vision.v1.model.Vertex; import com.google.common.collect.ImmutableList; - +import java.awt.image.BufferedImage; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.awt.image.BufferedImage; - /** * Unit tests for {@link FaceDetectApp}. */ diff --git a/vision/label/README.md b/vision/label/README.md index c22c399fa44..1c00085bdf4 100644 --- a/vision/label/README.md +++ b/vision/label/README.md @@ -1,5 +1,8 @@ # Google Cloud Vision API Java Image Labeling example + +Open in Cloud Shell + ## Download Maven This sample uses the [Apache Maven][maven] build system. Before getting started, be diff --git a/vision/label/pom.xml b/vision/label/pom.xml index a8ebef9ef5b..0867774ac7c 100644 --- a/vision/label/pom.xml +++ b/vision/label/pom.xml @@ -21,12 +21,14 @@ com.google.cloud.vision.samples vision-label - + - com.google.cloud - doc-samples - 1.0.0 - ../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java b/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java index fd4b62233e8..ac441e65c86 100644 --- a/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java +++ b/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java @@ -17,6 +17,7 @@ package com.google.cloud.vision.samples.label; // [START import_libraries] + import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.json.JsonFactory; @@ -31,7 +32,6 @@ import com.google.api.services.vision.v1.model.Feature; import com.google.api.services.vision.v1.model.Image; import com.google.common.collect.ImmutableList; - import java.io.IOException; import java.io.PrintStream; import java.nio.file.Files; diff --git a/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppIT.java b/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppIT.java index 17886c77432..ca19e10cc34 100644 --- a/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppIT.java +++ b/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppIT.java @@ -21,16 +21,14 @@ import com.google.api.services.vision.v1.model.EntityAnnotation; import com.google.common.collect.ImmutableSet; - +import java.io.IOException; +import java.nio.file.Paths; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.List; - /** * Integration (system) tests for {@link LabelApp}. */ diff --git a/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppTest.java b/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppTest.java index 6a238a3d248..f53ea7c3689 100644 --- a/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppTest.java +++ b/vision/label/src/test/java/com/google/cloud/vision/samples/label/LabelAppTest.java @@ -20,14 +20,12 @@ import com.google.api.services.vision.v1.model.EntityAnnotation; import com.google.common.collect.ImmutableList; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.nio.file.Paths; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Unit tests for {@link LabelApp}. diff --git a/vision/landmark-detection/README.md b/vision/landmark-detection/README.md index f04b6d99b26..03139b6ac5e 100644 --- a/vision/landmark-detection/README.md +++ b/vision/landmark-detection/README.md @@ -1,5 +1,8 @@ # Google Cloud Vision API Java Landmark Detection example + +Open in Cloud Shell + This sample takes in the URI for an object in Google Cloud Storage, and identifies the landmark pictured in it. diff --git a/vision/landmark-detection/pom.xml b/vision/landmark-detection/pom.xml index 9d34c76582b..6f798a6cb9e 100644 --- a/vision/landmark-detection/pom.xml +++ b/vision/landmark-detection/pom.xml @@ -21,12 +21,14 @@ com.google.cloud.vision.samples vision-landmark-detection - + - com.google.cloud - doc-samples - 1.0.0 - ../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java b/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java index 8274ed88f92..dd99a52af15 100644 --- a/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java +++ b/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java @@ -17,6 +17,7 @@ package com.google.cloud.vision.samples.landmarkdetection; // [START import_libraries] + import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.json.JsonFactory; @@ -32,7 +33,6 @@ import com.google.api.services.vision.v1.model.Image; import com.google.api.services.vision.v1.model.ImageSource; import com.google.common.collect.ImmutableList; - import java.io.IOException; import java.security.GeneralSecurityException; import java.util.List; diff --git a/vision/landmark-detection/src/test/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmarkIT.java b/vision/landmark-detection/src/test/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmarkIT.java index bb4c4e04f77..0312974069d 100644 --- a/vision/landmark-detection/src/test/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmarkIT.java +++ b/vision/landmark-detection/src/test/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmarkIT.java @@ -20,15 +20,13 @@ import static org.junit.Assert.fail; import com.google.api.services.vision.v1.model.EntityAnnotation; - +import java.io.IOException; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.io.IOException; -import java.util.List; - /** * Integration (system) tests for {@link DetectLandmark}. **/ @@ -66,13 +64,13 @@ public class DetectLandmarkIT { } } -// TODO(lesv): Currently we can access it, need to set better attributes. -// @Test public void identifyLandmark_noImage_throwsForbidden() throws Exception { -// try { -// appUnderTest.identifyLandmark(PRIVATE_LANDMARK_URI, MAX_RESULTS); -// fail("Expected IOException"); -// } catch (IOException expected) { -// assertThat(expected.getMessage()).named("IOException message").contains("permission"); -// } -// } + // TODO(lesv): Currently we can access it, need to set better attributes. + // @Test public void identifyLandmark_noImage_throwsForbidden() throws Exception { + // try { + // appUnderTest.identifyLandmark(PRIVATE_LANDMARK_URI, MAX_RESULTS); + // fail("Expected IOException"); + // } catch (IOException expected) { + // assertThat(expected.getMessage()).named("IOException message").contains("permission"); + // } + // } } diff --git a/vision/text/README.md b/vision/text/README.md index 8e7cb5550e3..b65e3417cf5 100644 --- a/vision/text/README.md +++ b/vision/text/README.md @@ -1,5 +1,8 @@ # Text Detection using the Vision API + +Open in Cloud Shell + This sample requires Java 8. ## Download Maven diff --git a/vision/text/pom.xml b/vision/text/pom.xml index 7270f0d6560..fbb1e5cf6fc 100644 --- a/vision/text/pom.xml +++ b/vision/text/pom.xml @@ -21,12 +21,14 @@ com.google.cloud.vision.samples vision-text - + - com.google.cloud - doc-samples - 1.0.0 - ../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/text/src/main/java/com/google/cloud/vision/samples/text/ImageText.java b/vision/text/src/main/java/com/google/cloud/vision/samples/text/ImageText.java index 4d695f9401f..aa1176d3ef7 100644 --- a/vision/text/src/main/java/com/google/cloud/vision/samples/text/ImageText.java +++ b/vision/text/src/main/java/com/google/cloud/vision/samples/text/ImageText.java @@ -18,10 +18,8 @@ import com.google.api.services.vision.v1.model.EntityAnnotation; import com.google.api.services.vision.v1.model.Status; - import java.nio.file.Path; import java.util.List; - import javax.annotation.Nullable; /** diff --git a/vision/text/src/main/java/com/google/cloud/vision/samples/text/Index.java b/vision/text/src/main/java/com/google/cloud/vision/samples/text/Index.java index 080d4d31e3b..53aeb4c1451 100644 --- a/vision/text/src/main/java/com/google/cloud/vision/samples/text/Index.java +++ b/vision/text/src/main/java/com/google/cloud/vision/samples/text/Index.java @@ -17,21 +17,18 @@ package com.google.cloud.vision.samples.text; import com.google.common.collect.ImmutableSet; - -import opennlp.tools.stemmer.Stemmer; -import opennlp.tools.tokenize.Tokenizer; -import opennlp.tools.tokenize.TokenizerModel; - -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; - import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; import java.util.HashSet; import java.util.stream.Stream; +import opennlp.tools.stemmer.Stemmer; +import opennlp.tools.tokenize.Tokenizer; +import opennlp.tools.tokenize.TokenizerModel; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; /** * An inverted index using Redis. diff --git a/vision/text/src/main/java/com/google/cloud/vision/samples/text/TextApp.java b/vision/text/src/main/java/com/google/cloud/vision/samples/text/TextApp.java index 951dacd00f6..862a289b089 100644 --- a/vision/text/src/main/java/com/google/cloud/vision/samples/text/TextApp.java +++ b/vision/text/src/main/java/com/google/cloud/vision/samples/text/TextApp.java @@ -34,12 +34,6 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; - -import opennlp.tools.stemmer.snowball.SnowballStemmer; -import opennlp.tools.tokenize.TokenizerME; - -import redis.clients.jedis.JedisPool; - import java.io.Console; import java.io.IOException; import java.nio.file.Files; @@ -48,6 +42,9 @@ import java.security.GeneralSecurityException; import java.util.List; import java.util.stream.Collectors; +import opennlp.tools.stemmer.snowball.SnowballStemmer; +import opennlp.tools.tokenize.TokenizerME; +import redis.clients.jedis.JedisPool; /** diff --git a/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppIT.java b/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppIT.java index 1b311d9db64..8077634458a 100644 --- a/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppIT.java +++ b/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppIT.java @@ -19,16 +19,14 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; - +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; - /** * Integration (system) tests for {@link TextApp}. **/ diff --git a/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppTest.java b/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppTest.java index bd197cc54c7..45c72ed3942 100644 --- a/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppTest.java +++ b/vision/text/src/test/java/com/google/cloud/vision/samples/text/TextAppTest.java @@ -29,16 +29,14 @@ import com.google.api.client.testing.http.MockLowLevelHttpResponse; import com.google.api.services.vision.v1.Vision; import com.google.common.collect.ImmutableList; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Unit tests for {@link TextApp}.