Class: Google::Cloud::Vision::Project
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Project
- Defined in:
- lib/google/cloud/vision/project.rb
Overview
Project
Google Cloud Vision allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.
See Google::Cloud#vision
Instance Method Summary collapse
-
#annotate(*images, faces: false, landmarks: false, logos: false, labels: false, text: false, document: false, safe_search: false, properties: false, crop_hints: false, web: false) {|annotate| ... } ⇒ Annotation+
(also: #mark, #detect)
Performs detection of Cloud Vision features on the given image(s).
-
#async_batch_annotate_files(requests, options = {}) ⇒ Google::Gax::Operation
Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page.
-
#image(source) ⇒ Image
Returns a new image from the given source.
-
#project_id ⇒ Object
(also: #project)
The Vision project connected to.
Instance Method Details
#annotate(*images, faces: false, landmarks: false, logos: false, labels: false, text: false, document: false, safe_search: false, properties: false, crop_hints: false, web: false) {|annotate| ... } ⇒ Annotation+ Also known as: mark, detect
Performs detection of Cloud Vision
features
on the given image(s). If no options for features are provided,
all image detection features will be performed, with a default of
100
results for faces, landmarks, logos, labels, crop_hints, and
web. If any feature option is provided, only the specified feature
detections will be performed. Please review
Pricing before use, as
a separate charge is incurred for each feature performed on an image.
Cloud Vision sets upper limits on file size as well as on the total combined size of all images in a request. Reducing your file size can significantly improve throughput; however, be careful not to reduce image quality in the process. See Best Practices - Image Sizing for current file size limits.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/google/cloud/vision/project.rb', line 257 def annotate *images, faces: false, landmarks: false, logos: false, labels: false, text: false, document: false, safe_search: false, properties: false, crop_hints: false, web: false a = Annotate.new self a.annotate(*images, faces: faces, landmarks: landmarks, logos: logos, labels: labels, text: text, document: document, safe_search: safe_search, properties: properties, crop_hints: crop_hints, web: web) yield a if block_given? grpc = service.annotate a.requests annotations = Array(grpc.responses).map do |g| raise Error.from_error(g.error) if g.error Annotation.from_grpc g end return annotations.first if annotations.count == 1 annotations end |
#async_batch_annotate_files(requests, options = {}) ⇒ Google::Gax::Operation
Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the google.longrunning.Operations interface. Operation.metadata contains OperationMetadata (metadata). Operation.response contains AsyncBatchAnnotateFilesResponse (results).
345 346 347 |
# File 'lib/google/cloud/vision/project.rb', line 345 def async_batch_annotate_files requests, = {} service.service.async_batch_annotate_files requests, end |
#image(source) ⇒ Image
Returns a new image from the given source.
Cloud Vision sets upper limits on file size as well as on the total combined size of all images in a request. Reducing your file size can significantly improve throughput; however, be careful not to reduce image quality in the process. See Best Practices - Image Sizing for current file size limits.
Note that an object in Google Cloud Storage is a single entity; permissions affect only that object. "Directory permissions" do not exist (though default bucket permissions do exist). Make sure the code which performs your request has access to that image.
124 125 126 127 |
# File 'lib/google/cloud/vision/project.rb', line 124 def image source return source if source.is_a? Image Image.from_source source, self end |
#project_id ⇒ Object Also known as: project
The Vision project connected to.
71 72 73 |
# File 'lib/google/cloud/vision/project.rb', line 71 def project_id service.project end |