google-cloud-vision 0.31.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -9
  3. data/LICENSE +1 -1
  4. data/README.md +94 -0
  5. data/lib/google/cloud/vision.rb +200 -535
  6. data/lib/google/cloud/vision/v1.rb +129 -55
  7. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +9 -0
  8. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +88 -0
  9. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +539 -0
  10. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +3 -3
  11. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +2 -1
  12. data/lib/google/cloud/vision/{version.rb → v1/doc/google/protobuf/empty.rb} +13 -6
  13. data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +230 -0
  14. data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +109 -0
  15. data/lib/google/cloud/vision/v1/geometry_pb.rb +1 -0
  16. data/lib/google/cloud/vision/v1/helpers.rb +972 -0
  17. data/lib/google/cloud/vision/v1/image_annotator_client.rb +4 -4
  18. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +5 -0
  19. data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +2 -1
  20. data/lib/google/cloud/vision/v1/product_search_client.rb +1337 -0
  21. data/lib/google/cloud/vision/v1/product_search_client_config.json +116 -0
  22. data/lib/google/cloud/vision/v1/product_search_pb.rb +45 -0
  23. data/lib/google/cloud/vision/v1/product_search_service_pb.rb +191 -0
  24. data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +224 -0
  25. data/lib/google/cloud/vision/v1p3beta1.rb +233 -0
  26. data/lib/google/cloud/vision/v1p3beta1/credentials.rb +42 -0
  27. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +72 -0
  28. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +763 -0
  29. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +154 -0
  30. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +533 -0
  31. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +254 -0
  32. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +101 -0
  33. data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +93 -0
  34. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +130 -0
  35. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +29 -0
  36. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +230 -0
  37. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +109 -0
  38. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +90 -0
  39. data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +84 -0
  40. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +156 -0
  41. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +65 -0
  42. data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +43 -0
  43. data/lib/google/cloud/vision/v1p3beta1/helpers.rb +972 -0
  44. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +302 -0
  45. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +36 -0
  46. data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +304 -0
  47. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +55 -0
  48. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +1351 -0
  49. data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +116 -0
  50. data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +64 -0
  51. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +191 -0
  52. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +222 -0
  53. data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +94 -0
  54. data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +51 -0
  55. metadata +53 -122
  56. data/AUTHENTICATION.md +0 -179
  57. data/CHANGELOG.md +0 -109
  58. data/CODE_OF_CONDUCT.md +0 -40
  59. data/CONTRIBUTING.md +0 -188
  60. data/LOGGING.md +0 -32
  61. data/OVERVIEW.md +0 -202
  62. data/TROUBLESHOOTING.md +0 -37
  63. data/lib/google-cloud-vision.rb +0 -146
  64. data/lib/google/cloud/vision/annotate.rb +0 -303
  65. data/lib/google/cloud/vision/annotation.rb +0 -553
  66. data/lib/google/cloud/vision/annotation/crop_hint.rb +0 -126
  67. data/lib/google/cloud/vision/annotation/entity.rb +0 -225
  68. data/lib/google/cloud/vision/annotation/face.rb +0 -1497
  69. data/lib/google/cloud/vision/annotation/normalized_vertex.rb +0 -76
  70. data/lib/google/cloud/vision/annotation/object_localization.rb +0 -115
  71. data/lib/google/cloud/vision/annotation/properties.rb +0 -220
  72. data/lib/google/cloud/vision/annotation/safe_search.rb +0 -153
  73. data/lib/google/cloud/vision/annotation/text.rb +0 -1015
  74. data/lib/google/cloud/vision/annotation/vertex.rb +0 -91
  75. data/lib/google/cloud/vision/annotation/web.rb +0 -420
  76. data/lib/google/cloud/vision/credentials.rb +0 -57
  77. data/lib/google/cloud/vision/image.rb +0 -832
  78. data/lib/google/cloud/vision/location.rb +0 -98
  79. data/lib/google/cloud/vision/project.rb +0 -367
  80. data/lib/google/cloud/vision/service.rb +0 -83
