Skip to content

Commit df6ea40

Browse files
gguussjmdobry
authored andcommitted
Cloud Client Vision How-to snippets (GoogleCloudPlatform#485)
* Add initial cloud client Vision API snippets. * Add Vision API quickstart. (GoogleCloudPlatform#486)
1 parent 32c0f6f commit df6ea40

File tree

12 files changed

+734
-0
lines changed

12 files changed

+734
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ tags
4848

4949
# Gradle
5050
out/
51+
52+
# OSX
53+
.DS_Store

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<module>translate</module>
119119
<module>translate/cloud-client</module>
120120
<module>unittests</module>
121+
<module>vision/cloud-client</module>
121122
<module>vision/face-detection</module>
122123
<module>vision/label</module>
123124
<module>vision/landmark-detection</module>

vision/cloud-client/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Image Feature Detection Sample
2+
3+
[Google Cloud Vision API][vision] provides feature detection for images.
4+
This API is part of the larger collection of Cloud Machine Learning APIs.
5+
6+
This sample Java application demonstrates how to access the Cloud Vision API
7+
using the [Google Cloud Client Library for Java][google-cloud-java].
8+
9+
[vision]: https://cloud.google.com/vision/docs/
10+
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
11+
12+
## Build the sample
13+
14+
Install [Maven](http://maven.apache.org/).
15+
16+
Build your project with:
17+
18+
```
19+
mvn clean compile assembly:single
20+
```
21+
22+
You can then run a given `ClassName` via:
23+
24+
```
25+
mvn exec:java -Dexec.mainClass=com.example.vision.ClassName \
26+
-DpropertyName=propertyValue \
27+
-Dexec.args="arg1 'arg 2' arg3"
28+
```
29+
30+
### Analyze an image
31+
32+
```
33+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
34+
```
35+
36+
```
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"
40+
```

vision/cloud-client/pom.xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!--
2+
Copyright 2017 Google Inc. All Rights Reserved.
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+
-->
16+
<project>
17+
<modelVersion>4.0.0</modelVersion>
18+
<groupId>com.example.vision</groupId>
19+
<artifactId>vision-google-cloud-samples</artifactId>
20+
<packaging>jar</packaging>
21+
22+
<!-- Parent defines config for testing & linting. -->
23+
<parent>
24+
<artifactId>doc-samples</artifactId>
25+
<groupId>com.google.cloud</groupId>
26+
<version>1.0.0</version>
27+
<relativePath>../..</relativePath>
28+
</parent>
29+
30+
<properties>
31+
<maven.compiler.target>1.8</maven.compiler.target>
32+
<maven.compiler.source>1.8</maven.compiler.source>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
</properties>
35+
36+
<dependencies>
37+
<!-- [START dependencies] -->
38+
<dependency>
39+
<groupId>com.google.cloud</groupId>
40+
<artifactId>google-cloud-vision</artifactId>
41+
<version>0.8.1-alpha</version>
42+
</dependency>
43+
<!-- [END dependencies] -->
44+
45+
<!-- Test dependencies -->
46+
<dependency>
47+
<groupId>junit</groupId>
48+
<artifactId>junit</artifactId>
49+
<version>4.12</version>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.google.truth</groupId>
54+
<artifactId>truth</artifactId>
55+
<version>0.31</version>
56+
<scope>test</scope>
57+
</dependency>
58+
</dependencies>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<artifactId>maven-assembly-plugin</artifactId>
63+
<configuration>
64+
<archive>
65+
<manifest>
66+
<mainClass>com.example.vision.Detect</mainClass>
67+
</manifest>
68+
</archive>
69+
<descriptorRefs>
70+
<descriptorRef>jar-with-dependencies</descriptorRef>
71+
</descriptorRefs>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
</project>
Loading
158 KB
Loading
8.06 KB
Loading
122 KB
Loading
63.4 KB
Loading

0 commit comments

Comments
 (0)