Class: Google::Cloud::Vision::Image
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Image
- Defined in:
- lib/google/cloud/vision/image.rb,
lib/google/cloud/vision/image.rb
Overview
Image
Represents an image for the Vision service.
See Project#image.
The Cloud Vision API supports a variety of image file formats, including JPEG, PNG8, PNG24, Animated GIF (first frame only), and RAW. See Best Practices - Image Types for the list of formats. Be aware that Cloud Vision sets upper limits on file size as well as 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.
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#context ⇒ Context
readonly
Returns the image context for the image, which accepts metadata values such as location and language hints.
Instance Method Summary collapse
-
#face ⇒ Annotation::Face
Performs the
FACE_DETECTION
feature on the image and returns only the first result. -
#faces(max_results = Google::Cloud::Vision.default_max_faces) ⇒ Array<Annotation::Face>
Performs the
FACE_DETECTION
feature on the image. -
#label ⇒ Annotation::Entity
Performs the
LABEL_DETECTION
feature on the image and returns only the first result. -
#labels(max_results = Google::Cloud::Vision.default_max_labels) ⇒ Array<Annotation::Entity>
Performs the
LABEL_DETECTION
feature on the image. -
#landmark ⇒ Annotation::Entity
Performs the
LANDMARK_DETECTION
feature on the image and returns only the first result. -
#landmarks(max_results = Google::Cloud::Vision.default_max_landmarks) ⇒ Array<Annotation::Entity>
Performs the
LANDMARK_DETECTION
feature on the image. -
#logo ⇒ Annotation::Entity
Performs the
LOGO_DETECTION
feature on the image and returns only the first result. -
#logos(max_results = Google::Cloud::Vision.default_max_logos) ⇒ Array<Annotation::Entity>
Performs the
LOGO_DETECTION
feature on the image. -
#properties ⇒ Annotation::Properties
Performs the
IMAGE_PROPERTIES
feature on the image. -
#safe_search ⇒ Annotation::SafeSearch
Performs the
SAFE_SEARCH_DETECTION
feature on the image. -
#text ⇒ Annotation::Text
Performs the
TEXT_DETECTION
(OCR) feature on the image.
Instance Attribute Details
#context ⇒ Context (readonly)
Returns the image context for the image, which accepts metadata values such as location and language hints.
63 64 65 |
# File 'lib/google/cloud/vision/image.rb', line 63 def context @context end |
Instance Method Details
#face ⇒ Annotation::Face
Performs the FACE_DETECTION
feature on the image and returns only
the first result.
123 124 125 |
# File 'lib/google/cloud/vision/image.rb', line 123 def face faces(1).first end |
#faces(max_results = Google::Cloud::Vision.default_max_faces) ⇒ Array<Annotation::Face>
Performs the FACE_DETECTION
feature on the image.
111 112 113 114 115 |
# File 'lib/google/cloud/vision/image.rb', line 111 def faces max_results = Google::Cloud::Vision.default_max_faces ensure_vision! annotation = @vision.mark self, faces: max_results annotation.faces end |
#label ⇒ Annotation::Entity
Performs the LABEL_DETECTION
feature on the image and returns only
the first result.
244 245 246 |
# File 'lib/google/cloud/vision/image.rb', line 244 def label labels(1).first end |
#labels(max_results = Google::Cloud::Vision.default_max_labels) ⇒ Array<Annotation::Entity>
Performs the LABEL_DETECTION
feature on the image.
232 233 234 235 236 |
# File 'lib/google/cloud/vision/image.rb', line 232 def labels max_results = Google::Cloud::Vision.default_max_labels ensure_vision! annotation = @vision.mark self, labels: max_results annotation.labels end |
#landmark ⇒ Annotation::Entity
Performs the LANDMARK_DETECTION
feature on the image and returns
only the first result.
163 164 165 |
# File 'lib/google/cloud/vision/image.rb', line 163 def landmark landmarks(1).first end |
#landmarks(max_results = Google::Cloud::Vision.default_max_landmarks) ⇒ Array<Annotation::Entity>
Performs the LANDMARK_DETECTION
feature on the image.
151 152 153 154 155 |
# File 'lib/google/cloud/vision/image.rb', line 151 def landmarks max_results = Google::Cloud::Vision.default_max_landmarks ensure_vision! annotation = @vision.mark self, landmarks: max_results annotation.landmarks end |
#logo ⇒ Annotation::Entity
Performs the LOGO_DETECTION
feature on the image and returns only
the first result.
203 204 205 |
# File 'lib/google/cloud/vision/image.rb', line 203 def logo logos(1).first end |
#logos(max_results = Google::Cloud::Vision.default_max_logos) ⇒ Array<Annotation::Entity>
Performs the LOGO_DETECTION
feature on the image.
191 192 193 194 195 |
# File 'lib/google/cloud/vision/image.rb', line 191 def logos max_results = Google::Cloud::Vision.default_max_logos ensure_vision! annotation = @vision.mark self, logos: max_results annotation.logos end |
#properties ⇒ Annotation::Properties
Performs the IMAGE_PROPERTIES
feature on the image.
324 325 326 327 328 |
# File 'lib/google/cloud/vision/image.rb', line 324 def properties ensure_vision! annotation = @vision.mark self, properties: true annotation.properties end |
#safe_search ⇒ Annotation::SafeSearch
Performs the SAFE_SEARCH_DETECTION
feature on the image.
295 296 297 298 299 |
# File 'lib/google/cloud/vision/image.rb', line 295 def safe_search ensure_vision! annotation = @vision.mark self, safe_search: true annotation.safe_search end |
#text ⇒ Annotation::Text
Performs the TEXT_DETECTION
(OCR) feature on the image.
270 271 272 273 274 |
# File 'lib/google/cloud/vision/image.rb', line 270 def text ensure_vision! annotation = @vision.mark self, text: true annotation.text end |