Module: Google::Cloud::Vision::V1
- Defined in:
- lib/google/cloud/vision/v1.rb,
lib/google/cloud/vision/v1/credentials.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
Overview
Ruby Client for Cloud Vision API (Alpha)
Cloud Vision API: Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
Quick Start
In order to use this library, you first need to go through the following steps:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Cloud Vision API.
- Setup Authentication.
Preview
ImageAnnotatorClient
require "google/cloud/vision"
image_annotator_client = Google::Cloud::Vision.new(version: :v1)
gcs_image_uri = "gs://gapic-toolkit/President_Barack_Obama.jpg"
source = { gcs_image_uri: gcs_image_uri }
image = { source: source }
type = :FACE_DETECTION
features_element = { type: type }
features = [features_element]
requests_element = { image: image, features: features }
requests = [requests_element]
response = image_annotator_client.batch_annotate_images(requests)
Next Steps
- Read the Cloud Vision API Product documentation to learn more about the product and see How-to Guides.
- View this repository's main README to see the full list of Cloud APIs that we cover.
Enabling Logging
To enable logging for this library, set the logger for the underlying gRPC library.
The logger that you set may be a Ruby stdlib Logger
as shown below,
or a Google::Cloud::Logging::Logger
that will write logs to Stackdriver Logging. See grpc/logconfig.rb
and the gRPC spec_helper.rb for additional information.
Configuring a Ruby stdlib logger:
require "logger"
module MyLogger
LOGGER = Logger.new $stderr, level: Logger::WARN
def logger
LOGGER
end
end
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
module GRPC
extend MyLogger
end
Defined Under Namespace
Modules: Likelihood Classes: AnnotateFileResponse, AnnotateImageRequest, AnnotateImageResponse, AsyncAnnotateFileRequest, AsyncAnnotateFileResponse, AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, BatchAnnotateImagesRequest, BatchAnnotateImagesResponse, Block, BoundingPoly, ColorInfo, Credentials, CropHint, CropHintsAnnotation, CropHintsParams, DominantColorsAnnotation, EntityAnnotation, FaceAnnotation, Feature, GcsDestination, GcsSource, Image, ImageAnnotationContext, ImageAnnotatorClient, ImageContext, ImageProperties, ImageSource, InputConfig, LatLongRect, LocationInfo, NormalizedVertex, OperationMetadata, OutputConfig, Page, Paragraph, Position, Property, SafeSearchAnnotation, Symbol, TextAnnotation, Vertex, WebDetection, WebDetectionParams, Word
Class Method Summary collapse
-
.new(credentials: nil, scopes: nil, client_config: nil, timeout: nil, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: nil) ⇒ Object
Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection.
Class Method Details
.new(credentials: nil, scopes: nil, client_config: nil, timeout: nil, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: nil) ⇒ Object
Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service returns detected entities from the images.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/google/cloud/vision/v1.rb', line 129 def self.new \ credentials: nil, scopes: nil, client_config: nil, timeout: nil, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: nil kwargs = { credentials: credentials, scopes: scopes, client_config: client_config, timeout: timeout, metadata: , exception_transformer: exception_transformer, lib_name: lib_name, lib_version: lib_version }.select { |_, v| v != nil } Google::Cloud::Vision::V1::ImageAnnotatorClient.new(**kwargs) end |