google-cloud-vision 0.20.2 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google-cloud-vision.rb +14 -26
- data/lib/google/cloud/vision.rb +108 -91
- data/lib/google/cloud/vision/annotate.rb +23 -25
- data/lib/google/cloud/vision/annotation.rb +58 -77
- data/lib/google/cloud/vision/annotation/entity.rb +24 -27
- data/lib/google/cloud/vision/annotation/face.rb +131 -148
- data/lib/google/cloud/vision/annotation/properties.rb +25 -27
- data/lib/google/cloud/vision/annotation/safe_search.rb +13 -14
- data/lib/google/cloud/vision/annotation/text.rb +27 -29
- data/lib/google/cloud/vision/annotation/vertex.rb +4 -5
- data/lib/google/cloud/vision/image.rb +39 -46
- data/lib/google/cloud/vision/location.rb +8 -9
- data/lib/google/cloud/vision/project.rb +31 -37
- data/lib/google/cloud/vision/service.rb +46 -21
- data/lib/google/cloud/vision/v1/image_annotator_api.rb +22 -6
- data/lib/google/cloud/vision/version.rb +1 -1
- metadata +63 -7
@@ -26,10 +26,9 @@ module Google
|
|
26
26
|
# See {Google::Cloud::Vision::Image#properties}.
|
27
27
|
#
|
28
28
|
# @example
|
29
|
-
# require "google/cloud"
|
29
|
+
# require "google/cloud/vision"
|
30
30
|
#
|
31
|
-
#
|
32
|
-
# vision = gcloud.vision
|
31
|
+
# vision = Google::Cloud::Vision.new
|
33
32
|
#
|
34
33
|
# image = vision.image "path/to/logo.jpg"
|
35
34
|
#
|
@@ -38,13 +37,13 @@ module Google
|
|
38
37
|
#
|
39
38
|
class Properties
|
40
39
|
##
|
41
|
-
# @private The ImageProperties
|
42
|
-
attr_accessor :
|
40
|
+
# @private The ImageProperties GRPC object.
|
41
|
+
attr_accessor :grpc
|
43
42
|
|
44
43
|
##
|
45
44
|
# @private Creates a new Properties instance.
|
46
45
|
def initialize
|
47
|
-
@
|
46
|
+
@grpc = nil
|
48
47
|
end
|
49
48
|
|
50
49
|
##
|
@@ -53,9 +52,9 @@ module Google
|
|
53
52
|
# @return [Array<Color>] An array of the image's dominant colors.
|
54
53
|
#
|
55
54
|
def colors
|
56
|
-
return [] unless @
|
57
|
-
@colors ||= Array(@
|
58
|
-
Color.
|
55
|
+
return [] unless @grpc.dominant_colors
|
56
|
+
@colors ||= Array(@grpc.dominant_colors.colors).map do |c|
|
57
|
+
Color.from_grpc c
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
@@ -88,9 +87,9 @@ module Google
|
|
88
87
|
end
|
89
88
|
|
90
89
|
##
|
91
|
-
# @private New Annotation::Properties from a
|
92
|
-
def self.
|
93
|
-
new.tap { |f| f.instance_variable_set :@
|
90
|
+
# @private New Annotation::Properties from a GRPC object.
|
91
|
+
def self.from_grpc grpc
|
92
|
+
new.tap { |f| f.instance_variable_set :@grpc, grpc }
|
94
93
|
end
|
95
94
|
|
96
95
|
##
|
@@ -100,10 +99,9 @@ module Google
|
|
100
99
|
# image the color occupies in the image.
|
101
100
|
#
|
102
101
|
# @example
|
103
|
-
# require "google/cloud"
|
102
|
+
# require "google/cloud/vision"
|
104
103
|
#
|
105
|
-
#
|
106
|
-
# vision = gcloud.vision
|
104
|
+
# vision = Google::Cloud::Vision.new
|
107
105
|
#
|
108
106
|
# image = vision.image "path/to/logo.jpg"
|
109
107
|
# properties = image.properties
|
@@ -119,13 +117,13 @@ module Google
|
|
119
117
|
#
|
120
118
|
class Color
|
121
119
|
##
|
122
|
-
# @private The ColorInfo
|
123
|
-
attr_accessor :
|
120
|
+
# @private The ColorInfo GRPC object.
|
121
|
+
attr_accessor :grpc
|
124
122
|
|
125
123
|
##
|
126
124
|
# @private Creates a new Color instance.
|
127
125
|
def initialize
|
128
|
-
@
|
126
|
+
@grpc = nil
|
129
127
|
end
|
130
128
|
|
131
129
|
##
|
@@ -134,7 +132,7 @@ module Google
|
|
134
132
|
# @return [Float] A value in the interval [0, 255].
|
135
133
|
#
|
136
134
|
def red
|
137
|
-
@
|
135
|
+
@grpc.color.red
|
138
136
|
end
|
139
137
|
|
140
138
|
##
|
@@ -143,7 +141,7 @@ module Google
|
|
143
141
|
# @return [Float] A value in the interval [0, 255].
|
144
142
|
#
|
145
143
|
def green
|
146
|
-
@
|
144
|
+
@grpc.color.green
|
147
145
|
end
|
148
146
|
|
149
147
|
##
|
@@ -152,7 +150,7 @@ module Google
|
|
152
150
|
# @return [Float] A value in the interval [0, 255].
|
153
151
|
#
|
154
152
|
def blue
|
155
|
-
@
|
153
|
+
@grpc.color.blue
|
156
154
|
end
|
157
155
|
|
158
156
|
##
|
@@ -163,7 +161,7 @@ module Google
|
|
163
161
|
# @return [Float] A value in the range [0, 1].
|
164
162
|
#
|
165
163
|
def alpha
|
166
|
-
@
|
164
|
+
@grpc.color.alpha || 1.0
|
167
165
|
end
|
168
166
|
|
169
167
|
def rgb
|
@@ -178,7 +176,7 @@ module Google
|
|
178
176
|
# @return [Float] A value in the range [0, 1].
|
179
177
|
#
|
180
178
|
def score
|
181
|
-
@
|
179
|
+
@grpc.score
|
182
180
|
end
|
183
181
|
|
184
182
|
##
|
@@ -187,7 +185,7 @@ module Google
|
|
187
185
|
# @return [Float] A value in the range [0, 1].
|
188
186
|
#
|
189
187
|
def pixel_fraction
|
190
|
-
@
|
188
|
+
@grpc.pixel_fraction
|
191
189
|
end
|
192
190
|
|
193
191
|
##
|
@@ -209,10 +207,10 @@ module Google
|
|
209
207
|
end
|
210
208
|
|
211
209
|
##
|
212
|
-
# @private New Annotation::Properties from a
|
210
|
+
# @private New Annotation::Properties from a GRPC
|
213
211
|
# object.
|
214
|
-
def self.
|
215
|
-
new.tap { |f| f.instance_variable_set :@
|
212
|
+
def self.from_grpc grpc
|
213
|
+
new.tap { |f| f.instance_variable_set :@grpc, grpc }
|
216
214
|
end
|
217
215
|
end
|
218
216
|
end
|
@@ -27,10 +27,9 @@ module Google
|
|
27
27
|
# adult, spoof, medical, violence).
|
28
28
|
#
|
29
29
|
# @example
|
30
|
-
# require "google/cloud"
|
30
|
+
# require "google/cloud/vision"
|
31
31
|
#
|
32
|
-
#
|
33
|
-
# vision = gcloud.vision
|
32
|
+
# vision = Google::Cloud::Vision.new
|
34
33
|
#
|
35
34
|
# image = vision.image "path/to/face.jpg"
|
36
35
|
#
|
@@ -39,23 +38,23 @@ module Google
|
|
39
38
|
# safe_search.spoof #=> "VERY_UNLIKELY"
|
40
39
|
#
|
41
40
|
class SafeSearch
|
42
|
-
POSITIVE_RATINGS = %
|
41
|
+
POSITIVE_RATINGS = %i(POSSIBLE LIKELY VERY_LIKELY)
|
43
42
|
|
44
43
|
##
|
45
|
-
# @private The SafeSearchAnnotation
|
46
|
-
attr_accessor :
|
44
|
+
# @private The SafeSearchAnnotation GRPC object.
|
45
|
+
attr_accessor :grpc
|
47
46
|
|
48
47
|
##
|
49
48
|
# @private Creates a new SafeSearch instance.
|
50
49
|
def initialize
|
51
|
-
@
|
50
|
+
@grpc = nil
|
52
51
|
end
|
53
52
|
|
54
53
|
##
|
55
54
|
# Adult likelihood rating. Possible values are `VERY_UNLIKELY`,
|
56
55
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
57
56
|
def adult
|
58
|
-
@
|
57
|
+
@grpc.adult
|
59
58
|
end
|
60
59
|
|
61
60
|
##
|
@@ -72,7 +71,7 @@ module Google
|
|
72
71
|
# Spoof likelihood rating. Possible values are `VERY_UNLIKELY`,
|
73
72
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
74
73
|
def spoof
|
75
|
-
@
|
74
|
+
@grpc.spoof
|
76
75
|
end
|
77
76
|
|
78
77
|
##
|
@@ -89,7 +88,7 @@ module Google
|
|
89
88
|
# Medical likelihood rating. Possible values are `VERY_UNLIKELY`,
|
90
89
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
91
90
|
def medical
|
92
|
-
@
|
91
|
+
@grpc.medical
|
93
92
|
end
|
94
93
|
|
95
94
|
##
|
@@ -106,7 +105,7 @@ module Google
|
|
106
105
|
# Violence likelihood rating. Possible values are `VERY_UNLIKELY`,
|
107
106
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
108
107
|
def violence
|
109
|
-
@
|
108
|
+
@grpc.violence
|
110
109
|
end
|
111
110
|
|
112
111
|
##
|
@@ -143,9 +142,9 @@ module Google
|
|
143
142
|
end
|
144
143
|
|
145
144
|
##
|
146
|
-
# @private New Annotation::SafeSearch from a
|
147
|
-
def self.
|
148
|
-
new.tap { |f| f.instance_variable_set :@
|
145
|
+
# @private New Annotation::SafeSearch from a GRPC object.
|
146
|
+
def self.from_grpc grpc
|
147
|
+
new.tap { |f| f.instance_variable_set :@grpc, grpc }
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
@@ -25,10 +25,9 @@ module Google
|
|
25
25
|
# The result of text, or optical character recognition (OCR), detection.
|
26
26
|
#
|
27
27
|
# @example
|
28
|
-
# require "google/cloud"
|
28
|
+
# require "google/cloud/vision"
|
29
29
|
#
|
30
|
-
#
|
31
|
-
# vision = gcloud.vision
|
30
|
+
# vision = Google::Cloud::Vision.new
|
32
31
|
#
|
33
32
|
# image = vision.image "path/to/text.png"
|
34
33
|
#
|
@@ -40,13 +39,13 @@ module Google
|
|
40
39
|
#
|
41
40
|
class Text
|
42
41
|
##
|
43
|
-
# @private The EntityAnnotation
|
44
|
-
attr_accessor :
|
42
|
+
# @private The EntityAnnotation GRPC object.
|
43
|
+
attr_accessor :grpc
|
45
44
|
|
46
45
|
##
|
47
46
|
# @private Creates a new Text instance.
|
48
47
|
def initialize
|
49
|
-
@
|
48
|
+
@grpc = nil
|
50
49
|
@words = []
|
51
50
|
end
|
52
51
|
|
@@ -56,7 +55,7 @@ module Google
|
|
56
55
|
# @return [String] The entire text including newline characters.
|
57
56
|
#
|
58
57
|
def text
|
59
|
-
@
|
58
|
+
@grpc.description
|
60
59
|
end
|
61
60
|
|
62
61
|
##
|
@@ -67,7 +66,7 @@ module Google
|
|
67
66
|
# language code.
|
68
67
|
#
|
69
68
|
def locale
|
70
|
-
@
|
69
|
+
@grpc.locale
|
71
70
|
end
|
72
71
|
|
73
72
|
##
|
@@ -76,9 +75,9 @@ module Google
|
|
76
75
|
# @return [Array<Vertex>]
|
77
76
|
#
|
78
77
|
def bounds
|
79
|
-
return [] unless @
|
80
|
-
@bounds ||= Array(@
|
81
|
-
Vertex.
|
78
|
+
return [] unless @grpc.bounding_poly
|
79
|
+
@bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|
|
80
|
+
Vertex.from_grpc v
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -118,15 +117,15 @@ module Google
|
|
118
117
|
end
|
119
118
|
|
120
119
|
##
|
121
|
-
# @private New Annotation::Text from an array of
|
120
|
+
# @private New Annotation::Text from an array of GRPC
|
122
121
|
# objects.
|
123
|
-
def self.
|
124
|
-
text, *words = Array
|
122
|
+
def self.from_grpc grpc_list
|
123
|
+
text, *words = Array grpc_list
|
125
124
|
return nil if text.nil?
|
126
125
|
new.tap do |t|
|
127
|
-
t.instance_variable_set :@
|
126
|
+
t.instance_variable_set :@grpc, text
|
128
127
|
t.instance_variable_set :@words,
|
129
|
-
words.map { |w| Word.
|
128
|
+
words.map { |w| Word.from_grpc w }
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
@@ -136,10 +135,9 @@ module Google
|
|
136
135
|
# A word within a detected text (OCR). See {Text}.
|
137
136
|
#
|
138
137
|
# @example
|
139
|
-
# require "google/cloud"
|
138
|
+
# require "google/cloud/vision"
|
140
139
|
#
|
141
|
-
#
|
142
|
-
# vision = gcloud.vision
|
140
|
+
# vision = Google::Cloud::Vision.new
|
143
141
|
#
|
144
142
|
# image = vision.image "path/to/text.png"
|
145
143
|
# text = image.text
|
@@ -154,13 +152,13 @@ module Google
|
|
154
152
|
#
|
155
153
|
class Word
|
156
154
|
##
|
157
|
-
# @private The EntityAnnotation
|
158
|
-
attr_accessor :
|
155
|
+
# @private The EntityAnnotation GRPC object.
|
156
|
+
attr_accessor :grpc
|
159
157
|
|
160
158
|
##
|
161
159
|
# @private Creates a new Word instance.
|
162
160
|
def initialize
|
163
|
-
@
|
161
|
+
@grpc = nil
|
164
162
|
end
|
165
163
|
|
166
164
|
##
|
@@ -169,7 +167,7 @@ module Google
|
|
169
167
|
# @return [String]
|
170
168
|
#
|
171
169
|
def text
|
172
|
-
@
|
170
|
+
@grpc.description
|
173
171
|
end
|
174
172
|
|
175
173
|
##
|
@@ -178,9 +176,9 @@ module Google
|
|
178
176
|
# @return [Array<Vertex>]
|
179
177
|
#
|
180
178
|
def bounds
|
181
|
-
return [] unless @
|
182
|
-
@bounds ||= Array(@
|
183
|
-
Vertex.
|
179
|
+
return [] unless @grpc.bounding_poly
|
180
|
+
@bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|
|
181
|
+
Vertex.from_grpc v
|
184
182
|
end
|
185
183
|
end
|
186
184
|
|
@@ -209,10 +207,10 @@ module Google
|
|
209
207
|
end
|
210
208
|
|
211
209
|
##
|
212
|
-
# @private New Annotation::Text::Word from a
|
210
|
+
# @private New Annotation::Text::Word from a GRPC
|
213
211
|
# object.
|
214
|
-
def self.
|
215
|
-
new.tap { |w| w.instance_variable_set :@
|
212
|
+
def self.from_grpc grpc
|
213
|
+
new.tap { |w| w.instance_variable_set :@grpc, grpc }
|
216
214
|
end
|
217
215
|
end
|
218
216
|
end
|
@@ -28,10 +28,9 @@ module Google
|
|
28
28
|
# @attr_reader [Integer] y The Y coordinate.
|
29
29
|
#
|
30
30
|
# @example
|
31
|
-
# require "google/cloud"
|
31
|
+
# require "google/cloud/vision"
|
32
32
|
#
|
33
|
-
#
|
34
|
-
# vision = gcloud.vision
|
33
|
+
# vision = Google::Cloud::Vision.new
|
35
34
|
#
|
36
35
|
# image = vision.image "path/to/text.png"
|
37
36
|
# text = image.text
|
@@ -82,8 +81,8 @@ module Google
|
|
82
81
|
##
|
83
82
|
# @private New Annotation::Entity::Bounds::Vertex from a Google API
|
84
83
|
# Client object.
|
85
|
-
def self.
|
86
|
-
new
|
84
|
+
def self.from_grpc grpc
|
85
|
+
new grpc.x, grpc.y
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
@@ -31,23 +31,22 @@ module Google
|
|
31
31
|
# The Cloud Vision API supports a variety of image file formats, including
|
32
32
|
# JPEG, PNG8, PNG24, Animated GIF (first frame only), and RAW. See [Best
|
33
33
|
# Practices - Image
|
34
|
-
# Types](https://cloud.google.com/vision/docs/
|
34
|
+
# Types](https://cloud.google.com/vision/docs/best-practices#image_types)
|
35
35
|
# for the list of formats. Be aware that Cloud Vision sets upper limits on
|
36
36
|
# file size as well as the total combined size of all images in a request.
|
37
37
|
# Reducing your file size can significantly improve throughput; however,
|
38
38
|
# be careful not to reduce image quality in the process. See [Best
|
39
39
|
# Practices - Image
|
40
|
-
# Sizing](https://cloud.google.com/vision/docs/
|
40
|
+
# Sizing](https://cloud.google.com/vision/docs/best-practices#image_sizing)
|
41
41
|
# for current file size limits.
|
42
42
|
#
|
43
|
-
# @see https://cloud.google.com/vision/docs/
|
43
|
+
# @see https://cloud.google.com/vision/docs/best-practices Best
|
44
44
|
# Practices
|
45
45
|
#
|
46
46
|
# @example
|
47
|
-
# require "google/cloud"
|
47
|
+
# require "google/cloud/vision"
|
48
48
|
#
|
49
|
-
#
|
50
|
-
# vision = gcloud.vision
|
49
|
+
# vision = Google::Cloud::Vision.new
|
51
50
|
#
|
52
51
|
# image = vision.image "path/to/text.png"
|
53
52
|
#
|
@@ -96,10 +95,9 @@ module Google
|
|
96
95
|
# @return [Array<Annotation::Face>] The results of face detection.
|
97
96
|
#
|
98
97
|
# @example
|
99
|
-
# require "google/cloud"
|
98
|
+
# require "google/cloud/vision"
|
100
99
|
#
|
101
|
-
#
|
102
|
-
# vision = gcloud.vision
|
100
|
+
# vision = Google::Cloud::Vision.new
|
103
101
|
# image = vision.image "path/to/face.jpg"
|
104
102
|
#
|
105
103
|
# faces = image.faces
|
@@ -135,10 +133,9 @@ module Google
|
|
135
133
|
# @return [Array<Annotation::Entity>] The results of landmark detection.
|
136
134
|
#
|
137
135
|
# @example
|
138
|
-
# require "google/cloud"
|
136
|
+
# require "google/cloud/vision"
|
139
137
|
#
|
140
|
-
#
|
141
|
-
# vision = gcloud.vision
|
138
|
+
# vision = Google::Cloud::Vision.new
|
142
139
|
# image = vision.image "path/to/landmark.jpg"
|
143
140
|
#
|
144
141
|
# landmarks = image.landmarks
|
@@ -175,10 +172,9 @@ module Google
|
|
175
172
|
# @return [Array<Annotation::Entity>] The results of logo detection.
|
176
173
|
#
|
177
174
|
# @example
|
178
|
-
# require "google/cloud"
|
175
|
+
# require "google/cloud/vision"
|
179
176
|
#
|
180
|
-
#
|
181
|
-
# vision = gcloud.vision
|
177
|
+
# vision = Google::Cloud::Vision.new
|
182
178
|
# image = vision.image "path/to/logo.jpg"
|
183
179
|
#
|
184
180
|
# logos = image.logos
|
@@ -215,10 +211,9 @@ module Google
|
|
215
211
|
# @return [Array<Annotation::Entity>] The results of label detection.
|
216
212
|
#
|
217
213
|
# @example
|
218
|
-
# require "google/cloud"
|
214
|
+
# require "google/cloud/vision"
|
219
215
|
#
|
220
|
-
#
|
221
|
-
# vision = gcloud.vision
|
216
|
+
# vision = Google::Cloud::Vision.new
|
222
217
|
# image = vision.image "path/to/face.jpg"
|
223
218
|
#
|
224
219
|
# labels = image.labels
|
@@ -253,10 +248,9 @@ module Google
|
|
253
248
|
# @return [Annotation::Text] The results of text (OCR) detection.
|
254
249
|
#
|
255
250
|
# @example
|
256
|
-
# require "google/cloud"
|
251
|
+
# require "google/cloud/vision"
|
257
252
|
#
|
258
|
-
#
|
259
|
-
# vision = gcloud.vision
|
253
|
+
# vision = Google::Cloud::Vision.new
|
260
254
|
# image = vision.image "path/to/text.png"
|
261
255
|
#
|
262
256
|
# text = image.text
|
@@ -281,10 +275,9 @@ module Google
|
|
281
275
|
# @return [Annotation::SafeSearch] The results of safe search detection.
|
282
276
|
#
|
283
277
|
# @example
|
284
|
-
# require "google/cloud"
|
278
|
+
# require "google/cloud/vision"
|
285
279
|
#
|
286
|
-
#
|
287
|
-
# vision = gcloud.vision
|
280
|
+
# vision = Google::Cloud::Vision.new
|
288
281
|
# image = vision.image "path/to/face.jpg"
|
289
282
|
#
|
290
283
|
# safe_search = image.safe_search
|
@@ -307,10 +300,9 @@ module Google
|
|
307
300
|
# detection.
|
308
301
|
#
|
309
302
|
# @example
|
310
|
-
# require "google/cloud"
|
303
|
+
# require "google/cloud/vision"
|
311
304
|
#
|
312
|
-
#
|
313
|
-
# vision = gcloud.vision
|
305
|
+
# vision = Google::Cloud::Vision.new
|
314
306
|
# image = vision.image "path/to/logo.jpg"
|
315
307
|
#
|
316
308
|
# properties = image.properties
|
@@ -345,13 +337,15 @@ module Google
|
|
345
337
|
end
|
346
338
|
|
347
339
|
##
|
348
|
-
# @private The
|
349
|
-
def
|
340
|
+
# @private The GRPC object for the Image.
|
341
|
+
def to_grpc
|
350
342
|
if io?
|
351
343
|
@io.rewind
|
352
|
-
Google::
|
344
|
+
Google::Cloud::Vision::V1::Image.new content: @io.read
|
353
345
|
elsif url?
|
354
|
-
Google::
|
346
|
+
Google::Cloud::Vision::V1::Image.new(
|
347
|
+
source: Google::Cloud::Vision::V1::ImageSource.new(
|
348
|
+
gcs_image_uri: @url))
|
355
349
|
else
|
356
350
|
fail ArgumentError, "Unable to use Image with Vision service."
|
357
351
|
end
|
@@ -430,10 +424,9 @@ module Google
|
|
430
424
|
# great deal if the hint is wrong).
|
431
425
|
#
|
432
426
|
# @example
|
433
|
-
# require "google/cloud"
|
427
|
+
# require "google/cloud/vision"
|
434
428
|
#
|
435
|
-
#
|
436
|
-
# vision = gcloud.vision
|
429
|
+
# vision = Google::Cloud::Vision.new
|
437
430
|
#
|
438
431
|
# image = vision.image "path/to/landmark.jpg"
|
439
432
|
# image.context.area.min = { longitude: -122.0862462,
|
@@ -468,12 +461,13 @@ module Google
|
|
468
461
|
|
469
462
|
##
|
470
463
|
# @private
|
471
|
-
def
|
464
|
+
def to_grpc
|
472
465
|
return nil if empty?
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
466
|
+
|
467
|
+
args = {}
|
468
|
+
args[:lat_long_rect] = area.to_grpc unless area.empty?
|
469
|
+
args[:language_hints] = languages unless languages.empty?
|
470
|
+
Google::Cloud::Vision::V1::ImageContext.new args
|
477
471
|
end
|
478
472
|
|
479
473
|
##
|
@@ -482,10 +476,9 @@ module Google
|
|
482
476
|
# A Lat/long rectangle that specifies the location of the image.
|
483
477
|
#
|
484
478
|
# @example
|
485
|
-
# require "google/cloud"
|
479
|
+
# require "google/cloud/vision"
|
486
480
|
#
|
487
|
-
#
|
488
|
-
# vision = gcloud.vision
|
481
|
+
# vision = Google::Cloud::Vision.new
|
489
482
|
#
|
490
483
|
# image = vision.image "path/to/landmark.jpg"
|
491
484
|
#
|
@@ -563,11 +556,11 @@ module Google
|
|
563
556
|
{ min_lat_lng: min.to_h, max_lat_lng: max.to_h }
|
564
557
|
end
|
565
558
|
|
566
|
-
def
|
559
|
+
def to_grpc
|
567
560
|
return nil if empty?
|
568
|
-
Google::
|
569
|
-
min_lat_lng: min.
|
570
|
-
max_lat_lng: max.
|
561
|
+
Google::Cloud::Vision::V1::LatLongRect.new(
|
562
|
+
min_lat_lng: min.to_grpc,
|
563
|
+
max_lat_lng: max.to_grpc
|
571
564
|
)
|
572
565
|
end
|
573
566
|
end
|