google-cloud-vision 0.38.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/AUTHENTICATION.md +51 -59
- data/LICENSE.md +203 -0
- data/MIGRATING.md +343 -0
- data/README.md +35 -49
- data/lib/{google/cloud/vision/v1/doc/google/protobuf/wrappers.rb → google-cloud-vision.rb} +4 -11
- data/lib/google/cloud/vision.rb +131 -214
- data/lib/google/cloud/vision/version.rb +6 -2
- metadata +73 -101
- data/LICENSE +0 -201
- data/lib/google/cloud/vision/v1.rb +0 -249
- data/lib/google/cloud/vision/v1/credentials.rb +0 -42
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +0 -66
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +0 -923
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +0 -115
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +0 -569
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +0 -254
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +0 -102
- data/lib/google/cloud/vision/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/vision/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/vision/v1/doc/google/type/color.rb +0 -161
- data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/vision/v1/geometry_pb.rb +0 -39
- data/lib/google/cloud/vision/v1/helpers.rb +0 -1154
- data/lib/google/cloud/vision/v1/image_annotator_client.rb +0 -519
- data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -46
- data/lib/google/cloud/vision/v1/image_annotator_pb.rb +0 -344
- data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +0 -74
- data/lib/google/cloud/vision/v1/product_search_client.rb +0 -1493
- data/lib/google/cloud/vision/v1/product_search_client_config.json +0 -121
- data/lib/google/cloud/vision/v1/product_search_pb.rb +0 -54
- data/lib/google/cloud/vision/v1/product_search_service_pb.rb +0 -207
- data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +0 -233
- data/lib/google/cloud/vision/v1/text_annotation_pb.rb +0 -94
- data/lib/google/cloud/vision/v1/web_detection_pb.rb +0 -51
- data/lib/google/cloud/vision/v1p3beta1.rb +0 -249
- data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -156
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -536
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -255
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
- data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -26
- data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -161
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
- data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -315
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +0 -36
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +0 -306
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -56
- data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1418
- data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
- data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -65
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -194
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -223
- data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
- data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
@@ -1,519 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
# EDITING INSTRUCTIONS
|
16
|
-
# This file was generated from the file
|
17
|
-
# https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto,
|
18
|
-
# and updates to that file get reflected here through a refresh process.
|
19
|
-
# For the short term, the refresh process will only be runnable by Google
|
20
|
-
# engineers.
|
21
|
-
|
22
|
-
|
23
|
-
require "json"
|
24
|
-
require "pathname"
|
25
|
-
|
26
|
-
require "google/gax"
|
27
|
-
require "google/gax/operation"
|
28
|
-
require "google/longrunning/operations_client"
|
29
|
-
|
30
|
-
require "google/cloud/vision/v1/image_annotator_pb"
|
31
|
-
require "google/cloud/vision/v1/credentials"
|
32
|
-
require "google/cloud/vision/version"
|
33
|
-
|
34
|
-
module Google
|
35
|
-
module Cloud
|
36
|
-
module Vision
|
37
|
-
module V1
|
38
|
-
# Service that performs Google Cloud Vision API detection tasks over client
|
39
|
-
# images, such as face, landmark, logo, label, and text detection. The
|
40
|
-
# ImageAnnotator service returns detected entities from the images.
|
41
|
-
#
|
42
|
-
# @!attribute [r] image_annotator_stub
|
43
|
-
# @return [Google::Cloud::Vision::V1::ImageAnnotator::Stub]
|
44
|
-
class ImageAnnotatorClient
|
45
|
-
# @private
|
46
|
-
attr_reader :image_annotator_stub
|
47
|
-
|
48
|
-
# The default address of the service.
|
49
|
-
SERVICE_ADDRESS = "vision.googleapis.com".freeze
|
50
|
-
|
51
|
-
# The default port of the service.
|
52
|
-
DEFAULT_SERVICE_PORT = 443
|
53
|
-
|
54
|
-
# The default set of gRPC interceptors.
|
55
|
-
GRPC_INTERCEPTORS = []
|
56
|
-
|
57
|
-
DEFAULT_TIMEOUT = 30
|
58
|
-
|
59
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
60
|
-
# this service.
|
61
|
-
ALL_SCOPES = [
|
62
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
63
|
-
"https://www.googleapis.com/auth/cloud-vision"
|
64
|
-
].freeze
|
65
|
-
|
66
|
-
# @private
|
67
|
-
class OperationsClient < Google::Longrunning::OperationsClient
|
68
|
-
self::SERVICE_ADDRESS = ImageAnnotatorClient::SERVICE_ADDRESS
|
69
|
-
self::GRPC_INTERCEPTORS = ImageAnnotatorClient::GRPC_INTERCEPTORS
|
70
|
-
end
|
71
|
-
|
72
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
73
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
74
|
-
# be many types.
|
75
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
76
|
-
# authenticating requests made by this client.
|
77
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
78
|
-
# credentials for this client.
|
79
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
80
|
-
# credentials for this client.
|
81
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
82
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
83
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
84
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
85
|
-
# metadata for requests, generally, to give OAuth credentials.
|
86
|
-
# @param scopes [Array<String>]
|
87
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
88
|
-
# an updater_proc is supplied.
|
89
|
-
# @param client_config [Hash]
|
90
|
-
# A Hash for call options for each method. See
|
91
|
-
# Google::Gax#construct_settings for the structure of
|
92
|
-
# this data. Falls back to the default config if not specified
|
93
|
-
# or the specified config is missing data points.
|
94
|
-
# @param timeout [Numeric]
|
95
|
-
# The default timeout, in seconds, for calls made through this client.
|
96
|
-
# @param metadata [Hash]
|
97
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
98
|
-
# @param service_address [String]
|
99
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
100
|
-
# @param service_port [Integer]
|
101
|
-
# Override for the service port, or `nil` to leave as the default.
|
102
|
-
# @param exception_transformer [Proc]
|
103
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
104
|
-
# custom error handling.
|
105
|
-
def initialize \
|
106
|
-
credentials: nil,
|
107
|
-
scopes: ALL_SCOPES,
|
108
|
-
client_config: {},
|
109
|
-
timeout: DEFAULT_TIMEOUT,
|
110
|
-
metadata: nil,
|
111
|
-
service_address: nil,
|
112
|
-
service_port: nil,
|
113
|
-
exception_transformer: nil,
|
114
|
-
lib_name: nil,
|
115
|
-
lib_version: ""
|
116
|
-
# These require statements are intentionally placed here to initialize
|
117
|
-
# the gRPC module only when it's required.
|
118
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
119
|
-
require "google/gax/grpc"
|
120
|
-
require "google/cloud/vision/v1/image_annotator_services_pb"
|
121
|
-
|
122
|
-
credentials ||= Google::Cloud::Vision::V1::Credentials.default
|
123
|
-
|
124
|
-
@operations_client = OperationsClient.new(
|
125
|
-
credentials: credentials,
|
126
|
-
scopes: scopes,
|
127
|
-
client_config: client_config,
|
128
|
-
timeout: timeout,
|
129
|
-
lib_name: lib_name,
|
130
|
-
service_address: service_address,
|
131
|
-
service_port: service_port,
|
132
|
-
lib_version: lib_version,
|
133
|
-
metadata: metadata,
|
134
|
-
)
|
135
|
-
|
136
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
137
|
-
updater_proc = Google::Cloud::Vision::V1::Credentials.new(credentials).updater_proc
|
138
|
-
end
|
139
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
140
|
-
channel = credentials
|
141
|
-
end
|
142
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
143
|
-
chan_creds = credentials
|
144
|
-
end
|
145
|
-
if credentials.is_a?(Proc)
|
146
|
-
updater_proc = credentials
|
147
|
-
end
|
148
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
149
|
-
updater_proc = credentials.updater_proc
|
150
|
-
end
|
151
|
-
|
152
|
-
package_version = Google::Cloud::Vision::VERSION
|
153
|
-
|
154
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
155
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
156
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
157
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
158
|
-
google_api_client.freeze
|
159
|
-
|
160
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
161
|
-
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
162
|
-
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
163
|
-
end
|
164
|
-
headers.merge!(metadata) unless metadata.nil?
|
165
|
-
client_config_file = Pathname.new(__dir__).join(
|
166
|
-
"image_annotator_client_config.json"
|
167
|
-
)
|
168
|
-
defaults = client_config_file.open do |f|
|
169
|
-
Google::Gax.construct_settings(
|
170
|
-
"google.cloud.vision.v1.ImageAnnotator",
|
171
|
-
JSON.parse(f.read),
|
172
|
-
client_config,
|
173
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
174
|
-
timeout,
|
175
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
176
|
-
metadata: headers
|
177
|
-
)
|
178
|
-
end
|
179
|
-
|
180
|
-
# Allow overriding the service path/port in subclasses.
|
181
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
182
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
183
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
184
|
-
@image_annotator_stub = Google::Gax::Grpc.create_stub(
|
185
|
-
service_path,
|
186
|
-
port,
|
187
|
-
chan_creds: chan_creds,
|
188
|
-
channel: channel,
|
189
|
-
updater_proc: updater_proc,
|
190
|
-
scopes: scopes,
|
191
|
-
interceptors: interceptors,
|
192
|
-
&Google::Cloud::Vision::V1::ImageAnnotator::Stub.method(:new)
|
193
|
-
)
|
194
|
-
|
195
|
-
@batch_annotate_images = Google::Gax.create_api_call(
|
196
|
-
@image_annotator_stub.method(:batch_annotate_images),
|
197
|
-
defaults["batch_annotate_images"],
|
198
|
-
exception_transformer: exception_transformer,
|
199
|
-
params_extractor: proc do |request|
|
200
|
-
{'parent' => request.parent}
|
201
|
-
end
|
202
|
-
)
|
203
|
-
@batch_annotate_files = Google::Gax.create_api_call(
|
204
|
-
@image_annotator_stub.method(:batch_annotate_files),
|
205
|
-
defaults["batch_annotate_files"],
|
206
|
-
exception_transformer: exception_transformer,
|
207
|
-
params_extractor: proc do |request|
|
208
|
-
{'parent' => request.parent}
|
209
|
-
end
|
210
|
-
)
|
211
|
-
@async_batch_annotate_images = Google::Gax.create_api_call(
|
212
|
-
@image_annotator_stub.method(:async_batch_annotate_images),
|
213
|
-
defaults["async_batch_annotate_images"],
|
214
|
-
exception_transformer: exception_transformer,
|
215
|
-
params_extractor: proc do |request|
|
216
|
-
{'parent' => request.parent}
|
217
|
-
end
|
218
|
-
)
|
219
|
-
@async_batch_annotate_files = Google::Gax.create_api_call(
|
220
|
-
@image_annotator_stub.method(:async_batch_annotate_files),
|
221
|
-
defaults["async_batch_annotate_files"],
|
222
|
-
exception_transformer: exception_transformer,
|
223
|
-
params_extractor: proc do |request|
|
224
|
-
{'parent' => request.parent}
|
225
|
-
end
|
226
|
-
)
|
227
|
-
end
|
228
|
-
|
229
|
-
# Service calls
|
230
|
-
|
231
|
-
# Run image detection and annotation for a batch of images.
|
232
|
-
#
|
233
|
-
# @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
|
234
|
-
# Required. Individual image annotation requests for this batch.
|
235
|
-
# A hash of the same form as `Google::Cloud::Vision::V1::AnnotateImageRequest`
|
236
|
-
# can also be provided.
|
237
|
-
# @param parent [String]
|
238
|
-
# Optional. Target project and location to make a call.
|
239
|
-
#
|
240
|
-
# Format: `projects/{project-id}/locations/{location-id}`.
|
241
|
-
#
|
242
|
-
# If no parent is specified, a region will be chosen automatically.
|
243
|
-
#
|
244
|
-
# Supported location-ids:
|
245
|
-
# `us`: USA country only,
|
246
|
-
# `asia`: East asia areas, like Japan, Taiwan,
|
247
|
-
# `eu`: The European Union.
|
248
|
-
#
|
249
|
-
# Example: `projects/project-A/locations/eu`.
|
250
|
-
# @param options [Google::Gax::CallOptions]
|
251
|
-
# Overrides the default settings for this call, e.g, timeout,
|
252
|
-
# retries, etc.
|
253
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
254
|
-
# @yieldparam result [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
|
255
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
256
|
-
# @return [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
|
257
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
258
|
-
# @example
|
259
|
-
# require "google/cloud/vision"
|
260
|
-
#
|
261
|
-
# image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
|
262
|
-
#
|
263
|
-
# # TODO: Initialize `requests`:
|
264
|
-
# requests = []
|
265
|
-
# response = image_annotator_client.batch_annotate_images(requests)
|
266
|
-
|
267
|
-
def batch_annotate_images \
|
268
|
-
requests,
|
269
|
-
parent: nil,
|
270
|
-
options: nil,
|
271
|
-
&block
|
272
|
-
req = {
|
273
|
-
requests: requests,
|
274
|
-
parent: parent
|
275
|
-
}.delete_if { |_, v| v.nil? }
|
276
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::BatchAnnotateImagesRequest)
|
277
|
-
@batch_annotate_images.call(req, options, &block)
|
278
|
-
end
|
279
|
-
|
280
|
-
# Service that performs image detection and annotation for a batch of files.
|
281
|
-
# Now only "application/pdf", "image/tiff" and "image/gif" are supported.
|
282
|
-
#
|
283
|
-
# This service will extract at most 5 (customers can specify which 5 in
|
284
|
-
# AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
|
285
|
-
# file provided and perform detection and annotation for each image
|
286
|
-
# extracted.
|
287
|
-
#
|
288
|
-
# @param requests [Array<Google::Cloud::Vision::V1::AnnotateFileRequest | Hash>]
|
289
|
-
# Required. The list of file annotation requests. Right now we support only one
|
290
|
-
# AnnotateFileRequest in BatchAnnotateFilesRequest.
|
291
|
-
# A hash of the same form as `Google::Cloud::Vision::V1::AnnotateFileRequest`
|
292
|
-
# can also be provided.
|
293
|
-
# @param parent [String]
|
294
|
-
# Optional. Target project and location to make a call.
|
295
|
-
#
|
296
|
-
# Format: `projects/{project-id}/locations/{location-id}`.
|
297
|
-
#
|
298
|
-
# If no parent is specified, a region will be chosen automatically.
|
299
|
-
#
|
300
|
-
# Supported location-ids:
|
301
|
-
# `us`: USA country only,
|
302
|
-
# `asia`: East asia areas, like Japan, Taiwan,
|
303
|
-
# `eu`: The European Union.
|
304
|
-
#
|
305
|
-
# Example: `projects/project-A/locations/eu`.
|
306
|
-
# @param options [Google::Gax::CallOptions]
|
307
|
-
# Overrides the default settings for this call, e.g, timeout,
|
308
|
-
# retries, etc.
|
309
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
310
|
-
# @yieldparam result [Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
|
311
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
312
|
-
# @return [Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
|
313
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
314
|
-
# @example
|
315
|
-
# require "google/cloud/vision"
|
316
|
-
#
|
317
|
-
# image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
|
318
|
-
#
|
319
|
-
# # TODO: Initialize `requests`:
|
320
|
-
# requests = []
|
321
|
-
# response = image_annotator_client.batch_annotate_files(requests)
|
322
|
-
|
323
|
-
def batch_annotate_files \
|
324
|
-
requests,
|
325
|
-
parent: nil,
|
326
|
-
options: nil,
|
327
|
-
&block
|
328
|
-
req = {
|
329
|
-
requests: requests,
|
330
|
-
parent: parent
|
331
|
-
}.delete_if { |_, v| v.nil? }
|
332
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::BatchAnnotateFilesRequest)
|
333
|
-
@batch_annotate_files.call(req, options, &block)
|
334
|
-
end
|
335
|
-
|
336
|
-
# Run asynchronous image detection and annotation for a list of images.
|
337
|
-
#
|
338
|
-
# Progress and results can be retrieved through the
|
339
|
-
# `google.longrunning.Operations` interface.
|
340
|
-
# `Operation.metadata` contains `OperationMetadata` (metadata).
|
341
|
-
# `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
|
342
|
-
#
|
343
|
-
# This service will write image annotation outputs to json files in customer
|
344
|
-
# GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
|
345
|
-
#
|
346
|
-
# @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
|
347
|
-
# Required. Individual image annotation requests for this batch.
|
348
|
-
# A hash of the same form as `Google::Cloud::Vision::V1::AnnotateImageRequest`
|
349
|
-
# can also be provided.
|
350
|
-
# @param output_config [Google::Cloud::Vision::V1::OutputConfig | Hash]
|
351
|
-
# Required. The desired output location and metadata (e.g. format).
|
352
|
-
# A hash of the same form as `Google::Cloud::Vision::V1::OutputConfig`
|
353
|
-
# can also be provided.
|
354
|
-
# @param parent [String]
|
355
|
-
# Optional. Target project and location to make a call.
|
356
|
-
#
|
357
|
-
# Format: `projects/{project-id}/locations/{location-id}`.
|
358
|
-
#
|
359
|
-
# If no parent is specified, a region will be chosen automatically.
|
360
|
-
#
|
361
|
-
# Supported location-ids:
|
362
|
-
# `us`: USA country only,
|
363
|
-
# `asia`: East asia areas, like Japan, Taiwan,
|
364
|
-
# `eu`: The European Union.
|
365
|
-
#
|
366
|
-
# Example: `projects/project-A/locations/eu`.
|
367
|
-
# @param options [Google::Gax::CallOptions]
|
368
|
-
# Overrides the default settings for this call, e.g, timeout,
|
369
|
-
# retries, etc.
|
370
|
-
# @return [Google::Gax::Operation]
|
371
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
372
|
-
# @example
|
373
|
-
# require "google/cloud/vision"
|
374
|
-
#
|
375
|
-
# image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
|
376
|
-
#
|
377
|
-
# # TODO: Initialize `requests`:
|
378
|
-
# requests = []
|
379
|
-
#
|
380
|
-
# # TODO: Initialize `output_config`:
|
381
|
-
# output_config = {}
|
382
|
-
#
|
383
|
-
# # Register a callback during the method call.
|
384
|
-
# operation = image_annotator_client.async_batch_annotate_images(requests, output_config) do |op|
|
385
|
-
# raise op.results.message if op.error?
|
386
|
-
# op_results = op.results
|
387
|
-
# # Process the results.
|
388
|
-
#
|
389
|
-
# metadata = op.metadata
|
390
|
-
# # Process the metadata.
|
391
|
-
# end
|
392
|
-
#
|
393
|
-
# # Or use the return value to register a callback.
|
394
|
-
# operation.on_done do |op|
|
395
|
-
# raise op.results.message if op.error?
|
396
|
-
# op_results = op.results
|
397
|
-
# # Process the results.
|
398
|
-
#
|
399
|
-
# metadata = op.metadata
|
400
|
-
# # Process the metadata.
|
401
|
-
# end
|
402
|
-
#
|
403
|
-
# # Manually reload the operation.
|
404
|
-
# operation.reload!
|
405
|
-
#
|
406
|
-
# # Or block until the operation completes, triggering callbacks on
|
407
|
-
# # completion.
|
408
|
-
# operation.wait_until_done!
|
409
|
-
|
410
|
-
def async_batch_annotate_images \
|
411
|
-
requests,
|
412
|
-
output_config,
|
413
|
-
parent: nil,
|
414
|
-
options: nil
|
415
|
-
req = {
|
416
|
-
requests: requests,
|
417
|
-
output_config: output_config,
|
418
|
-
parent: parent
|
419
|
-
}.delete_if { |_, v| v.nil? }
|
420
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest)
|
421
|
-
operation = Google::Gax::Operation.new(
|
422
|
-
@async_batch_annotate_images.call(req, options),
|
423
|
-
@operations_client,
|
424
|
-
Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesResponse,
|
425
|
-
Google::Cloud::Vision::V1::OperationMetadata,
|
426
|
-
call_options: options
|
427
|
-
)
|
428
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
429
|
-
operation
|
430
|
-
end
|
431
|
-
|
432
|
-
# Run asynchronous image detection and annotation for a list of generic
|
433
|
-
# files, such as PDF files, which may contain multiple pages and multiple
|
434
|
-
# images per page. Progress and results can be retrieved through the
|
435
|
-
# `google.longrunning.Operations` interface.
|
436
|
-
# `Operation.metadata` contains `OperationMetadata` (metadata).
|
437
|
-
# `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
|
438
|
-
#
|
439
|
-
# @param requests [Array<Google::Cloud::Vision::V1::AsyncAnnotateFileRequest | Hash>]
|
440
|
-
# Required. Individual async file annotation requests for this batch.
|
441
|
-
# A hash of the same form as `Google::Cloud::Vision::V1::AsyncAnnotateFileRequest`
|
442
|
-
# can also be provided.
|
443
|
-
# @param parent [String]
|
444
|
-
# Optional. Target project and location to make a call.
|
445
|
-
#
|
446
|
-
# Format: `projects/{project-id}/locations/{location-id}`.
|
447
|
-
#
|
448
|
-
# If no parent is specified, a region will be chosen automatically.
|
449
|
-
#
|
450
|
-
# Supported location-ids:
|
451
|
-
# `us`: USA country only,
|
452
|
-
# `asia`: East asia areas, like Japan, Taiwan,
|
453
|
-
# `eu`: The European Union.
|
454
|
-
#
|
455
|
-
# Example: `projects/project-A/locations/eu`.
|
456
|
-
# @param options [Google::Gax::CallOptions]
|
457
|
-
# Overrides the default settings for this call, e.g, timeout,
|
458
|
-
# retries, etc.
|
459
|
-
# @return [Google::Gax::Operation]
|
460
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
461
|
-
# @example
|
462
|
-
# require "google/cloud/vision"
|
463
|
-
#
|
464
|
-
# image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
|
465
|
-
#
|
466
|
-
# # TODO: Initialize `requests`:
|
467
|
-
# requests = []
|
468
|
-
#
|
469
|
-
# # Register a callback during the method call.
|
470
|
-
# operation = image_annotator_client.async_batch_annotate_files(requests) do |op|
|
471
|
-
# raise op.results.message if op.error?
|
472
|
-
# op_results = op.results
|
473
|
-
# # Process the results.
|
474
|
-
#
|
475
|
-
# metadata = op.metadata
|
476
|
-
# # Process the metadata.
|
477
|
-
# end
|
478
|
-
#
|
479
|
-
# # Or use the return value to register a callback.
|
480
|
-
# operation.on_done do |op|
|
481
|
-
# raise op.results.message if op.error?
|
482
|
-
# op_results = op.results
|
483
|
-
# # Process the results.
|
484
|
-
#
|
485
|
-
# metadata = op.metadata
|
486
|
-
# # Process the metadata.
|
487
|
-
# end
|
488
|
-
#
|
489
|
-
# # Manually reload the operation.
|
490
|
-
# operation.reload!
|
491
|
-
#
|
492
|
-
# # Or block until the operation completes, triggering callbacks on
|
493
|
-
# # completion.
|
494
|
-
# operation.wait_until_done!
|
495
|
-
|
496
|
-
def async_batch_annotate_files \
|
497
|
-
requests,
|
498
|
-
parent: nil,
|
499
|
-
options: nil
|
500
|
-
req = {
|
501
|
-
requests: requests,
|
502
|
-
parent: parent
|
503
|
-
}.delete_if { |_, v| v.nil? }
|
504
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest)
|
505
|
-
operation = Google::Gax::Operation.new(
|
506
|
-
@async_batch_annotate_files.call(req, options),
|
507
|
-
@operations_client,
|
508
|
-
Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesResponse,
|
509
|
-
Google::Cloud::Vision::V1::OperationMetadata,
|
510
|
-
call_options: options
|
511
|
-
)
|
512
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
513
|
-
operation
|
514
|
-
end
|
515
|
-
end
|
516
|
-
end
|
517
|
-
end
|
518
|
-
end
|
519
|
-
end
|