google-cloud-vision 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +2 -9
- data/LICENSE +1 -1
- data/README.md +94 -0
- data/lib/google/cloud/vision.rb +200 -535
- data/lib/google/cloud/vision/v1.rb +129 -55
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +9 -0
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +88 -0
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +539 -0
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +3 -3
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +2 -1
- data/lib/google/cloud/vision/{version.rb → v1/doc/google/protobuf/empty.rb} +13 -6
- data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +230 -0
- data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/vision/v1/geometry_pb.rb +1 -0
- data/lib/google/cloud/vision/v1/helpers.rb +972 -0
- data/lib/google/cloud/vision/v1/image_annotator_client.rb +4 -4
- data/lib/google/cloud/vision/v1/image_annotator_pb.rb +5 -0
- data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +2 -1
- data/lib/google/cloud/vision/v1/product_search_client.rb +1337 -0
- data/lib/google/cloud/vision/v1/product_search_client_config.json +116 -0
- data/lib/google/cloud/vision/v1/product_search_pb.rb +45 -0
- data/lib/google/cloud/vision/v1/product_search_service_pb.rb +191 -0
- data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +224 -0
- data/lib/google/cloud/vision/v1p3beta1.rb +233 -0
- data/lib/google/cloud/vision/v1p3beta1/credentials.rb +42 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +72 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +763 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +154 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +533 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +254 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +101 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +93 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +130 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +230 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +90 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +84 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +156 -0
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +65 -0
- data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +43 -0
- data/lib/google/cloud/vision/v1p3beta1/helpers.rb +972 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +302 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +36 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +304 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +55 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +1351 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +116 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +64 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +191 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +222 -0
- data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +94 -0
- data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +51 -0
- metadata +53 -122
- data/AUTHENTICATION.md +0 -179
- data/CHANGELOG.md +0 -109
- data/CODE_OF_CONDUCT.md +0 -40
- data/CONTRIBUTING.md +0 -188
- data/LOGGING.md +0 -32
- data/OVERVIEW.md +0 -202
- data/TROUBLESHOOTING.md +0 -37
- data/lib/google-cloud-vision.rb +0 -146
- data/lib/google/cloud/vision/annotate.rb +0 -303
- data/lib/google/cloud/vision/annotation.rb +0 -553
- data/lib/google/cloud/vision/annotation/crop_hint.rb +0 -126
- data/lib/google/cloud/vision/annotation/entity.rb +0 -225
- data/lib/google/cloud/vision/annotation/face.rb +0 -1497
- data/lib/google/cloud/vision/annotation/normalized_vertex.rb +0 -76
- data/lib/google/cloud/vision/annotation/object_localization.rb +0 -115
- data/lib/google/cloud/vision/annotation/properties.rb +0 -220
- data/lib/google/cloud/vision/annotation/safe_search.rb +0 -153
- data/lib/google/cloud/vision/annotation/text.rb +0 -1015
- data/lib/google/cloud/vision/annotation/vertex.rb +0 -91
- data/lib/google/cloud/vision/annotation/web.rb +0 -420
- data/lib/google/cloud/vision/credentials.rb +0 -57
- data/lib/google/cloud/vision/image.rb +0 -832
- data/lib/google/cloud/vision/location.rb +0 -98
- data/lib/google/cloud/vision/project.rb +0 -367
- data/lib/google/cloud/vision/service.rb +0 -83
data/CHANGELOG.md
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Release History
|
|
2
|
-
|
|
3
|
-
### 0.31.0 / 2018-09-26
|
|
4
|
-
|
|
5
|
-
* Add Object Localization.
|
|
6
|
-
|
|
7
|
-
### 0.30.4 / 2018-09-20
|
|
8
|
-
|
|
9
|
-
* Update documentation.
|
|
10
|
-
* Change documentation URL to googleapis GitHub org.
|
|
11
|
-
* Fix circular require warning.
|
|
12
|
-
|
|
13
|
-
### 0.30.3 / 2018-09-12
|
|
14
|
-
|
|
15
|
-
* Add missing documentation files to package.
|
|
16
|
-
|
|
17
|
-
### 0.30.2 / 2018-09-10
|
|
18
|
-
|
|
19
|
-
* Update documentation.
|
|
20
|
-
|
|
21
|
-
### 0.30.1 / 2018-08-21
|
|
22
|
-
|
|
23
|
-
* Update documentation.
|
|
24
|
-
|
|
25
|
-
### 0.30.0 / 2018-07-20
|
|
26
|
-
|
|
27
|
-
* Add async_batch_annotate_files method to Google::Cloud::Vision::Project
|
|
28
|
-
|
|
29
|
-
### 0.29.1 / 2018-07-05
|
|
30
|
-
|
|
31
|
-
* Update google-gax dependency to version 1.3.
|
|
32
|
-
|
|
33
|
-
### 0.29.0 / 2018-06-22
|
|
34
|
-
|
|
35
|
-
* Add V1 API.
|
|
36
|
-
|
|
37
|
-
### 0.28.0 / 2018-02-27
|
|
38
|
-
|
|
39
|
-
* Add Shared Configuration.
|
|
40
|
-
|
|
41
|
-
### 0.27.0 / 2017-12-19
|
|
42
|
-
|
|
43
|
-
* Update google-gax dependency to 1.0.
|
|
44
|
-
|
|
45
|
-
### 0.26.0 / 2017-11-14
|
|
46
|
-
|
|
47
|
-
* Add `Google::Cloud::Vision::Credentials` class.
|
|
48
|
-
* Rename constructor arguments to `project_id` and `credentials`.
|
|
49
|
-
(The previous arguments `project` and `keyfile` are still supported.)
|
|
50
|
-
* Document `Google::Auth::Credentials` as `credentials` value.
|
|
51
|
-
* Update generated low level GAPIC code.
|
|
52
|
-
* Updated `google-gax` (`grpc`, `google-protobuf`), `googleauth` dependencies.
|
|
53
|
-
|
|
54
|
-
### 0.25.0 / 2017-07-11
|
|
55
|
-
|
|
56
|
-
* Add `Image#annotate`.
|
|
57
|
-
* Update GAPIC configuration to exclude `UNAVAILABLE` errors from automatic retry.
|
|
58
|
-
* Update gem spec homepage links.
|
|
59
|
-
|
|
60
|
-
### 0.24.0 / 2017-03-31
|
|
61
|
-
|
|
62
|
-
* Updated documentation
|
|
63
|
-
* Automatic retry on `UNAVAILABLE` errors
|
|
64
|
-
|
|
65
|
-
### 0.23.0 / 2017-03-03
|
|
66
|
-
|
|
67
|
-
Major release, adding V1.1 support.
|
|
68
|
-
|
|
69
|
-
* Support image URLs from the internet, not just Cloud Storage.
|
|
70
|
-
* Add document text detection feature, like text but for longer documents.
|
|
71
|
-
* Add crop hints feature.
|
|
72
|
-
* Add web annotation feature
|
|
73
|
-
* Update GRPC header value sent to the Vision API.
|
|
74
|
-
|
|
75
|
-
### 0.22.1 / 2017-03-01
|
|
76
|
-
|
|
77
|
-
* No public API changes.
|
|
78
|
-
* Update GRPC header value sent to the Vision API.
|
|
79
|
-
|
|
80
|
-
### 0.22.0 / 2017-02-21
|
|
81
|
-
|
|
82
|
-
* Fix GRPC retry bug
|
|
83
|
-
* The client_config data structure has replaced retry_codes/retry_codes_def with retry_codes
|
|
84
|
-
* Update GRPC/Protobuf/GAX dependencies
|
|
85
|
-
* Updates to code examples in documentation
|
|
86
|
-
|
|
87
|
-
### 0.21.1 / 2016-10-27
|
|
88
|
-
|
|
89
|
-
* Fix outdated requires (Ricowere)
|
|
90
|
-
|
|
91
|
-
### 0.21.0 / 2016-10-20
|
|
92
|
-
|
|
93
|
-
* New service constructor Google::Cloud::Vision.new
|
|
94
|
-
* New constructor argument client_config
|
|
95
|
-
|
|
96
|
-
### 0.20.2 / 2016-09-06
|
|
97
|
-
|
|
98
|
-
* Fix for using GCS URLs. (erikaxel)
|
|
99
|
-
|
|
100
|
-
### 0.20.1 / 2016-09-02
|
|
101
|
-
|
|
102
|
-
* Fix for timeout on uploads.
|
|
103
|
-
|
|
104
|
-
### 0.20.0 / 2016-08-26
|
|
105
|
-
|
|
106
|
-
This gem contains the Google Cloud Vision service implementation for the `google-cloud` gem. The `google-cloud` gem replaces the old `gcloud` gem. Legacy code can continue to use the `gcloud` gem.
|
|
107
|
-
|
|
108
|
-
* Namespace is now `Google::Cloud`
|
|
109
|
-
* The `google-cloud` gem is now an umbrella package for individual gems
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
2
|
-
|
|
3
|
-
As contributors and maintainers of this project, and in the interest of
|
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
-
|
|
8
|
-
We are committed to making participation in this project a harassment-free
|
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
-
|
|
13
|
-
Examples of unacceptable behavior by participants include:
|
|
14
|
-
|
|
15
|
-
* The use of sexualized language or imagery
|
|
16
|
-
* Personal attacks
|
|
17
|
-
* Trolling or insulting/derogatory comments
|
|
18
|
-
* Public or private harassment
|
|
19
|
-
* Publishing other's private information, such as physical or electronic
|
|
20
|
-
addresses, without explicit permission
|
|
21
|
-
* Other unethical or unprofessional conduct.
|
|
22
|
-
|
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or reject
|
|
24
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
25
|
-
not aligned to this Code of Conduct. By adopting this Code of Conduct, project
|
|
26
|
-
maintainers commit themselves to fairly and consistently applying these
|
|
27
|
-
principles to every aspect of managing this project. Project maintainers who do
|
|
28
|
-
not follow or enforce the Code of Conduct may be permanently removed from the
|
|
29
|
-
project team.
|
|
30
|
-
|
|
31
|
-
This code of conduct applies both within project spaces and in public spaces
|
|
32
|
-
when an individual is representing the project or its community.
|
|
33
|
-
|
|
34
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
35
|
-
reported by opening an issue or contacting one or more of the project
|
|
36
|
-
maintainers.
|
|
37
|
-
|
|
38
|
-
This Code of Conduct is adapted from the [Contributor
|
|
39
|
-
Covenant](http://contributor-covenant.org), version 1.2.0, available at
|
|
40
|
-
[http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
data/CONTRIBUTING.md
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Contributing to Google Cloud Vision
|
|
2
|
-
|
|
3
|
-
1. **Sign one of the contributor license agreements below.**
|
|
4
|
-
2. Fork the repo, develop and test your code changes.
|
|
5
|
-
3. Send a pull request.
|
|
6
|
-
|
|
7
|
-
## Contributor License Agreements
|
|
8
|
-
|
|
9
|
-
Before we can accept your pull requests you'll need to sign a Contributor
|
|
10
|
-
License Agreement (CLA):
|
|
11
|
-
|
|
12
|
-
- **If you are an individual writing original source code** and **you own the
|
|
13
|
-
intellectual property**, then you'll need to sign an [individual
|
|
14
|
-
CLA](https://developers.google.com/open-source/cla/individual).
|
|
15
|
-
- **If you work for a company that wants to allow you to contribute your work**,
|
|
16
|
-
then you'll need to sign a [corporate
|
|
17
|
-
CLA](https://developers.google.com/open-source/cla/corporate).
|
|
18
|
-
|
|
19
|
-
You can sign these electronically (just scroll to the bottom). After that, we'll
|
|
20
|
-
be able to accept your pull requests.
|
|
21
|
-
|
|
22
|
-
## Setup
|
|
23
|
-
|
|
24
|
-
In order to use the google-cloud-vision console and run the project's tests,
|
|
25
|
-
there is a small amount of setup:
|
|
26
|
-
|
|
27
|
-
1. Install Ruby. google-cloud-vision requires Ruby 2.3+. You may choose to
|
|
28
|
-
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
|
29
|
-
[rbenv](https://github.com/rbenv/rbenv), or
|
|
30
|
-
[chruby](https://github.com/postmodern/chruby).
|
|
31
|
-
|
|
32
|
-
2. Install [Bundler](http://bundler.io/).
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
$ gem install bundler
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
3. Install the top-level project dependencies.
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
$ bundle install
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
4. Install the Vision dependencies.
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
$ cd google-cloud-vision/
|
|
48
|
-
$ bundle exec rake bundleupdate
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Console
|
|
52
|
-
|
|
53
|
-
In order to run code interactively, you can automatically load
|
|
54
|
-
google-cloud-vision and its dependencies in IRB. This requires that your
|
|
55
|
-
developer environment has already been configured by following the steps
|
|
56
|
-
described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
|
|
57
|
-
can be created with:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
$ cd google-cloud-vision/
|
|
61
|
-
$ bundle exec rake console
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Vision Tests
|
|
65
|
-
|
|
66
|
-
Tests are very important part of google-cloud-vision. All contributions
|
|
67
|
-
should include tests that ensure the contributed code behaves as expected.
|
|
68
|
-
|
|
69
|
-
To run the unit tests, documentation tests, and code style checks together for a
|
|
70
|
-
package:
|
|
71
|
-
|
|
72
|
-
``` sh
|
|
73
|
-
$ cd google-cloud-vision/
|
|
74
|
-
$ bundle exec rake ci
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
|
|
78
|
-
its handy alias, `rake ci:a`.
|
|
79
|
-
|
|
80
|
-
### Vision Unit Tests
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
The project uses the [minitest](https://github.com/seattlerb/minitest) library,
|
|
84
|
-
including [specs](https://github.com/seattlerb/minitest#specs),
|
|
85
|
-
[mocks](https://github.com/seattlerb/minitest#mocks) and
|
|
86
|
-
[minitest-autotest](https://github.com/seattlerb/minitest-autotest).
|
|
87
|
-
|
|
88
|
-
To run the Vision unit tests:
|
|
89
|
-
|
|
90
|
-
``` sh
|
|
91
|
-
$ cd google-cloud-vision/
|
|
92
|
-
$ bundle exec rake test
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Vision Documentation Tests
|
|
96
|
-
|
|
97
|
-
The project tests the code examples in the gem's
|
|
98
|
-
[YARD](https://github.com/lsegal/yard)-based documentation.
|
|
99
|
-
|
|
100
|
-
The example testing functions in a way that is very similar to unit testing, and
|
|
101
|
-
in fact the library providing it,
|
|
102
|
-
[yard-doctest](https://github.com/p0deje/yard-doctest), is based on the
|
|
103
|
-
project's unit test library, [minitest](https://github.com/seattlerb/minitest).
|
|
104
|
-
|
|
105
|
-
To run the Vision documentation tests:
|
|
106
|
-
|
|
107
|
-
``` sh
|
|
108
|
-
$ cd google-cloud-vision/
|
|
109
|
-
$ bundle exec rake doctest
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
If you add, remove or modify documentation examples when working on a pull
|
|
113
|
-
request, you may need to update the setup for the tests. The stubs and mocks
|
|
114
|
-
required to run the tests are located in `support/doctest_helper.rb`. Please
|
|
115
|
-
note that much of the setup is matched by the title of the
|
|
116
|
-
[`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
|
|
117
|
-
If you alter an example's title, you may encounter breaking tests.
|
|
118
|
-
|
|
119
|
-
### Vision Acceptance Tests
|
|
120
|
-
|
|
121
|
-
The Vision acceptance tests interact with the live service API. Follow the
|
|
122
|
-
instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
|
|
123
|
-
the Vision API. Occasionally, some API features may not yet be generally
|
|
124
|
-
available, making it difficult for some contributors to successfully run the
|
|
125
|
-
entire acceptance test suite. However, please ensure that you do successfully
|
|
126
|
-
run acceptance tests for any code areas covered by your pull request.
|
|
127
|
-
|
|
128
|
-
To run the acceptance tests, first create and configure a project in the Google
|
|
129
|
-
Developers Console, as described in the {file:AUTHENTICATION.md Authentication
|
|
130
|
-
guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
|
|
131
|
-
the KEYFILE location on your system.
|
|
132
|
-
|
|
133
|
-
Before you can run the Vision acceptance tests, you must first create indexes
|
|
134
|
-
used in the tests.
|
|
135
|
-
|
|
136
|
-
#### Running the Vision acceptance tests
|
|
137
|
-
|
|
138
|
-
To run the Vision acceptance tests:
|
|
139
|
-
|
|
140
|
-
``` sh
|
|
141
|
-
$ cd google-cloud-vision/
|
|
142
|
-
$ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Or, if you prefer you can store the values in the `GCLOUD_TEST_PROJECT` and
|
|
146
|
-
`GCLOUD_TEST_KEYFILE` environment variables:
|
|
147
|
-
|
|
148
|
-
``` sh
|
|
149
|
-
$ cd google-cloud-vision/
|
|
150
|
-
$ export GCLOUD_TEST_PROJECT=\\{my-project-id}
|
|
151
|
-
$ export GCLOUD_TEST_KEYFILE=\\{/path/to/keyfile.json}
|
|
152
|
-
$ bundle exec rake acceptance
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
If you want to use a different project and credentials for acceptance tests, you
|
|
156
|
-
can use the more specific `VISION_TEST_PROJECT` and `VISION_TEST_KEYFILE`
|
|
157
|
-
environment variables:
|
|
158
|
-
|
|
159
|
-
``` sh
|
|
160
|
-
$ cd google-cloud-vision/
|
|
161
|
-
$ export VISION_TEST_PROJECT=\\{my-project-id}
|
|
162
|
-
$ export VISION_TEST_KEYFILE=\\{/path/to/keyfile.json}
|
|
163
|
-
$ bundle exec rake acceptance
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## Coding Style
|
|
167
|
-
|
|
168
|
-
Please follow the established coding style in the library. The style is is
|
|
169
|
-
largely based on [The Ruby Style
|
|
170
|
-
Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based
|
|
171
|
-
on seattle-style:
|
|
172
|
-
|
|
173
|
-
* Avoid parenthesis when possible, including in method definitions.
|
|
174
|
-
* Always use double quotes strings. ([Option
|
|
175
|
-
B](https://github.com/bbatsov/ruby-style-guide#strings))
|
|
176
|
-
|
|
177
|
-
You can check your code against these rules by running Rubocop like so:
|
|
178
|
-
|
|
179
|
-
```sh
|
|
180
|
-
$ cd google-cloud-vision/
|
|
181
|
-
$ bundle exec rake rubocop
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Code of Conduct
|
|
185
|
-
|
|
186
|
-
Please note that this project is released with a Contributor Code of Conduct. By
|
|
187
|
-
participating in this project you agree to abide by its terms. See
|
|
188
|
-
{file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
|
data/LOGGING.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Enabling gRPC Logging
|
|
2
|
-
|
|
3
|
-
To enable logging for this library, set the logger for the underlying
|
|
4
|
-
[gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
|
|
5
|
-
that you set may be a Ruby stdlib
|
|
6
|
-
[`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
|
|
7
|
-
shown below, or a
|
|
8
|
-
[`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
|
|
9
|
-
that will write logs to [Stackdriver
|
|
10
|
-
Logging](https://cloud.google.com/logging/). See
|
|
11
|
-
[grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
|
12
|
-
and the gRPC
|
|
13
|
-
[spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
|
|
14
|
-
for additional information.
|
|
15
|
-
|
|
16
|
-
Configuring a Ruby stdlib logger:
|
|
17
|
-
|
|
18
|
-
```ruby
|
|
19
|
-
require "logger"
|
|
20
|
-
|
|
21
|
-
module MyLogger
|
|
22
|
-
LOGGER = Logger.new $stderr, level: Logger::WARN
|
|
23
|
-
def logger
|
|
24
|
-
LOGGER
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
|
29
|
-
module GRPC
|
|
30
|
-
extend MyLogger
|
|
31
|
-
end
|
|
32
|
-
```
|
data/OVERVIEW.md
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
# Google Cloud Vision
|
|
2
|
-
|
|
3
|
-
Google Cloud Vision allows developers to easily integrate vision
|
|
4
|
-
detection features within applications, including image labeling, face
|
|
5
|
-
and landmark detection, optical character recognition (OCR), and tagging
|
|
6
|
-
of explicit content.
|
|
7
|
-
|
|
8
|
-
For more information about Cloud Vision, read the [Google Cloud Vision API
|
|
9
|
-
Documentation](https://cloud.google.com/vision/docs/).
|
|
10
|
-
|
|
11
|
-
The goal of google-cloud is to provide an API that is comfortable to
|
|
12
|
-
Rubyists. Your authentication credentials are detected automatically in
|
|
13
|
-
Google Cloud Platform environments such as Google Compute Engine, Google
|
|
14
|
-
App Engine and Google Kubernetes Engine. In other environments you can
|
|
15
|
-
configure authentication easily, either directly in your code or via
|
|
16
|
-
environment variables. Read more about the options for connecting in the
|
|
17
|
-
{file:AUTHENTICATION.md Authentication Guide}.
|
|
18
|
-
|
|
19
|
-
## Creating images
|
|
20
|
-
|
|
21
|
-
The Cloud Vision API supports UTF-8, UTF-16, and UTF-32 text encodings.
|
|
22
|
-
(Ruby uses UTF-8 natively, which is the default sent to the API, so unless
|
|
23
|
-
you're working with text processed in different platform, you should not
|
|
24
|
-
need to set the encoding type.)
|
|
25
|
-
a ). Be aware that Cloud Vision sets upper
|
|
26
|
-
limits on file size as well as on the total combined size of all images in
|
|
27
|
-
a request. Reducing your file size can significantly improve throughput;
|
|
28
|
-
however, be careful not to reduce image quality in the process. See [Best
|
|
29
|
-
Practices - Image
|
|
30
|
-
Sizing](https://cloud.google.com/vision/docs/best-practices#image_sizing)
|
|
31
|
-
for current file size limits.
|
|
32
|
-
|
|
33
|
-
Use {Google::Cloud::Vision::Project#image} to create images for the Cloud Vision
|
|
34
|
-
service. You can provide a file path:
|
|
35
|
-
|
|
36
|
-
```ruby
|
|
37
|
-
require "google/cloud/vision"
|
|
38
|
-
|
|
39
|
-
vision = Google::Cloud::Vision.new
|
|
40
|
-
|
|
41
|
-
image = vision.image "path/to/landmark.jpg"
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Or any publicly-accessible image HTTP/HTTPS URL:
|
|
45
|
-
|
|
46
|
-
```ruby
|
|
47
|
-
require "google/cloud/vision"
|
|
48
|
-
|
|
49
|
-
vision = Google::Cloud::Vision.new
|
|
50
|
-
|
|
51
|
-
image = vision.image "https://www.example.com/images/landmark.jpg"
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Or, you can initialize the image with a Google Cloud Storage URI:
|
|
55
|
-
|
|
56
|
-
```ruby
|
|
57
|
-
require "google/cloud/vision"
|
|
58
|
-
|
|
59
|
-
vision = Google::Cloud::Vision.new
|
|
60
|
-
|
|
61
|
-
image = vision.image "gs://bucket-name/path_to_image_object"
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Creating an Image instance does not perform an API request.
|
|
65
|
-
|
|
66
|
-
## Annotating images
|
|
67
|
-
|
|
68
|
-
The instance methods on {Google::Cloud::Vision::Image} invoke Cloud Vision's
|
|
69
|
-
detection features individually. Each method call makes an API request. (If you
|
|
70
|
-
want to run multiple features in a single request, see the examples for
|
|
71
|
-
{Google::Cloud::Vision::Project#annotate}, below.)
|
|
72
|
-
|
|
73
|
-
```ruby
|
|
74
|
-
require "google/cloud/vision"
|
|
75
|
-
|
|
76
|
-
vision = Google::Cloud::Vision.new
|
|
77
|
-
|
|
78
|
-
image = vision.image "path/to/face.jpg"
|
|
79
|
-
|
|
80
|
-
face = image.face
|
|
81
|
-
|
|
82
|
-
face.features.to_h.count #=> 9
|
|
83
|
-
face.features.eyes.left.pupil
|
|
84
|
-
#<Landmark (x: 190.41544, y: 84.4557, z: -1.3682901)>
|
|
85
|
-
face.features.chin.center
|
|
86
|
-
#<Landmark (x: 233.21977, y: 189.47475, z: 19.487228)>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
To run multiple features on an image in a single request, pass the image (or a
|
|
90
|
-
string file path, publicly-accessible image HTTP/HTTPS URL, or Storage URI) to
|
|
91
|
-
{Google::Cloud::Vision::Project#annotate}:
|
|
92
|
-
|
|
93
|
-
```ruby
|
|
94
|
-
require "google/cloud/vision"
|
|
95
|
-
|
|
96
|
-
vision = Google::Cloud::Vision.new
|
|
97
|
-
|
|
98
|
-
image = vision.image "path/to/face.jpg"
|
|
99
|
-
|
|
100
|
-
annotation = vision.annotate image, faces: true, labels: true
|
|
101
|
-
annotation.faces.count #=> 1
|
|
102
|
-
annotation.labels.count #=> 4
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
You can also perform detection tasks on multiple images in a single
|
|
106
|
-
request:
|
|
107
|
-
|
|
108
|
-
```ruby
|
|
109
|
-
require "google/cloud/vision"
|
|
110
|
-
|
|
111
|
-
vision = Google::Cloud::Vision.new
|
|
112
|
-
|
|
113
|
-
face_image = vision.image "path/to/face.jpg"
|
|
114
|
-
landmark_image = vision.image "path/to/landmark.jpg"
|
|
115
|
-
|
|
116
|
-
annotations = vision.annotate face_image,
|
|
117
|
-
landmark_image,
|
|
118
|
-
faces: true,
|
|
119
|
-
landmarks: true,
|
|
120
|
-
labels: true
|
|
121
|
-
|
|
122
|
-
annotations[0].faces.count #=> 1
|
|
123
|
-
annotations[0].landmarks.count #=> 0
|
|
124
|
-
annotations[0].labels.count #=> 4
|
|
125
|
-
annotations[1].faces.count #=> 1
|
|
126
|
-
annotations[1].landmarks.count #=> 1
|
|
127
|
-
annotations[1].labels.count #=> 6
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
It is even possible to configure different features for multiple images in
|
|
131
|
-
a single call using a block. The following example results in a single
|
|
132
|
-
request to the Cloud Vision API:
|
|
133
|
-
|
|
134
|
-
```ruby
|
|
135
|
-
require "google/cloud/vision"
|
|
136
|
-
|
|
137
|
-
vision = Google::Cloud::Vision.new
|
|
138
|
-
|
|
139
|
-
face_image = vision.image "path/to/face.jpg"
|
|
140
|
-
landmark_image = vision.image "path/to/landmark.jpg"
|
|
141
|
-
text_image = vision.image "path/to/text.png"
|
|
142
|
-
|
|
143
|
-
annotations = vision.annotate do |annotate|
|
|
144
|
-
annotate.annotate face_image, faces: true, labels: true
|
|
145
|
-
annotate.annotate landmark_image, landmarks: true
|
|
146
|
-
annotate.annotate text_image, text: true
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
annotations[0].faces.count #=> 1
|
|
150
|
-
annotations[0].labels.count #=> 4
|
|
151
|
-
annotations[1].landmarks.count #=> 1
|
|
152
|
-
annotations[2].text.pages.count #=> 1
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The maximum number of results returned when performing face, landmark,
|
|
156
|
-
logo, and label detection are defined by
|
|
157
|
-
{Google::Cloud::Vision.default_max_faces},
|
|
158
|
-
{Google::Cloud::Vision.default_max_landmarks},
|
|
159
|
-
{Google::Cloud::Vision.default_max_logos}, and
|
|
160
|
-
{Google::Cloud::Vision.default_max_labels}, respectively. To change the
|
|
161
|
-
global defaults, you can update the configuration:
|
|
162
|
-
|
|
163
|
-
```ruby
|
|
164
|
-
require "google/cloud/vision"
|
|
165
|
-
|
|
166
|
-
vision = Google::Cloud::Vision.new
|
|
167
|
-
|
|
168
|
-
Google::Cloud::Vision.default_max_faces = 1
|
|
169
|
-
|
|
170
|
-
annotation = vision.annotate "path/to/face.jpg", faces: true
|
|
171
|
-
annotation.faces.count #=> 1
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Or, to override a default for a single method call, simply pass an
|
|
175
|
-
integer instead of a flag:
|
|
176
|
-
|
|
177
|
-
```ruby
|
|
178
|
-
require "google/cloud/vision"
|
|
179
|
-
|
|
180
|
-
vision = Google::Cloud::Vision.new
|
|
181
|
-
|
|
182
|
-
image = vision.image "path/to/face.jpg"
|
|
183
|
-
|
|
184
|
-
# Return just one face.
|
|
185
|
-
annotation = vision.annotate image, faces: 1
|
|
186
|
-
# Return up to 5 faces.
|
|
187
|
-
annotation = vision.annotate image, faces: 5
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Configuring timeout
|
|
191
|
-
|
|
192
|
-
You can configure the request `timeout` value in seconds.
|
|
193
|
-
|
|
194
|
-
```ruby
|
|
195
|
-
require "google/cloud/vision"
|
|
196
|
-
|
|
197
|
-
vision = Google::Cloud::Vision.new timeout: 120
|
|
198
|
-
```
|
|
199
|
-
## Additional information
|
|
200
|
-
|
|
201
|
-
Google Cloud Vision can be configured to use gRPC's logging. To learn more, see
|
|
202
|
-
the {file:LOGGING.md Logging guide}.
|