Skip to content

Commit 36f0f61

Browse files
committed
Update beta/ cloud-client/ directories
1 parent 761d76d commit 36f0f61

File tree

8 files changed

+201
-164
lines changed

8 files changed

+201
-164
lines changed

vision/beta/cloud-client/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ Install [Maven](http://maven.apache.org/).
1616
Build your project with:
1717

1818
```
19-
mvn clean compile assembly:single
19+
mvn clean package
2020
```
2121

22-
You can then run a given `ClassName` via:
22+
You can then run `Detect` via:
2323

2424
```
25-
mvn exec:java -Dexec.mainClass=com.example.vision.ClassName \
26-
-DpropertyName=propertyValue \
27-
-Dexec.args="arg1 'arg 2' arg3"
25+
mvn exec:java -DDetect -Dexec.args="arg1 'arg 2' arg3"
2826
```
2927

3028
### Analyze an image
@@ -34,7 +32,5 @@ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
3432
```
3533

3634
```
37-
java -cp target/vision-detect-beta-1.0.0-jar-with-dependencies.jar \
38-
com.example.vision.Detect \
39-
logos "./resources/logos.png"
35+
mvn exec:java -DDetect -Dexec.args="logos './resources/logos.png'"
4036
```

vision/beta/cloud-client/pom.xml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@
4242
</dependency>
4343
<!-- [END dependencies] -->
4444

45-
<dependency>
46-
<groupId>com.google.auth</groupId>
47-
<artifactId>google-auth-library-oauth2-http</artifactId>
48-
<version>0.9.0</version>
49-
</dependency>
50-
<dependency>
51-
<groupId>com.google.guava</groupId>
52-
<artifactId>guava</artifactId>
53-
<version>23.0</version>
54-
</dependency>
5545
<!-- Test dependencies -->
5646
<dependency>
5747
<groupId>junit</groupId>
@@ -67,21 +57,35 @@
6757
<scope>test</scope>
6858
</dependency>
6959
</dependencies>
70-
<build>
71-
<plugins>
72-
<plugin>
73-
<artifactId>maven-assembly-plugin</artifactId>
74-
<configuration>
75-
<archive>
76-
<manifest>
60+
61+
<profiles>
62+
<profile>
63+
<id>Detect</id>
64+
<activation>
65+
<property>
66+
<name>Detect</name>
67+
</property>
68+
</activation>
69+
<build>
70+
<plugins>
71+
<plugin>
72+
<groupId>org.codehaus.mojo</groupId>
73+
<artifactId>exec-maven-plugin</artifactId>
74+
<version>1.6.0</version>
75+
<executions>
76+
<execution>
77+
<goals>
78+
<goal>java</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
<configuration>
7783
<mainClass>com.example.vision.Detect</mainClass>
78-
</manifest>
79-
</archive>
80-
<descriptorRefs>
81-
<descriptorRef>jar-with-dependencies</descriptorRef>
82-
</descriptorRefs>
83-
</configuration>
84-
</plugin>
85-
</plugins>
86-
</build>
84+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
85+
</configuration>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
</profile>
90+
</profiles>
8791
</project>

vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
/**
2-
* Copyright 2017, Google, Inc.
3-
*
4-
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5-
* except in compliance with the License. You may obtain a copy of the License at
6-
*
7-
* <p>http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10-
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
* express or implied. See the License for the specific language governing permissions and
12-
* limitations under the License.
13-
*/
1+
/*
2+
Copyright 2017, Google, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
1416

1517
package com.example.vision;
1618

@@ -56,7 +58,7 @@
5658
public class Detect {
5759

5860
/**
59-
* Detects entities,sentiment and syntax in a document using the Natural Language API.
61+
* Detects entities, sentiment, and syntax in a document using the Vision API.
6062
*
6163
* @throws Exception on errors while closing the client.
6264
* @throws IOException on Input/Output errors.
@@ -75,13 +77,12 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception,
7577
if (args.length < 1) {
7678
out.println("Usage:");
7779
out.printf(
78-
"\tjava %s \"<command>\" \"<path-to-image>\"\n"
80+
"\tmvn exec:java -DDetect -Dexec.args=\"<command> <path-to-image>\"\n"
7981
+ "Commands:\n"
8082
+ "\tfaces | labels | landmarks | logos | text | safe-search | properties"
8183
+ "| web | web-entities | web-entities-include-geo | crop \n"
8284
+ "Path:\n\tA file path (ex: ./resources/wakeupcat.jpg) or a URI for a Cloud Storage "
83-
+ "resource (gs://...)\n",
84-
Detect.class.getCanonicalName());
85+
+ "resource (gs://...)\n");
8586
return;
8687
}
8788
String command = args[0];
@@ -207,9 +208,10 @@ public static void detectFaces(String filePath, PrintStream out) throws Exceptio
207208
}
208209

209210
/**
210-
* Detects faces in the specified remote image.
211+
* Detects faces in the specified remote image on Google Cloud Storage.
211212
*
212-
* @param gcsPath The path to the remote file to perform face detection on.
213+
* @param gcsPath The path to the remote file on Google Cloud Storage to perform face detection
214+
* on.
213215
* @param out A {@link PrintStream} to write detected features to.
214216
* @throws Exception on errors while closing the client.
215217
* @throws IOException on Input/Output errors.
@@ -287,9 +289,10 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti
287289
}
288290

289291
/**
290-
* Detects labels in the specified remote image.
292+
* Detects labels in the specified remote image on Google Cloud Storage.
291293
*
292-
* @param gcsPath The path to the remote file to perform label detection on.
294+
* @param gcsPath The path to the remote file on Google Cloud Storage to perform label detection
295+
* on.
293296
* @param out A {@link PrintStream} to write detected features to.
294297
* @throws Exception on errors while closing the client.
295298
* @throws IOException on Input/Output errors.
@@ -365,16 +368,16 @@ public static void detectLandmarks(String filePath, PrintStream out) throws Exce
365368
/**
366369
* Detects landmarks in the specified URI.
367370
*
368-
* @param url The path to the file to perform landmark detection on.
371+
* @param uri The path to the file to perform landmark detection on.
369372
* @param out A {@link PrintStream} to write detected landmarks to.
370373
* @throws Exception on errors while closing the client.
371374
* @throws IOException on Input/Output errors.
372375
*/
373-
public static void detectLandmarksUrl(String url, PrintStream out) throws Exception,
376+
public static void detectLandmarksUrl(String uri, PrintStream out) throws Exception,
374377
IOException {
375378
List<AnnotateImageRequest> requests = new ArrayList<>();
376379

377-
ImageSource imgSource = ImageSource.newBuilder().setImageUri(url).build();
380+
ImageSource imgSource = ImageSource.newBuilder().setImageUri(uri).build();
378381
Image img = Image.newBuilder().setSource(imgSource).build();
379382
Feature feat = Feature.newBuilder().setType(Type.LANDMARK_DETECTION).build();
380383
AnnotateImageRequest request =
@@ -401,9 +404,10 @@ public static void detectLandmarksUrl(String url, PrintStream out) throws Except
401404
}
402405

403406
/**
404-
* Detects landmarks in the specified remote image.
407+
* Detects landmarks in the specified remote imageon Google Cloud Storage.
405408
*
406-
* @param gcsPath The path to the remote file to perform landmark detection on.
409+
* @param gcsPath The path to the remote file on Google Cloud Storage to perform landmark
410+
* detection on.
407411
* @param out A {@link PrintStream} to write detected landmarks to.
408412
* @throws Exception on errors while closing the client.
409413
* @throws IOException on Input/Output errors.
@@ -476,9 +480,10 @@ public static void detectLogos(String filePath, PrintStream out) throws Exceptio
476480
}
477481

478482
/**
479-
* Detects logos in the specified remote image.
483+
* Detects logos in the specified remote image on Google Cloud Storage.
480484
*
481-
* @param gcsPath The path to the remote file to perform logo detection on.
485+
* @param gcsPath The path to the remote file on Google Cloud Storage to perform logo detection
486+
* on.
482487
* @param out A {@link PrintStream} to write detected logos to.
483488
* @throws Exception on errors while closing the client.
484489
* @throws IOException on Input/Output errors.
@@ -551,9 +556,9 @@ public static void detectText(String filePath, PrintStream out) throws Exception
551556
}
552557

553558
/**
554-
* Detects text in the specified remote image.
559+
* Detects text in the specified remote image on Google Cloud Storage.
555560
*
556-
* @param gcsPath The path to the remote file to detect text in.
561+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect text in.
557562
* @param out A {@link PrintStream} to write the detected text to.
558563
* @throws Exception on errors while closing the client.
559564
* @throws IOException on Input/Output errors.
@@ -632,9 +637,10 @@ public static void detectProperties(String filePath, PrintStream out) throws Exc
632637
}
633638

634639
/**
635-
* Detects image properties such as color frequency from the specified remote image.
640+
* Detects image properties such as color frequency from the specified remote image on Google
641+
* Cloud Storage.
636642
*
637-
* @param gcsPath The path to the remote file to detect properties on.
643+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect properties on.
638644
* @param out A {@link PrintStream} to write
639645
* @throws Exception on errors while closing the client.
640646
* @throws IOException on Input/Output errors.
@@ -721,9 +727,10 @@ public static void detectSafeSearch(String filePath, PrintStream out) throws Exc
721727

722728
// [START vision_detect_safe_search_uri]
723729
/**
724-
* Detects whether the specified remote image has features you would want to moderate.
730+
* Detects whether the specified image on Google Cloud Storage has features you would want
731+
* to moderate.
725732
*
726-
* @param gcsPath The path to the remote file to detect safe-search on.
733+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect safe-search on.
727734
* @param out A {@link PrintStream} to write the results to.
728735
* @throws Exception on errors while closing the client.
729736
* @throws IOException on Input/Output errors.
@@ -830,9 +837,10 @@ public static void detectWebDetections(String filePath, PrintStream out) throws
830837

831838
// [START vision_detect_web_uri]
832839
/**
833-
* Detects whether the specified remote image has features you would want to moderate.
840+
* Detects whether the remote image on Google Cloud Storage has features you would want to
841+
* moderate.
834842
*
835-
* @param gcsPath The path to the remote file to detect web annotations.
843+
* @param gcsPath The path to the remote on Google Cloud Storage file to detect web annotations.
836844
* @param out A {@link PrintStream} to write the results to.
837845
* @throws Exception on errors while closing the client.
838846
* @throws IOException on Input/Output errors.
@@ -929,8 +937,8 @@ public static void detectWebEntities(String filePath, PrintStream out) throws Ex
929937
}
930938

931939
/**
932-
* Find web entities given the uri to an image.
933-
* @param gcsPath The path to the remote file to detect web entities.
940+
* Find web entities given the remote image on Google Cloud Storage.
941+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect web entities.
934942
* @param out A {@link PrintStream} to write the results to.
935943
* @throws Exception on errors while closing the client.
936944
* @throws IOException on Input/Output errors.
@@ -1016,8 +1024,9 @@ public static void detectWebEntitiesIncludeGeoResults(String filePath, PrintStre
10161024

10171025
// [START vision_web_entities_include_geo_results_uri]
10181026
/**
1019-
* Find web entities given the uri to an image.
1020-
* @param gcsPath The path to the remote file to detect web entities with geo results.
1027+
* Find web entities given the remote image on Google Cloud Storage.
1028+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect web entities with
1029+
* geo results.
10211030
* @param out A {@link PrintStream} to write the results to.
10221031
* @throws Exception on errors while closing the client.
10231032
* @throws IOException on Input/Output errors.
@@ -1104,9 +1113,9 @@ public static void detectCropHints(String filePath, PrintStream out) throws Exce
11041113
}
11051114

11061115
/**
1107-
* Suggests a region to crop to for a remote file.
1116+
* Suggests a region to crop to for a remote file on Google Cloud Storage.
11081117
*
1109-
* @param gcsPath The path to the remote file to detect safe-search on.
1118+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect safe-search on.
11101119
* @param out A {@link PrintStream} to write the results to.
11111120
* @throws Exception on errors while closing the client.
11121121
* @throws IOException on Input/Output errors.
@@ -1208,9 +1217,9 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E
12081217

12091218
// [START vision_detect_document_uri]
12101219
/**
1211-
* Performs document text detection on a local image file.
1220+
* Performs document text detection on a remote image on Google Cloud Storage.
12121221
*
1213-
* @param gcsPath The path to the remote file to detect document text on.
1222+
* @param gcsPath The path to the remote file on Google Cloud Storage to detect document text on.
12141223
* @param out A {@link PrintStream} to write the results to.
12151224
* @throws Exception on errors while closing the client.
12161225
* @throws IOException on Input/Output errors.
@@ -1268,4 +1277,4 @@ public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws
12681277
}
12691278
}
12701279
// [END vision_detect_document_uri]
1271-
}
1280+
}

vision/beta/cloud-client/src/test/java/com/example/vision/DetectIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016, Google, Inc.
2+
Copyright 2017, Google, Inc.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -347,4 +347,4 @@ public void testDocumentTextGcs() throws Exception {
347347
assertThat(got).contains("37%");
348348
assertThat(got).contains("Word text: class (confidence:");
349349
}
350-
}
350+
}

vision/cloud-client/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ Install [Maven](http://maven.apache.org/).
1616
Build your project with:
1717

1818
```
19-
mvn clean compile assembly:single
19+
mvn clean package
2020
```
2121

2222
You can then run a given `ClassName` via:
2323

2424
```
25-
mvn exec:java -Dexec.mainClass=com.example.vision.ClassName \
26-
-DpropertyName=propertyValue \
27-
-Dexec.args="arg1 'arg 2' arg3"
25+
mvn exec:java -DClassName -Dexec.args="arg1 'arg 2' arg3"
2826
```
2927

3028
### Analyze an image
@@ -34,7 +32,5 @@ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
3432
```
3533

3634
```
37-
java -cp target/vision-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
38-
com.example.vision.Detect \
39-
logos "./resources/logos.png"
35+
mvn exec:java -DDetect -Dexec.args="logos './resources/logos.png'"
4036
```

0 commit comments

Comments
 (0)