@@ -1,91 +0,0 @@
1
- # Copyright 2016 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Cloud
18
- module Vision
19
- class Annotation
20
- ##
21
- # # Vertex
22
- #
23
- # A vertex in a set of bounding polygon vertices.
24
- #
25
- # See {Face::Bounds} and {Text}.
26
- #
27
- # @attr_reader [Integer] x The X coordinate.
28
- # @attr_reader [Integer] y The Y coordinate.
29
- #
30
- # @example
31
- # require "google/cloud/vision"
32
- #
33
- # vision = Google::Cloud::Vision.new
34
- #
35
- # image = vision.image "path/to/text.png"
36
- # text = image.text
37
- #
38
- # text.bounds.count #=> 4
39
- # vertex = text.bounds.first
40
- # vertex.x #=> 1
41
- # vertex.y #=> 0
42
- #
43
- class Vertex
44
- attr_reader :x, :y
45
-
46
- ##
47
- # @private Creates a new Vertex instance.
48
- def initialize x, y
49
- @x = x
50
- @y = y
51
- end
52
-
53
- ##
54
- # Returns the object's property values as an array.
55
- #
56
- # @return [Array]
57
- #
58
- def to_a
59
- [x, y]
60
- end
61
-
62
- ##
63
- # Converts object to a hash. All keys will be symbolized.
64
- #
65
- # @return [Hash]
66
- #
67
- def to_h
68
- { x: x, y: y }
69
- end
70
-
71
- # @private
72
- def to_s
73
- "(x: #{x.inspect}, y: #{y.inspect})"
74
- end
75
-
76
- # @private
77
- def inspect
78
- "#<Vertex #{self}>"
79
- end
80
-
81
- ##
82
- # @private New Annotation::Entity::Bounds::Vertex from a Google API
83
- # Client object.
84
- def self.from_grpc grpc
85
- new grpc.x, grpc.y
86
- end
87
- end
88
- end
89
- end
90
- end
91
- end
@@ -1,420 +0,0 @@
1
- # Copyright 2016 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- require "google/cloud/vision/annotation/vertex"
17
-
18
- module Google
19
- module Cloud
20
- module Vision
21
- class Annotation
22
- ##
23
- # # Web
24
- #
25
- # Relevant information for the image from the Internet.
26
- #
27
- # See {Annotation#web}.
28
- #
29
- # @example
30
- # require "google/cloud/vision"
31
- #
32
- # vision = Google::Cloud::Vision.new
33
- #
34
- # image = vision.image "path/to/landmark.jpg"
35
- #
36
- # web = image.web
37
- #
38
- # entity = web.entities.first
39
- # entity.entity_id #=> "/m/019dvv"
40
- # entity.score #=> 107.34591674804688
41
- # entity.description #=> "Mount Rushmore National Memorial"
42
- #
43
- # full_matching_image = web.full_matching_images.first
44
- # full_matching_image.url #=> "http://example.com/images/123.jpg"
45
- # full_matching_image.score #=> 0.10226666927337646
46
- #
47
- # page_with_matching_images = web.pages_with_matching_images.first
48
- # page_with_matching_images.url #=> "http://example.com/posts/123"
49
- # page_with_matching_images.score #=> 8.114753723144531
50
- #
51
- class Web
52
- ##
53
- # @private The WebDetection GRPC object.
54
- attr_accessor :grpc
55
-
56
- ##
57
- # @private Creates a new Web instance.
58
- def initialize
59
- @grpc = nil
60
- end
61
-
62
- ##
63
- # Deduced entities from similar images on the Internet.
64
- #
65
- # @return [Array<Google::Cloud::Vision::Annotation::Web::Entity>]
66
- #
67
- def entities
68
- @entities ||= Array(@grpc.web_entities).map do |e|
69
- Entity.from_grpc e
70
- end
71
- end
72
-
73
- ##
74
- # Fully matching images from the Internet. They're definite neardups
75
- # and most often a copy of the query image with merely a size change.
76
- #
77
- # @return [Array<Google::Cloud::Vision::Annotation::Web::Image>]
78
- #
79
- def full_matching_images
80
- images = @grpc.full_matching_images
81
- @full_matching_images ||= Array(images).map do |i|
82
- Image.from_grpc i
83
- end
84
- end
85
-
86
- ##
87
- # Partial matching images from the Internet. Those images are similar
88
- # enough to share some key-point features. For example an original
89
- # image will likely have partial matching for its crops.
90
- #
91
- # @return [Array<Google::Cloud::Vision::Annotation::Web::Image>]
92
- #
93
- def partial_matching_images
94
- images = @grpc.partial_matching_images
95
- @partial_matching_images ||= Array(images).map do |i|
96
- Image.from_grpc i
97
- end
98
- end
99
-
100
- ##
101
- # Web pages containing the matching images from the Internet.
102
- #
103
- # @return [Array<Google::Cloud::Vision::Annotation::Web::Page>]
104
- #
105
- def pages_with_matching_images
106
- pages = @grpc.pages_with_matching_images
107
- @pages_with_matching_images ||= Array(pages).map do |p|
108
- Page.from_grpc p
109
- end
110
- end
111
-
112
- ##
113
- # Deeply converts object to a hash. All keys will be symbolized.
114
- #
115
- # @return [Hash]
116
- #
117
- def to_h
118
- {
119
- entities: entities.map(&:to_h),
120
- full_matching_images: full_matching_images.map(&:to_h),
121
- partial_matching_images: partial_matching_images.map(&:to_h),
122
- pages_with_matching_images: pages_with_matching_images.map(&:to_h)
123
- }
124
- end
125
-
126
- # @private
127
- def to_s
128
- # Keep console output low by not showing all sub-objects.
129
- format "(entities: %i, full_matching_images: %i," \
130
- " partial_matching_images: %i," \
131
- " pages_with_matching_images: %i)",
132
- entities.count, full_matching_images.count,
133
- partial_matching_images.count,
134
- pages_with_matching_images.count
135
- end
136
-
137
- # @private
138
- def inspect
139
- "#<#{self.class.name} #{self}>"
140
- end
141
-
142
- ##
143
- # @private New Annotation::Face from a GRPC object.
144
- def self.from_grpc grpc
145
- new.tap { |f| f.instance_variable_set :@grpc, grpc }
146
- end
147
-
148
- ##
149
- # # Entity
150
- #
151
- # Entity deduced from similar images on the Internet.
152
- #
153
- # See {Web}.
154
- #
155
- # @example
156
- # require "google/cloud/vision"
157
- #
158
- # vision = Google::Cloud::Vision.new
159
- #
160
- # image = vision.image "path/to/landmark.jpg"
161
- #
162
- # web = image.web
163
- #
164
- # entity = web.entities.first
165
- # entity.entity_id #=> "/m/019dvv"
166
- # entity.score #=> 107.34591674804688
167
- # entity.description #=> "Mount Rushmore National Memorial"
168
- #
169
- class Entity
170
- ##
171
- # @private The WebEntity GRPC object.
172
- attr_accessor :grpc
173
-
174
- ##
175
- # @private Creates a new Entity instance.
176
- def initialize
177
- @grpc = nil
178
- end
179
-
180
- ##
181
- # Opaque entity ID.
182
- #
183
- # @return [String]
184
- #
185
- def entity_id
186
- @grpc.entity_id
187
- end
188
-
189
- ##
190
- # Overall relevancy score for the entity. Not normalized and not
191
- # comparable across different image queries.
192
- #
193
- # @return [Float]
194
- #
195
- def score
196
- @grpc.score
197
- end
198
-
199
- ##
200
- # Canonical description of the entity, in English.
201
- #
202
- # @return [String]
203
- #
204
- def description
205
- @grpc.description
206
- end
207
-
208
- ##
209
- # Returns the object's property values as an array.
210
- #
211
- # @return [Array]
212
- #
213
- def to_a
214
- [entity_id, score, description]
215
- end
216
-
217
- ##
218
- # Converts object to a hash. All keys will be symbolized.
219
- #
220
- # @return [Hash]
221
- #
222
- def to_h
223
- { entity_id: entity_id, score: score, description: description }
224
- end
225
-
226
- # @private
227
- def to_s
228
- format "(entity_id: %s, score: %s, description: %s)",
229
- entity_id.inspect, score.inspect, description.inspect
230
- end
231
-
232
- # @private
233
- def inspect
234
- "#<Web::Entity #{self}>"
235
- end
236
-
237
- ##
238
- # @private New Google::Cloud::Vision::Annotation::Web::Entity from
239
- # a GRPC object.
240
- def self.from_grpc grpc
241
- new.tap { |f| f.instance_variable_set :@grpc, grpc }
242
- end
243
- end
244
-
245
- ##
246
- # # Image
247
- #
248
- # Metadata for online images.
249
- #
250
- # See {Web}.
251
- #
252
- # @example
253
- # require "google/cloud/vision"
254
- #
255
- # vision = Google::Cloud::Vision.new
256
- #
257
- # image = vision.image "path/to/landmark.jpg"
258
- #
259
- # web = image.web
260
- #
261
- # full_matching_image = web.full_matching_images.first
262
- # full_matching_image.url #=> "http://example.com/images/123.jpg"
263
- # full_matching_image.score #=> 0.10226666927337646
264
- #
265
- class Image
266
- ##
267
- # @private The WebImage GRPC object.
268
- attr_accessor :grpc
269
-
270
- ##
271
- # @private Creates a new Image instance.
272
- def initialize
273
- @grpc = nil
274
- end
275
-
276
- ##
277
- # The result image URL.
278
- #
279
- # @return [String]
280
- #
281
- def url
282
- @grpc.url
283
- end
284
-
285
- ##
286
- # Overall relevancy score for the image. Not normalized and not
287
- # comparable across different image queries.
288
- #
289
- # @return [Float]
290
- #
291
- def score
292
- @grpc.score
293
- end
294
-
295
- ##
296
- # Returns the object's property values as an array.
297
- #
298
- # @return [Array]
299
- #
300
- def to_a
301
- [url, score]
302
- end
303
-
304
- ##
305
- # Converts object to a hash. All keys will be symbolized.
306
- #
307
- # @return [Hash]
308
- #
309
- def to_h
310
- { url: url, score: score }
311
- end
312
-
313
- # @private
314
- def to_s
315
- format "(url: %s, score: %s)", url.inspect, score.inspect
316
- end
317
-
318
- # @private
319
- def inspect
320
- "#<Web::Image #{self}>"
321
- end
322
-
323
- ##
324
- # @private New Google::Cloud::Vision::Annotation::Web::Image from
325
- # a GRPC object.
326
- def self.from_grpc grpc
327
- new.tap { |f| f.instance_variable_set :@grpc, grpc }
328
- end
329
- end
330
-
331
- ##
332
- # # Page
333
- #
334
- # Metadata for web pages.
335
- #
336
- # See {Web}.
337
- #
338
- # @example
339
- # require "google/cloud/vision"
340
- #
341
- # vision = Google::Cloud::Vision.new
342
- #
343
- # image = vision.image "path/to/landmark.jpg"
344
- #
345
- # web = image.web
346
- #
347
- # page_with_matching_images = web.pages_with_matching_images.first
348
- # page_with_matching_images.url #=> "http://example.com/posts/123"
349
- # page_with_matching_images.score #=> 8.114753723144531
350
- #
351
- class Page
352
- ##
353
- # @private The WebPage GRPC object.
354
- attr_accessor :grpc
355
-
356
- ##
357
- # @private Creates a new Page instance.
358
- def initialize
359
- @grpc = nil
360
- end
361
-
362
- ##
363
- # The result web page URL.
364
- #
365
- # @return [String]
366
- #
367
- def url
368
- @grpc.url
369
- end
370
-
371
- ##
372
- # Overall relevancy score for the web page. Not normalized and not
373
- # comparable across different image queries.
374
- #
375
- # @return [Float]
376
- #
377
- def score
378
- @grpc.score
379
- end
380
-
381
- ##
382
- # Returns the object's property values as an array.
383
- #
384
- # @return [Array]
385
- #
386
- def to_a
387
- [url, score]
388
- end
389
-
390
- ##
391
- # Converts object to a hash. All keys will be symbolized.
392
- #
393
- # @return [Hash]
394
- #
395
- def to_h
396
- { url: url, score: score }
397
- end
398
-
399
- # @private
400
- def to_s
401
- format "(url: %s, score: %s)", url.inspect, score.inspect
402
- end
403
-
404
- # @private
405
- def inspect
406
- "#<Web::Page #{self}>"
407
- end
408
-
409
- ##
410
- # @private New Google::Cloud::Vision::Annotation::Web::Page from
411
- # a GRPC object.
412
- def self.from_grpc grpc
413
- new.tap { |f| f.instance_variable_set :@grpc, grpc }
414
- end
415
- end
416
- end
417
- end
418
- end
419
- end
420
- end