Module: Google::Cloud

Defined in:
lib/google-cloud-vision.rb,
lib/google/cloud/vision.rb,
lib/google/cloud/vision/v1.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/web.rb,
lib/google/cloud/vision/v1/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/crop_hint.rb,
lib/google/cloud/vision/annotation/properties.rb,
lib/google/cloud/vision/annotation/safe_search.rb,
lib/google/cloud/vision/v1/image_annotator_client.rb,
lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb,
lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb,
lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb,
lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb

Defined Under Namespace

Modules: Vision

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.vision(project_id = nil, credentials = 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_id (String) (defaults to: nil)

    Project identifier for the Vision service you are connecting to. If not present, the default project for the credentials is used.

  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil)

    The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Google::Cloud::Vision::Credentials)

  • 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:



104
105
106
107
108
109
110
111
# File 'lib/google-cloud-vision.rb', line 104

def self.vision project_id = nil, credentials = nil, scope: nil,
                timeout: nil, client_config: nil
  require "google/cloud/vision"
  Google::Cloud::Vision.new project_id: project_id,
                            credentials: credentials,
                            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:



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

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