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.
154 155 156 157 158 159 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 154 def bounds return [] unless @grpc.bounding_poly @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v| Vertex.from_grpc 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.
131 132 133 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 131 def confidence @grpc.confidence end |
#description ⇒ String
Entity textual description, expressed in the #locale language.
111 112 113 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 111 def description @grpc.description end |
#locale ⇒ String
The language code for the locale in which the description
is
expressed.
102 103 104 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 102 def locale @grpc.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.
171 172 173 174 175 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 171 def locations @locations ||= Array(@grpc.locations).map do |l| Location.from_grpc l.lat_lng end end |
#mid ⇒ String
Opaque entity ID. Some IDs might be available in Knowledge Graph (KG).
90 91 92 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 90 def mid @grpc.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.
184 185 186 187 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 184 def properties @properties ||= Hash[Array(@grpc.properties).map { |p| [p.name, p.value] }] end |
#score ⇒ Float
Overall score of the result.
120 121 122 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 120 def score @grpc.score end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
194 195 196 197 198 199 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 194 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.
144 145 146 |
# File 'lib/google/cloud/vision/annotation/entity.rb', line 144 def topicality @grpc.topicality end |