Class: Google::Cloud::Vision::Annotation::Entity
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Entity
- Defined in:
- lib/google/cloud/vision/annotation/entity.rb
Overview
Entity
Represents characteristics of an entity detected in an image. May describe a real-world entity such as a person, place, or thing. May be identified with an entity ID as an entity in the Knowledge Graph (KG).
Instance Method Summary collapse
-
#bounds ⇒ Array<Vertex>
Image region to which this entity belongs.
-
#confidence ⇒ Float
The accuracy of the entity detection in an image.
-
#description ⇒ String
Entity textual description, expressed in the #locale language.
-
#locale ⇒ String
The language code for the locale in which the
description
is expressed. -
#locations ⇒ Array<Location>
The location information for the detected entity.
-
#mid ⇒ String
Opaque entity ID.
-
#properties ⇒ Hash
Some entities can have additional optional Property fields.
-
#score ⇒ Float
Overall score of the result.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#topicality ⇒ Float
The relevancy of the ICA (Image Content Annotation) label to the image.
Instance Method Details
#bounds ⇒ Array<Vertex>
Image region to which this entity belongs. Not filled currently for
labels
detection.
157 158 159 160 161 162 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 157 def bounds return [] unless @gapi.bounding_poly @bounds ||= Array(@gapi.bounding_poly.vertices).map do |v| Vertex.from_gapi v end end |
#confidence ⇒ Float
The accuracy of the entity detection in an image. For example, for an image containing 'Eiffel Tower,' this field represents the confidence that there is a tower in the query image.
134 135 136 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 134 def confidence @gapi.confidence end |
#description ⇒ String
Entity textual description, expressed in the #locale language.
114 115 116 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 114 def description @gapi.description end |
#locale ⇒ String
The language code for the locale in which the description
is
expressed.
105 106 107 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 105 def locale @gapi.locale end |
#locations ⇒ Array<Location>
The location information for the detected entity. Multiple Location elements can be present since one location may indicate the location of the scene in the query image, and another the location of the place where the query image was taken. Location information is usually present for landmarks.
174 175 176 177 178 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 174 def locations @locations ||= Array(@gapi.locations).map do |l| Location.from_gapi l.lat_lng end end |
#mid ⇒ String
Opaque entity ID. Some IDs might be available in Knowledge Graph (KG).
93 94 95 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 93 def mid @gapi.mid end |
#properties ⇒ Hash
Some entities can have additional optional Property fields. For example a different kind of score or string that qualifies the entity. present for landmarks.
187 188 189 190 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 187 def properties @properties ||= Hash[Array(@gapi.properties).map { |p| [p.name, p.value] }] end |
#score ⇒ Float
Overall score of the result.
123 124 125 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 123 def score @gapi.score end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
197 198 199 200 201 202 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 197 def to_h { mid: mid, locale: locale, description: description, score: score, confidence: confidence, topicality: topicality, bounds: bounds.map(&:to_h), locations: locations.map(&:to_h), properties: properties } end |
#topicality ⇒ Float
The relevancy of the ICA (Image Content Annotation) label to the image. For example, the relevancy of 'tower' to an image containing 'Eiffel Tower' is likely higher than an image containing a distant towering building, though the confidence that there is a tower may be the same.
147 148 149 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 147 def topicality @gapi.topicality end |