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 Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#annotate(*images, faces: false, landmarks: false, logos: false, labels: false, text: false, safe_search: false, properties: false) {|annotate| ... } ⇒ Annotation+
(also: #mark, #detect)
Performs detection of Cloud Vision [features](cloud.google.com/vision/reference/rest/v1/images/annotate#Feature) on the given image(s).
-
#image(source) ⇒ Image
Returns a new image from the given source.
-
#initialize(service) ⇒ Project
constructor
A new instance of Project.
-
#project ⇒ Object
The Vision project connected to.
Constructor Details
#initialize(service) ⇒ Project
Returns a new instance of Project.
56 57 58 |
# File 'lib/google/cloud/vision/project.rb', line 56 def initialize service @service = service end |
Instance Attribute Details
#service ⇒ Object
52 53 54 |
# File 'lib/google/cloud/vision/project.rb', line 52 def service @service end |
Class Method Details
.default_project ⇒ Object
78 79 80 81 82 83 |
# File 'lib/google/cloud/vision/project.rb', line 78 def self.default_project ENV["VISION_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"] || ENV["GCLOUD_PROJECT"] || Google::Cloud::Core::Environment.project_id end |
Instance Method Details
#annotate(*images, faces: false, landmarks: false, logos: false, labels: false, text: false, safe_search: false, properties: false) {|annotate| ... } ⇒ Annotation+ Also known as: mark, detect
Performs detection of Cloud Vision [features](cloud.google.com/vision/reference/rest/v1/images/annotate#Feature) 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, and labels. If any feature option is provided, only the specified feature detections will be performed. Please review [Pricing](cloud.google.com/vision/docs/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](cloud.google.com/vision/docs/best-practices#image_sizing) for current file size limits.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/google/cloud/vision/project.rb', line 247 def annotate *images, faces: false, landmarks: false, logos: false, labels: false, text: false, safe_search: false, properties: false a = Annotate.new self a.annotate(*images, faces: faces, landmarks: landmarks, logos: logos, labels: labels, text: text, safe_search: safe_search, properties: properties) yield a if block_given? grpc = service.annotate a.requests annotations = Array(grpc.responses).map do |g| fail Error.from_error(g.error) if g.error Annotation.from_grpc g end return annotations.first if annotations.count == 1 annotations 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](cloud.google.com/vision/docs/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.
125 126 127 128 |
# File 'lib/google/cloud/vision/project.rb', line 125 def image source return source if source.is_a? Image Image.from_source source, self end |
#project ⇒ Object
The Vision project connected to.
72 73 74 |
# File 'lib/google/cloud/vision/project.rb', line 72 def project service.project end |