This sample requires Java 8.
This sample uses the Apache Maven build system. Before getting started, be sure to download and install it. When you use Maven as described here, it will automatically download the needed client libraries.
This example uses the Cloud Vision API to detect text within images, stores this text in an index, and then lets you query this index.
This example uses a redis server, which must be up and
running before you start the indexing. To install Redis, follow the
instructions on the download page, or install via a
package manager like homebrew or apt-get
as appropriate
for your OS.
The example assumes that the server is running on localhost
, on the default
port, and it uses redis
dbs 0 and 1 for its data.
Edit the example code before you start if your redis settings are different.
Download Tokenizer data and save it to this directory.
wget http://opennlp.sourceforge.net/models-1.5/en-token.bin
To build and run the sample, run the jar from this directory. You can provide a directory to index the text in all the images it contains.
mvn clean compile assembly:single
java -cp target/text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp ../../data/text/
Once this builds the index, you can run the same command without the input path to query the index.
java -cp target/text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp