google-cloud-vision 0.25.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/google-cloud-vision.rb +13 -10
- data/lib/google/cloud/vision.rb +21 -18
- data/lib/google/cloud/vision/annotation/text.rb +15 -0
- data/lib/google/cloud/vision/credentials.rb +31 -5
- data/lib/google/cloud/vision/project.rb +6 -5
- data/lib/google/cloud/vision/service.rb +3 -22
- data/lib/google/cloud/vision/v1.rb +113 -1
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +17 -6
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +33 -33
- data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +12 -2
- data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +22 -22
- data/lib/google/cloud/vision/v1/doc/overview.rb +72 -0
- data/lib/google/cloud/vision/v1/image_annotator_client.rb +59 -22
- data/lib/google/cloud/vision/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c09d8049f20a5c93eb8bd360bf9342829812606be35eec929e2c87abdb4758f
|
4
|
+
data.tar.gz: dda3ffc1e2ea698d2e0e14d6904378a5ad9c4dd7d6fd7e556a1003b07c41d632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b23ca2e917b9313c5aa8933ddd861b854cb036161b25d6db7d23da1ab80651908e7117a6e4ccaa59654a250916939655d92ec11a3a961f68a121cf3cb9b2e81f
|
7
|
+
data.tar.gz: ec7ed02b242c7fa31255a0f20b39da2450fef2a1964e85bce8a2b7fc062d991529979163b7743fd730b96332a3869e50e1e97eb518cbd2fe53483706eeb1c672
|
data/lib/google-cloud-vision.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
##
|
16
|
-
# This file is here to be autorequired by bundler, so that the
|
17
|
-
# #
|
18
|
-
# be loaded until required and used.
|
16
|
+
# This file is here to be autorequired by bundler, so that the
|
17
|
+
# Google::Cloud.vision and Google::Cloud#vision methods can be available, but
|
18
|
+
# the library and all dependencies won't be loaded until required and used.
|
19
19
|
|
20
20
|
|
21
21
|
gem "google-cloud-core"
|
@@ -69,10 +69,12 @@ module Google
|
|
69
69
|
# Creates a new object for connecting to the Vision service.
|
70
70
|
# Each call creates a new connection.
|
71
71
|
#
|
72
|
-
# @param [String]
|
73
|
-
# connecting to.
|
74
|
-
#
|
75
|
-
#
|
72
|
+
# @param [String] project_id Project identifier for the Vision service you
|
73
|
+
# are connecting to. If not present, the default project for the
|
74
|
+
# credentials is used.
|
75
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
76
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
77
|
+
# Google::Auth::Credentials object. (See {Vision::Credentials})
|
76
78
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
77
79
|
# set of resources and operations that the connection can access. See
|
78
80
|
# [Using OAuth 2.0 to Access Google
|
@@ -97,10 +99,11 @@ module Google
|
|
97
99
|
# landmark = image.landmark
|
98
100
|
# landmark.description #=> "Mount Rushmore"
|
99
101
|
#
|
100
|
-
def self.vision
|
101
|
-
client_config: nil
|
102
|
+
def self.vision project_id = nil, credentials = nil, scope: nil,
|
103
|
+
timeout: nil, client_config: nil
|
102
104
|
require "google/cloud/vision"
|
103
|
-
Google::Cloud::Vision.new
|
105
|
+
Google::Cloud::Vision.new project_id: project_id,
|
106
|
+
credentials: credentials,
|
104
107
|
scope: scope, timeout: timeout,
|
105
108
|
client_config: client_config
|
106
109
|
end
|
data/lib/google/cloud/vision.rb
CHANGED
@@ -570,10 +570,12 @@ module Google
|
|
570
570
|
# Creates a new object for connecting to the Vision service.
|
571
571
|
# Each call creates a new connection.
|
572
572
|
#
|
573
|
-
# @param [String]
|
574
|
-
# are connecting to.
|
575
|
-
#
|
576
|
-
#
|
573
|
+
# @param [String] project_id Project identifier for the Vision service you
|
574
|
+
# are connecting to. If not present, the default project for the
|
575
|
+
# credentials is used.
|
576
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
577
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
578
|
+
# Google::Auth::Credentials object. (See {Vision::Credentials})
|
577
579
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
578
580
|
# the set of resources and operations that the connection can access.
|
579
581
|
# See [Using OAuth 2.0 to Access Google
|
@@ -585,6 +587,9 @@ module Google
|
|
585
587
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
586
588
|
# @param [Hash] client_config A hash of values to override the default
|
587
589
|
# behavior of the API client. Optional.
|
590
|
+
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
591
|
+
# @param [String] keyfile Alias for the `credentials` argument.
|
592
|
+
# Deprecated.
|
588
593
|
#
|
589
594
|
# @return [Google::Cloud::Vision::Project]
|
590
595
|
#
|
@@ -598,23 +603,21 @@ module Google
|
|
598
603
|
# landmark = image.landmark
|
599
604
|
# landmark.description #=> "Mount Rushmore"
|
600
605
|
#
|
601
|
-
def self.new
|
602
|
-
client_config: nil
|
603
|
-
|
604
|
-
|
605
|
-
fail ArgumentError, "
|
606
|
+
def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
|
607
|
+
client_config: nil, project: nil, keyfile: nil
|
608
|
+
project_id ||= (project || Vision::Project.default_project_id)
|
609
|
+
project_id = project_id.to_s # Always cast to a string
|
610
|
+
fail ArgumentError, "project_id is missing" if project_id.empty?
|
606
611
|
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
credentials = Google::Cloud::Vision::Credentials.new \
|
611
|
-
keyfile, scope: scope
|
612
|
+
credentials ||= (keyfile || Vision::Credentials.default(scope: scope))
|
613
|
+
unless credentials.is_a? Google::Auth::Credentials
|
614
|
+
credentials = Vision::Credentials.new credentials, scope: scope
|
612
615
|
end
|
613
616
|
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
617
|
+
Vision::Project.new(
|
618
|
+
Vision::Service.new(
|
619
|
+
project_id, credentials, timeout: timeout,
|
620
|
+
client_config: client_config))
|
618
621
|
end
|
619
622
|
end
|
620
623
|
end
|
@@ -290,6 +290,7 @@ module Google
|
|
290
290
|
# @return [Array<Language>]
|
291
291
|
#
|
292
292
|
def languages
|
293
|
+
return [] if @grpc.property.nil?
|
293
294
|
@languages ||= Array(@grpc.property.detected_languages).map do |l|
|
294
295
|
Language.from_grpc l
|
295
296
|
end
|
@@ -301,6 +302,7 @@ module Google
|
|
301
302
|
# @return [::Symbol]
|
302
303
|
#
|
303
304
|
def break_type
|
305
|
+
return nil if @grpc.property.nil?
|
304
306
|
@grpc.property.detected_break &&
|
305
307
|
@grpc.property.detected_break.type.to_sym
|
306
308
|
end
|
@@ -311,6 +313,7 @@ module Google
|
|
311
313
|
# @return [Boolean]
|
312
314
|
#
|
313
315
|
def prefix_break?
|
316
|
+
return nil if @grpc.property.nil?
|
314
317
|
@grpc.property.detected_break &&
|
315
318
|
@grpc.property.detected_break.is_prefix
|
316
319
|
end
|
@@ -411,6 +414,7 @@ module Google
|
|
411
414
|
# @return [Array<Language>]
|
412
415
|
#
|
413
416
|
def languages
|
417
|
+
return [] if @grpc.property.nil?
|
414
418
|
detected_languages = @grpc.property.detected_languages
|
415
419
|
@languages ||= Array(detected_languages).map do |l|
|
416
420
|
Language.from_grpc l
|
@@ -423,6 +427,7 @@ module Google
|
|
423
427
|
# @return [::Symbol]
|
424
428
|
#
|
425
429
|
def break_type
|
430
|
+
return nil if @grpc.property.nil?
|
426
431
|
@grpc.property.detected_break &&
|
427
432
|
@grpc.property.detected_break.type.to_sym
|
428
433
|
end
|
@@ -433,6 +438,7 @@ module Google
|
|
433
438
|
# @return [Boolean]
|
434
439
|
#
|
435
440
|
def prefix_break?
|
441
|
+
return nil if @grpc.property.nil?
|
436
442
|
@grpc.property.detected_break &&
|
437
443
|
@grpc.property.detected_break.is_prefix
|
438
444
|
end
|
@@ -555,6 +561,7 @@ module Google
|
|
555
561
|
# @return [Array<Language>]
|
556
562
|
#
|
557
563
|
def languages
|
564
|
+
return [] if @grpc.property.nil?
|
558
565
|
detected_languages = @grpc.property.detected_languages
|
559
566
|
@languages ||= Array(detected_languages).map do |l|
|
560
567
|
Language.from_grpc l
|
@@ -567,6 +574,7 @@ module Google
|
|
567
574
|
# @return [::Symbol]
|
568
575
|
#
|
569
576
|
def break_type
|
577
|
+
return nil if @grpc.property.nil?
|
570
578
|
@grpc.property.detected_break &&
|
571
579
|
@grpc.property.detected_break.type.to_sym
|
572
580
|
end
|
@@ -577,6 +585,7 @@ module Google
|
|
577
585
|
# @return [Boolean]
|
578
586
|
#
|
579
587
|
def prefix_break?
|
588
|
+
return nil if @grpc.property.nil?
|
580
589
|
@grpc.property.detected_break &&
|
581
590
|
@grpc.property.detected_break.is_prefix
|
582
591
|
end
|
@@ -688,6 +697,7 @@ module Google
|
|
688
697
|
# @return [Array<Language>]
|
689
698
|
#
|
690
699
|
def languages
|
700
|
+
return [] if @grpc.property.nil?
|
691
701
|
detected_languages = @grpc.property.detected_languages
|
692
702
|
@languages ||= Array(detected_languages).map do |l|
|
693
703
|
Language.from_grpc l
|
@@ -700,6 +710,7 @@ module Google
|
|
700
710
|
# @return [::Symbol]
|
701
711
|
#
|
702
712
|
def break_type
|
713
|
+
return nil if @grpc.property.nil?
|
703
714
|
@grpc.property.detected_break &&
|
704
715
|
@grpc.property.detected_break.type.to_sym
|
705
716
|
end
|
@@ -710,6 +721,7 @@ module Google
|
|
710
721
|
# @return [Boolean]
|
711
722
|
#
|
712
723
|
def prefix_break?
|
724
|
+
return nil if @grpc.property.nil?
|
713
725
|
@grpc.property.detected_break &&
|
714
726
|
@grpc.property.detected_break.is_prefix
|
715
727
|
end
|
@@ -823,6 +835,7 @@ module Google
|
|
823
835
|
# @return [Array<Language>]
|
824
836
|
#
|
825
837
|
def languages
|
838
|
+
return [] if @grpc.property.nil?
|
826
839
|
detected_languages = @grpc.property.detected_languages
|
827
840
|
@languages ||= Array(detected_languages).map do |l|
|
828
841
|
Language.from_grpc l
|
@@ -835,6 +848,7 @@ module Google
|
|
835
848
|
# @return [::Symbol]
|
836
849
|
#
|
837
850
|
def break_type
|
851
|
+
return nil if @grpc.property.nil?
|
838
852
|
@grpc.property.detected_break &&
|
839
853
|
@grpc.property.detected_break.type.to_sym
|
840
854
|
end
|
@@ -845,6 +859,7 @@ module Google
|
|
845
859
|
# @return [Boolean]
|
846
860
|
#
|
847
861
|
def prefix_break?
|
862
|
+
return nil if @grpc.property.nil?
|
848
863
|
@grpc.property.detected_break &&
|
849
864
|
@grpc.property.detected_break.is_prefix
|
850
865
|
end
|
@@ -13,18 +13,44 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "
|
16
|
+
require "googleauth"
|
17
17
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
20
|
module Vision
|
21
21
|
##
|
22
|
-
#
|
23
|
-
|
22
|
+
# # Credentials
|
23
|
+
#
|
24
|
+
# Represents the authentication and authorization used to connect to the
|
25
|
+
# Vision API.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# require "google/cloud/vision"
|
29
|
+
#
|
30
|
+
# keyfile = "/path/to/keyfile.json"
|
31
|
+
# creds = Google::Cloud::Vision::Credentials.new keyfile
|
32
|
+
#
|
33
|
+
# vision = Google::Cloud::Vision.new(
|
34
|
+
# project_id: "my-project",
|
35
|
+
# credentials: creds
|
36
|
+
# )
|
37
|
+
#
|
38
|
+
# vision.project_id #=> "my-project"
|
39
|
+
#
|
40
|
+
class Credentials < Google::Auth::Credentials
|
24
41
|
SCOPE = ["https://www.googleapis.com/auth/cloud-platform"]
|
25
|
-
PATH_ENV_VARS = %w(
|
26
|
-
|
42
|
+
PATH_ENV_VARS = %w(VISION_CREDENTIALS
|
43
|
+
VISION_KEYFILE
|
44
|
+
GOOGLE_CLOUD_CREDENTIALS
|
45
|
+
GOOGLE_CLOUD_KEYFILE
|
46
|
+
GCLOUD_KEYFILE)
|
47
|
+
JSON_ENV_VARS = %w(VISION_CREDENTIALS_JSON
|
48
|
+
VISION_KEYFILE_JSON
|
49
|
+
GOOGLE_CLOUD_CREDENTIALS_JSON
|
50
|
+
GOOGLE_CLOUD_KEYFILE_JSON
|
27
51
|
GCLOUD_KEYFILE_JSON)
|
52
|
+
DEFAULT_PATHS = \
|
53
|
+
["~/.config/gcloud/application_default_credentials.json"]
|
28
54
|
end
|
29
55
|
end
|
30
56
|
end
|
@@ -63,19 +63,20 @@ module Google
|
|
63
63
|
# require "google/cloud/vision"
|
64
64
|
#
|
65
65
|
# vision = Google::Cloud::Vision.new(
|
66
|
-
#
|
67
|
-
#
|
66
|
+
# project_id: "my-project",
|
67
|
+
# credentials: "/path/to/keyfile.json"
|
68
68
|
# )
|
69
69
|
#
|
70
|
-
# vision.
|
70
|
+
# vision.project_id #=> "my-project"
|
71
71
|
#
|
72
|
-
def
|
72
|
+
def project_id
|
73
73
|
service.project
|
74
74
|
end
|
75
|
+
alias_method :project, :project_id
|
75
76
|
|
76
77
|
##
|
77
78
|
# @private Default project.
|
78
|
-
def self.
|
79
|
+
def self.default_project_id
|
79
80
|
ENV["VISION_PROJECT"] ||
|
80
81
|
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
81
82
|
ENV["GCLOUD_PROJECT"] ||
|
@@ -25,37 +25,22 @@ module Google
|
|
25
25
|
# @private
|
26
26
|
# Represents the service to Vision, exposing the API calls.
|
27
27
|
class Service
|
28
|
-
attr_accessor :project, :credentials, :
|
28
|
+
attr_accessor :project, :credentials, :timeout, :client_config
|
29
29
|
|
30
30
|
##
|
31
31
|
# Creates a new Service instance.
|
32
|
-
def initialize project, credentials,
|
33
|
-
client_config: nil
|
32
|
+
def initialize project, credentials, timeout: nil, client_config: nil
|
34
33
|
@project = project
|
35
34
|
@credentials = credentials
|
36
|
-
@host = host || V1::ImageAnnotatorClient::SERVICE_ADDRESS
|
37
35
|
@timeout = timeout
|
38
36
|
@client_config = client_config || {}
|
39
37
|
end
|
40
38
|
|
41
|
-
def channel
|
42
|
-
require "grpc"
|
43
|
-
GRPC::Core::Channel.new host, nil, chan_creds
|
44
|
-
end
|
45
|
-
|
46
|
-
def chan_creds
|
47
|
-
return credentials if insecure?
|
48
|
-
require "grpc"
|
49
|
-
GRPC::Core::ChannelCredentials.new.compose \
|
50
|
-
GRPC::Core::CallCredentials.new credentials.client.updater_proc
|
51
|
-
end
|
52
|
-
|
53
39
|
def service
|
54
40
|
return mocked_service if mocked_service
|
55
41
|
@service ||= \
|
56
42
|
V1::ImageAnnotatorClient.new(
|
57
|
-
|
58
|
-
channel: channel,
|
43
|
+
credentials: credentials,
|
59
44
|
timeout: timeout,
|
60
45
|
client_config: client_config,
|
61
46
|
lib_name: "gccl",
|
@@ -63,10 +48,6 @@ module Google
|
|
63
48
|
end
|
64
49
|
attr_accessor :mocked_service
|
65
50
|
|
66
|
-
def insecure?
|
67
|
-
credentials == :this_channel_is_insecure
|
68
|
-
end
|
69
|
-
|
70
51
|
##
|
71
52
|
# Returns API::BatchAnnotateImagesResponse
|
72
53
|
def annotate requests
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -13,3 +13,115 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require "google/cloud/vision/v1/image_annotator_client"
|
16
|
+
|
17
|
+
module Google
|
18
|
+
module Cloud
|
19
|
+
# rubocop:disable LineLength
|
20
|
+
|
21
|
+
##
|
22
|
+
# # Ruby Client for Google Cloud Vision API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
23
|
+
#
|
24
|
+
# [Google Cloud Vision API][Product Documentation]:
|
25
|
+
# Integrates Google Vision features, including image labeling, face, logo, and
|
26
|
+
# landmark detection, optical character recognition (OCR), and detection of
|
27
|
+
# explicit content, into applications.
|
28
|
+
# - [Product Documentation][]
|
29
|
+
#
|
30
|
+
# ## Quick Start
|
31
|
+
# In order to use this library, you first need to go through the following
|
32
|
+
# steps:
|
33
|
+
#
|
34
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
35
|
+
# 2. [Enable the Google Cloud Vision API.](https://console.cloud.google.com/apis/api/vision)
|
36
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
37
|
+
#
|
38
|
+
# ### Preview
|
39
|
+
# #### ImageAnnotatorClient
|
40
|
+
# ```rb
|
41
|
+
# require "google/cloud/vision/v1"
|
42
|
+
#
|
43
|
+
# image_annotator_client = Google::Cloud::Vision::V1.new
|
44
|
+
# gcs_image_uri = "gs://gapic-toolkit/President_Barack_Obama.jpg"
|
45
|
+
# source = { gcs_image_uri: gcs_image_uri }
|
46
|
+
# image = { source: source }
|
47
|
+
# type = :FACE_DETECTION
|
48
|
+
# features_element = { type: type }
|
49
|
+
# features = [features_element]
|
50
|
+
# requests_element = { image: image, features: features }
|
51
|
+
# requests = [requests_element]
|
52
|
+
# response = image_annotator_client.batch_annotate_images(requests)
|
53
|
+
# ```
|
54
|
+
#
|
55
|
+
# ### Next Steps
|
56
|
+
# - Read the [Google Cloud Vision API Product documentation][Product Documentation]
|
57
|
+
# to learn more about the product and see How-to Guides.
|
58
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
59
|
+
# to see the full list of Cloud APIs that we cover.
|
60
|
+
#
|
61
|
+
# [Product Documentation]: https://cloud.google.com/vision
|
62
|
+
#
|
63
|
+
#
|
64
|
+
module Vision
|
65
|
+
module V1
|
66
|
+
# rubocop:enable LineLength
|
67
|
+
|
68
|
+
##
|
69
|
+
# Service that performs Google Cloud Vision API detection tasks over client
|
70
|
+
# images, such as face, landmark, logo, label, and text detection. The
|
71
|
+
# ImageAnnotator service returns detected entities from the images.
|
72
|
+
#
|
73
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
74
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
75
|
+
# be many types.
|
76
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
77
|
+
# authenticating requests made by this client.
|
78
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
79
|
+
# credentials for this client.
|
80
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
81
|
+
# credentials for this client.
|
82
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
83
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
84
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
85
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
86
|
+
# metadata for requests, generally, to give OAuth credentials.
|
87
|
+
# @param scopes [Array<String>]
|
88
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
89
|
+
# an updater_proc is supplied.
|
90
|
+
# @param client_config [Hash]
|
91
|
+
# A Hash for call options for each method. See
|
92
|
+
# Google::Gax#construct_settings for the structure of
|
93
|
+
# this data. Falls back to the default config if not specified
|
94
|
+
# or the specified config is missing data points.
|
95
|
+
# @param timeout [Numeric]
|
96
|
+
# The default timeout, in seconds, for calls made through this client.
|
97
|
+
def self.new \
|
98
|
+
service_path: nil,
|
99
|
+
port: nil,
|
100
|
+
channel: nil,
|
101
|
+
chan_creds: nil,
|
102
|
+
updater_proc: nil,
|
103
|
+
credentials: nil,
|
104
|
+
scopes: nil,
|
105
|
+
client_config: nil,
|
106
|
+
timeout: nil,
|
107
|
+
lib_name: nil,
|
108
|
+
lib_version: nil
|
109
|
+
kwargs = {
|
110
|
+
service_path: service_path,
|
111
|
+
port: port,
|
112
|
+
channel: channel,
|
113
|
+
chan_creds: chan_creds,
|
114
|
+
updater_proc: updater_proc,
|
115
|
+
credentials: credentials,
|
116
|
+
scopes: scopes,
|
117
|
+
client_config: client_config,
|
118
|
+
timeout: timeout,
|
119
|
+
lib_name: lib_name,
|
120
|
+
lib_version: lib_version
|
121
|
+
}.select { |_, v| v != nil }
|
122
|
+
Google::Cloud::Vision::V1::ImageAnnotatorClient.new(**kwargs)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -15,6 +15,17 @@
|
|
15
15
|
module Google
|
16
16
|
module Cloud
|
17
17
|
module Vision
|
18
|
+
##
|
19
|
+
# # Google Cloud Vision API Contents
|
20
|
+
#
|
21
|
+
# | Class | Description |
|
22
|
+
# | ----- | ----------- |
|
23
|
+
# | [ImageAnnotatorClient][] | Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications. |
|
24
|
+
# | [Data Types][] | Data types for Google::Cloud::Vision::V1 |
|
25
|
+
#
|
26
|
+
# [ImageAnnotatorClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-vision/latest/google/cloud/vision/v1/imageannotatorclient
|
27
|
+
# [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-vision/latest/google/cloud/vision/v1/datatypes
|
28
|
+
#
|
18
29
|
module V1
|
19
30
|
# Users describe the type of Google Cloud Vision API tasks to perform over
|
20
31
|
# images by using *Feature*s. Each Feature indicates a type of image
|
@@ -71,16 +82,16 @@ module Google
|
|
71
82
|
# NOTE: For new code +image_uri+ below is preferred.
|
72
83
|
# Google Cloud Storage image URI, which must be in the following form:
|
73
84
|
# +gs://bucket_name/object_name+ (for details, see
|
74
|
-
#
|
75
|
-
# URIs
|
85
|
+
# [Google Cloud Storage Request
|
86
|
+
# URIs](https://cloud.google.com/storage/docs/reference-uris)).
|
76
87
|
# NOTE: Cloud Storage object versioning is not supported.
|
77
88
|
# @!attribute [rw] image_uri
|
78
89
|
# @return [String]
|
79
90
|
# Image URI which supports:
|
80
91
|
# 1) Google Cloud Storage image URI, which must be in the following form:
|
81
92
|
# +gs://bucket_name/object_name+ (for details, see
|
82
|
-
#
|
83
|
-
# URIs
|
93
|
+
# [Google Cloud Storage Request
|
94
|
+
# URIs](https://cloud.google.com/storage/docs/reference-uris)).
|
84
95
|
# NOTE: Cloud Storage object versioning is not supported.
|
85
96
|
# 2) Publicly accessible image HTTP/HTTPS URL.
|
86
97
|
# This is preferred over the legacy +gcs_image_uri+ above. When both
|
@@ -308,7 +319,7 @@ module Google
|
|
308
319
|
# @!attribute [rw] mid
|
309
320
|
# @return [String]
|
310
321
|
# Opaque entity ID. Some IDs may be available in
|
311
|
-
#
|
322
|
+
# [Google Knowledge Graph Search API](https://developers.google.com/knowledge-graph/).
|
312
323
|
# @!attribute [rw] locale
|
313
324
|
# @return [String]
|
314
325
|
# The language code for the locale in which the entity textual
|
@@ -448,7 +459,7 @@ module Google
|
|
448
459
|
# setting a hint will help get better results (although it will be a
|
449
460
|
# significant hindrance if the hint is wrong). Text detection returns an
|
450
461
|
# error if one or more of the specified languages is not one of the
|
451
|
-
#
|
462
|
+
# [supported languages](https://cloud.google.com/vision/docs/languages).
|
452
463
|
# @!attribute [rw] crop_hints_params
|
453
464
|
# @return [Google::Cloud::Vision::V1::CropHintsParams]
|
454
465
|
# Parameters for crop hints annotation request.
|
@@ -21,7 +21,7 @@ module Google
|
|
21
21
|
# TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol
|
22
22
|
# Each structural component, starting from Page, may further have their own
|
23
23
|
# properties. Properties describe detected languages, breaks etc.. Please
|
24
|
-
# refer to the Google::Cloud::Vision::V1::TextAnnotation::TextProperty message
|
24
|
+
# refer to the {Google::Cloud::Vision::V1::TextAnnotation::TextProperty} message
|
25
25
|
# definition below for more detail.
|
26
26
|
# @!attribute [rw] pages
|
27
27
|
# @return [Array<Google::Cloud::Vision::V1::Page>]
|
@@ -109,15 +109,15 @@ module Google
|
|
109
109
|
# is represented as around the top-left corner as defined when the text is
|
110
110
|
# read in the 'natural' orientation.
|
111
111
|
# For example:
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
112
|
+
# * when the text is horizontal it might look like:
|
113
|
+
# 0----1
|
114
|
+
# | |
|
115
|
+
# 3----2
|
116
116
|
# * when it's rotated 180 degrees around the top-left corner it becomes:
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
117
|
+
# 2----3
|
118
|
+
# | |
|
119
|
+
# 1----0
|
120
|
+
# and the vertice order will still be (0, 1, 2, 3).
|
121
121
|
# @!attribute [rw] paragraphs
|
122
122
|
# @return [Array<Google::Cloud::Vision::V1::Paragraph>]
|
123
123
|
# List of paragraphs in this block (if this blocks is of type text).
|
@@ -159,15 +159,15 @@ module Google
|
|
159
159
|
# is represented as around the top-left corner as defined when the text is
|
160
160
|
# read in the 'natural' orientation.
|
161
161
|
# For example:
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
162
|
+
# * when the text is horizontal it might look like:
|
163
|
+
# 0----1
|
164
|
+
# | |
|
165
|
+
# 3----2
|
166
166
|
# * when it's rotated 180 degrees around the top-left corner it becomes:
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
167
|
+
# 2----3
|
168
|
+
# | |
|
169
|
+
# 1----0
|
170
|
+
# and the vertice order will still be (0, 1, 2, 3).
|
171
171
|
# @!attribute [rw] words
|
172
172
|
# @return [Array<Google::Cloud::Vision::V1::Word>]
|
173
173
|
# List of words in this paragraph.
|
@@ -185,15 +185,15 @@ module Google
|
|
185
185
|
# is represented as around the top-left corner as defined when the text is
|
186
186
|
# read in the 'natural' orientation.
|
187
187
|
# For example:
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
188
|
+
# * when the text is horizontal it might look like:
|
189
|
+
# 0----1
|
190
|
+
# | |
|
191
|
+
# 3----2
|
192
192
|
# * when it's rotated 180 degrees around the top-left corner it becomes:
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
193
|
+
# 2----3
|
194
|
+
# | |
|
195
|
+
# 1----0
|
196
|
+
# and the vertice order will still be (0, 1, 2, 3).
|
197
197
|
# @!attribute [rw] symbols
|
198
198
|
# @return [Array<Google::Cloud::Vision::V1::Symbol>]
|
199
199
|
# List of symbols in the word.
|
@@ -212,15 +212,15 @@ module Google
|
|
212
212
|
# is represented as around the top-left corner as defined when the text is
|
213
213
|
# read in the 'natural' orientation.
|
214
214
|
# For example:
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
215
|
+
# * when the text is horizontal it might look like:
|
216
|
+
# 0----1
|
217
|
+
# | |
|
218
|
+
# 3----2
|
219
219
|
# * when it's rotated 180 degrees around the top-left corner it becomes:
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
220
|
+
# 2----3
|
221
|
+
# | |
|
222
|
+
# 1----0
|
223
|
+
# and the vertice order will still be (0, 1, 2, 3).
|
224
224
|
# @!attribute [rw] text
|
225
225
|
# @return [String]
|
226
226
|
# The actual UTF-8 representation of the symbol.
|
@@ -49,6 +49,16 @@ module Google
|
|
49
49
|
# any.Unpack(foo)
|
50
50
|
# ...
|
51
51
|
#
|
52
|
+
# Example 4: Pack and unpack a message in Go
|
53
|
+
#
|
54
|
+
# foo := &pb.Foo{...}
|
55
|
+
# any, err := ptypes.MarshalAny(foo)
|
56
|
+
# ...
|
57
|
+
# foo := &pb.Foo{}
|
58
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
59
|
+
# ...
|
60
|
+
# }
|
61
|
+
#
|
52
62
|
# The pack methods provided by protobuf library will by default use
|
53
63
|
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
54
64
|
# methods only use the fully qualified type name after the last '/'
|
@@ -77,7 +87,7 @@ module Google
|
|
77
87
|
# If the embedded message type is well-known and has a custom JSON
|
78
88
|
# representation, that representation will be embedded adding a field
|
79
89
|
# +value+ which holds the custom JSON in addition to the +@type+
|
80
|
-
# field. Example (for message Google::Protobuf::Duration):
|
90
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
81
91
|
#
|
82
92
|
# {
|
83
93
|
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
@@ -96,7 +106,7 @@ module Google
|
|
96
106
|
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
97
107
|
# The name should be in a canonical form (e.g., leading "." is
|
98
108
|
# not accepted).
|
99
|
-
# * An HTTP GET on the URL must yield a Google::Protobuf::Type
|
109
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
100
110
|
# value in binary format, or produce an error.
|
101
111
|
# * Applications are allowed to cache lookup results based on the
|
102
112
|
# URL, or have them precompiled into a binary to avoid any
|
@@ -16,22 +16,22 @@ module Google
|
|
16
16
|
module Rpc
|
17
17
|
# The +Status+ type defines a logical error model that is suitable for different
|
18
18
|
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
-
#
|
19
|
+
# [gRPC](https://github.com/grpc). The error model is designed to be:
|
20
20
|
#
|
21
|
-
#
|
22
|
-
#
|
21
|
+
# * Simple to use and understand for most users
|
22
|
+
# * Flexible enough to meet unexpected needs
|
23
23
|
#
|
24
24
|
# = Overview
|
25
25
|
#
|
26
26
|
# The +Status+ message contains three pieces of data: error code, error message,
|
27
27
|
# and error details. The error code should be an enum value of
|
28
|
-
# Google::Rpc::Code, but it may accept additional error codes if needed. The
|
28
|
+
# {Google::Rpc::Code}, but it may accept additional error codes if needed. The
|
29
29
|
# error message should be a developer-facing English message that helps
|
30
30
|
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
31
|
# error message is needed, put the localized message in the error details or
|
32
32
|
# localize it in the client. The optional error details may contain arbitrary
|
33
33
|
# information about the error. There is a predefined set of error detail types
|
34
|
-
# in the package +google.rpc+
|
34
|
+
# in the package +google.rpc+ that can be used for common error conditions.
|
35
35
|
#
|
36
36
|
# = Language mapping
|
37
37
|
#
|
@@ -49,35 +49,35 @@ module Google
|
|
49
49
|
#
|
50
50
|
# Example uses of this error model include:
|
51
51
|
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
52
|
+
# * Partial errors. If a service needs to return partial errors to the client,
|
53
|
+
# it may embed the +Status+ in the normal response to indicate the partial
|
54
|
+
# errors.
|
55
55
|
#
|
56
|
-
#
|
57
|
-
#
|
56
|
+
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting.
|
58
58
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
59
|
+
# * Batch operations. If a client uses batch request and batch response, the
|
60
|
+
# +Status+ message should be used directly inside batch response, one for
|
61
|
+
# each error sub-response.
|
62
62
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
63
|
+
# * Asynchronous operations. If an API call embeds asynchronous operation
|
64
|
+
# results in its response, the status of those operations should be
|
65
|
+
# represented directly using the +Status+ message.
|
66
66
|
#
|
67
|
-
#
|
68
|
-
#
|
67
|
+
# * Logging. If some API errors are stored in logs, the message +Status+ could
|
68
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
69
69
|
# @!attribute [rw] code
|
70
70
|
# @return [Integer]
|
71
|
-
# The status code, which should be an enum value of Google::Rpc::Code.
|
71
|
+
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
72
72
|
# @!attribute [rw] message
|
73
73
|
# @return [String]
|
74
74
|
# A developer-facing error message, which should be in English. Any
|
75
75
|
# user-facing error message should be localized and sent in the
|
76
|
-
# Google::Rpc::Status#details field, or localized by the client.
|
76
|
+
# {Google::Rpc::Status#details} field, or localized by the client.
|
77
77
|
# @!attribute [rw] details
|
78
78
|
# @return [Array<Google::Protobuf::Any>]
|
79
|
-
# A list of messages that carry the error details. There
|
80
|
-
#
|
79
|
+
# A list of messages that carry the error details. There is a common set of
|
80
|
+
# message types for APIs to use.
|
81
81
|
class Status; end
|
82
82
|
end
|
83
83
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
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
|
+
# http://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
|
+
module Google
|
16
|
+
module Cloud
|
17
|
+
# rubocop:disable LineLength
|
18
|
+
|
19
|
+
##
|
20
|
+
# # Ruby Client for Google Cloud Vision API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
21
|
+
#
|
22
|
+
# [Google Cloud Vision API][Product Documentation]:
|
23
|
+
# Integrates Google Vision features, including image labeling, face, logo, and
|
24
|
+
# landmark detection, optical character recognition (OCR), and detection of
|
25
|
+
# explicit content, into applications.
|
26
|
+
# - [Product Documentation][]
|
27
|
+
#
|
28
|
+
# ## Quick Start
|
29
|
+
# In order to use this library, you first need to go through the following
|
30
|
+
# steps:
|
31
|
+
#
|
32
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
33
|
+
# 2. [Enable the Google Cloud Vision API.](https://console.cloud.google.com/apis/api/vision)
|
34
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
35
|
+
#
|
36
|
+
# ### Installation
|
37
|
+
# ```
|
38
|
+
# $ gem install google-cloud-vision
|
39
|
+
# ```
|
40
|
+
#
|
41
|
+
# ### Preview
|
42
|
+
# #### ImageAnnotatorClient
|
43
|
+
# ```rb
|
44
|
+
# require "google/cloud/vision"
|
45
|
+
#
|
46
|
+
# image_annotator_client = Google::Cloud::Vision.new
|
47
|
+
# gcs_image_uri = "gs://gapic-toolkit/President_Barack_Obama.jpg"
|
48
|
+
# source = { gcs_image_uri: gcs_image_uri }
|
49
|
+
# image = { source: source }
|
50
|
+
# type = :FACE_DETECTION
|
51
|
+
# features_element = { type: type }
|
52
|
+
# features = [features_element]
|
53
|
+
# requests_element = { image: image, features: features }
|
54
|
+
# requests = [requests_element]
|
55
|
+
# response = image_annotator_client.batch_annotate_images(requests)
|
56
|
+
# ```
|
57
|
+
#
|
58
|
+
# ### Next Steps
|
59
|
+
# - Read the [Google Cloud Vision API Product documentation][Product Documentation]
|
60
|
+
# to learn more about the product and see How-to Guides.
|
61
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
62
|
+
# to see the full list of Cloud APIs that we cover.
|
63
|
+
#
|
64
|
+
# [Product Documentation]: https://cloud.google.com/vision
|
65
|
+
#
|
66
|
+
#
|
67
|
+
module Vision
|
68
|
+
module V1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -28,6 +28,7 @@ require "pathname"
|
|
28
28
|
require "google/gax"
|
29
29
|
|
30
30
|
require "google/cloud/vision/v1/image_annotator_pb"
|
31
|
+
require "google/cloud/vision/credentials"
|
31
32
|
|
32
33
|
module Google
|
33
34
|
module Cloud
|
@@ -53,18 +54,28 @@ module Google
|
|
53
54
|
# The scopes needed to make gRPC calls to all of the methods defined in
|
54
55
|
# this service.
|
55
56
|
ALL_SCOPES = [
|
56
|
-
"https://www.googleapis.com/auth/cloud-platform"
|
57
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
58
|
+
"https://www.googleapis.com/auth/cloud-vision"
|
57
59
|
].freeze
|
58
60
|
|
59
|
-
# @param
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# A
|
65
|
-
#
|
66
|
-
# A
|
67
|
-
#
|
61
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
62
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
63
|
+
# be many types.
|
64
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
65
|
+
# authenticating requests made by this client.
|
66
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
67
|
+
# credentials for this client.
|
68
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
69
|
+
# credentials for this client.
|
70
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
71
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
72
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
73
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
74
|
+
# metadata for requests, generally, to give OAuth credentials.
|
75
|
+
# @param scopes [Array<String>]
|
76
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
77
|
+
# an updater_proc is supplied.
|
78
|
+
# @param client_config [Hash]
|
68
79
|
# A Hash for call options for each method. See
|
69
80
|
# Google::Gax#construct_settings for the structure of
|
70
81
|
# this data. Falls back to the default config if not specified
|
@@ -76,11 +87,11 @@ module Google
|
|
76
87
|
port: DEFAULT_SERVICE_PORT,
|
77
88
|
channel: nil,
|
78
89
|
chan_creds: nil,
|
90
|
+
updater_proc: nil,
|
91
|
+
credentials: nil,
|
79
92
|
scopes: ALL_SCOPES,
|
80
93
|
client_config: {},
|
81
94
|
timeout: DEFAULT_TIMEOUT,
|
82
|
-
app_name: nil,
|
83
|
-
app_version: nil,
|
84
95
|
lib_name: nil,
|
85
96
|
lib_version: ""
|
86
97
|
# These require statements are intentionally placed here to initialize
|
@@ -89,14 +100,38 @@ module Google
|
|
89
100
|
require "google/gax/grpc"
|
90
101
|
require "google/cloud/vision/v1/image_annotator_services_pb"
|
91
102
|
|
103
|
+
if channel || chan_creds || updater_proc
|
104
|
+
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
105
|
+
"on 2017/09/08"
|
106
|
+
credentials ||= channel
|
107
|
+
credentials ||= chan_creds
|
108
|
+
credentials ||= updater_proc
|
109
|
+
end
|
110
|
+
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
111
|
+
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
112
|
+
end
|
92
113
|
|
93
|
-
|
94
|
-
|
114
|
+
credentials ||= Google::Cloud::Vision::Credentials.default
|
115
|
+
|
116
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
117
|
+
updater_proc = Google::Cloud::Vision::Credentials.new(credentials).updater_proc
|
118
|
+
end
|
119
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
120
|
+
channel = credentials
|
121
|
+
end
|
122
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
123
|
+
chan_creds = credentials
|
124
|
+
end
|
125
|
+
if credentials.is_a?(Proc)
|
126
|
+
updater_proc = credentials
|
127
|
+
end
|
128
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
129
|
+
updater_proc = credentials.updater_proc
|
95
130
|
end
|
96
131
|
|
97
132
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
98
133
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
99
|
-
google_api_client << " gapic/0.
|
134
|
+
google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
|
100
135
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
101
136
|
google_api_client.freeze
|
102
137
|
|
@@ -120,6 +155,7 @@ module Google
|
|
120
155
|
port,
|
121
156
|
chan_creds: chan_creds,
|
122
157
|
channel: channel,
|
158
|
+
updater_proc: updater_proc,
|
123
159
|
scopes: scopes,
|
124
160
|
&Google::Cloud::Vision::V1::ImageAnnotator::Stub.method(:new)
|
125
161
|
)
|
@@ -134,28 +170,29 @@ module Google
|
|
134
170
|
|
135
171
|
# Run image detection and annotation for a batch of images.
|
136
172
|
#
|
137
|
-
# @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest>]
|
173
|
+
# @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
|
138
174
|
# Individual image annotation requests for this batch.
|
175
|
+
# A hash of the same form as `Google::Cloud::Vision::V1::AnnotateImageRequest`
|
176
|
+
# can also be provided.
|
139
177
|
# @param options [Google::Gax::CallOptions]
|
140
178
|
# Overrides the default settings for this call, e.g, timeout,
|
141
179
|
# retries, etc.
|
142
180
|
# @return [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
|
143
181
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
144
182
|
# @example
|
145
|
-
# require "google/cloud/vision/v1
|
146
|
-
#
|
147
|
-
# ImageAnnotatorClient = Google::Cloud::Vision::V1::ImageAnnotatorClient
|
183
|
+
# require "google/cloud/vision/v1"
|
148
184
|
#
|
149
|
-
# image_annotator_client =
|
185
|
+
# image_annotator_client = Google::Cloud::Vision::V1.new
|
150
186
|
# requests = []
|
151
187
|
# response = image_annotator_client.batch_annotate_images(requests)
|
152
188
|
|
153
189
|
def batch_annotate_images \
|
154
190
|
requests,
|
155
191
|
options: nil
|
156
|
-
req =
|
192
|
+
req = {
|
157
193
|
requests: requests
|
158
|
-
}.delete_if { |_, v| v.nil? }
|
194
|
+
}.delete_if { |_, v| v.nil? }
|
195
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::BatchAnnotateImagesRequest)
|
159
196
|
@batch_annotate_images.call(req, options)
|
160
197
|
end
|
161
198
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-vision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: google-gax
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 0.10.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.
|
41
|
+
version: 0.10.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/google/cloud/vision/v1/doc/google/rpc/status.rb
|
204
204
|
- lib/google/cloud/vision/v1/doc/google/type/color.rb
|
205
205
|
- lib/google/cloud/vision/v1/doc/google/type/latlng.rb
|
206
|
+
- lib/google/cloud/vision/v1/doc/overview.rb
|
206
207
|
- lib/google/cloud/vision/v1/geometry_pb.rb
|
207
208
|
- lib/google/cloud/vision/v1/image_annotator_client.rb
|
208
209
|
- lib/google/cloud/vision/v1/image_annotator_client_config.json
|
@@ -231,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
232
|
version: '0'
|
232
233
|
requirements: []
|
233
234
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.7.2
|
235
236
|
signing_key:
|
236
237
|
specification_version: 4
|
237
238
|
summary: API Client library for Google Cloud Vision API
|