Module: Google::Cloud

Defined in:
lib/google-cloud-vision.rb,
lib/google/cloud/vision.rb,
lib/google/cloud/vision/image.rb,
lib/google/cloud/vision/project.rb,
lib/google/cloud/vision/service.rb,
lib/google/cloud/vision/version.rb,
lib/google/cloud/vision/annotate.rb,
lib/google/cloud/vision/location.rb,
lib/google/cloud/vision/annotation.rb,
lib/google/cloud/vision/credentials.rb,
lib/google/cloud/vision/annotation/face.rb,
lib/google/cloud/vision/annotation/text.rb,
lib/google/cloud/vision/annotation/entity.rb,
lib/google/cloud/vision/annotation/vertex.rb,
lib/google/cloud/vision/annotation/properties.rb,
lib/google/cloud/vision/annotation/safe_search.rb

Defined Under Namespace

Modules: Vision

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.vision(project = nil, keyfile = nil, scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Vision::Project

Creates a new object for connecting to the Vision service. Each call creates a new connection.

Examples:

require "google/cloud"

vision = Google::Cloud.vision

image = vision.image "path/to/landmark.jpg"

landmark = image.landmark
landmark.description #=> "Mount Rushmore"

Parameters:

  • project (String) (defaults to: nil)

    Project identifier for the Vision service you are connecting to.

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud-platform
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



100
101
102
103
104
105
106
# File 'lib/google-cloud-vision.rb', line 100

def self.vision project = nil, keyfile = nil, scope: nil, timeout: nil,
                client_config: nil
  require "google/cloud/vision"
  Google::Cloud::Vision.new project: project, keyfile: keyfile,
                            scope: scope, timeout: timeout,
                            client_config: client_config
end

Instance Method Details

#vision(scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Vision::Project

Creates a new object for connecting to the Vision service. Each call creates a new connection.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
vision = gcloud.vision

image = vision.image "path/to/landmark.jpg"

landmark = image.landmark
landmark.description #=> "Mount Rushmore"

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
vision = gcloud.vision scope: platform_scope

Parameters:

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud-platform
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



62
63
64
65
66
# File 'lib/google-cloud-vision.rb', line 62

def vision scope: nil, timeout: nil, client_config: nil
  Google::Cloud.vision @project, @keyfile, scope: scope,
                                           timeout: (timeout || @timeout),
                                           client_config: client_config
end