Class: Gcloud::Vision::Annotation::Face::Bounds
- Inherits:
-
Object
- Object
- Gcloud::Vision::Annotation::Face::Bounds
- Defined in:
- lib/gcloud/vision/annotation/face.rb
Overview
Instance Attribute Summary collapse
Class Method Summary collapse
-
.from_gapi(gapi) ⇒ Object
object.
Instance Method Summary collapse
-
#face ⇒ Object
This bounding polygon is tighter than the #head, and encloses only the skin part of the face.
-
#head ⇒ Object
The bounding polygon around the face.
-
#initialize ⇒ Bounds
constructor
A new instance of Bounds.
- #inspect ⇒ Object
-
#to_a ⇒ Array
Returns the object’s property values as an array.
-
#to_ary ⇒ Array
Returns the object’s property values as an array.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#to_hash ⇒ Hash
Deeply converts object to a hash.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Bounds
Returns a new instance of Bounds.
279 280 281 |
# File 'lib/gcloud/vision/annotation/face.rb', line 279 def initialize @gapi = {} end |
Instance Attribute Details
#gapi ⇒ Object
275 276 277 |
# File 'lib/gcloud/vision/annotation/face.rb', line 275 def gapi @gapi end |
Class Method Details
.from_gapi(gapi) ⇒ Object
object.
360 361 362 |
# File 'lib/gcloud/vision/annotation/face.rb', line 360 def self.from_gapi gapi new.tap { |f| f.instance_variable_set :@gapi, gapi } end |
Instance Method Details
#face ⇒ Object
This bounding polygon is tighter than the #head, and encloses only the skin part of the face. Typically, it is used to eliminate the face from any image annotation that detects the “amount of skin” visible in an image. It is not based on the landmarks, only on the initial face detection.
304 305 306 307 308 309 |
# File 'lib/gcloud/vision/annotation/face.rb', line 304 def face return [] unless @gapi["fdBoundingPoly"] @face ||= Array(@gapi["fdBoundingPoly"]["vertices"]).map do |v| Vertex.from_gapi v end end |
#head ⇒ Object
The bounding polygon around the face. The coordinates of the bounding box are in the original image’s scale, as returned in ImageParams. The bounding box is computed to “frame” the face in accordance with human expectations. It is based on the landmarker results. Note that one or more x and/or y coordinates may not be generated in the BoundingPoly (the polygon will be unbounded) if only a partial face appears in the image to be annotated.
291 292 293 294 295 296 |
# File 'lib/gcloud/vision/annotation/face.rb', line 291 def head return [] unless @gapi["boundingPoly"] @head ||= Array(@gapi["boundingPoly"]["vertices"]).map do |v| Vertex.from_gapi v end end |
#inspect ⇒ Object
353 354 355 |
# File 'lib/gcloud/vision/annotation/face.rb', line 353 def inspect "#<Bounds #{self}>" end |
#to_a ⇒ Array
Returns the object’s property values as an array.
316 317 318 |
# File 'lib/gcloud/vision/annotation/face.rb', line 316 def to_a to_ary end |
#to_ary ⇒ Array
Returns the object’s property values as an array.
325 326 327 |
# File 'lib/gcloud/vision/annotation/face.rb', line 325 def to_ary [head.map(&:to_a), face.map(&:to_a)] end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
334 335 336 |
# File 'lib/gcloud/vision/annotation/face.rb', line 334 def to_h to_hash end |
#to_hash ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
343 344 345 |
# File 'lib/gcloud/vision/annotation/face.rb', line 343 def to_hash { head: head.map(&:to_h), face: face.map(&:to_h) } end |
#to_s ⇒ Object
348 349 350 |
# File 'lib/gcloud/vision/annotation/face.rb', line 348 def to_s "(head: #{head.inspect}, face: #{face.inspect})" end |