Class: Google::Cloud::Vision::Annotation::Face::Bounds
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Face::Bounds
- Defined in:
- lib/google/cloud/vision/annotation/face.rb
Overview
Instance Attribute Summary collapse
Class Method Summary collapse
-
.from_grpc(grpc) ⇒ 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_h ⇒ Hash
Deeply converts object to a hash.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Bounds
Returns a new instance of Bounds.
251 252 253 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 251 def initialize @grpc = nil end |
Instance Attribute Details
#grpc ⇒ Object
247 248 249 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 247 def grpc @grpc end |
Class Method Details
.from_grpc(grpc) ⇒ Object
object.
314 315 316 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 314 def self.from_grpc grpc new.tap { |f| f.instance_variable_set :@grpc, grpc } 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.
276 277 278 279 280 281 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 276 def face return [] unless @grpc.fd_bounding_poly @face ||= Array(@grpc.fd_bounding_poly.vertices).map do |v| Vertex.from_grpc 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.
263 264 265 266 267 268 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 263 def head return [] unless @grpc.bounding_poly @head ||= Array(@grpc.bounding_poly.vertices).map do |v| Vertex.from_grpc v end end |
#inspect ⇒ Object
307 308 309 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 307 def inspect "#<Bounds #{self}>" end |
#to_a ⇒ Array
Returns the object’s property values as an array.
288 289 290 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 288 def to_a [head.map(&:to_a), face.map(&:to_a)] end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
297 298 299 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 297 def to_h { head: head.map(&:to_h), face: face.map(&:to_h) } end |
#to_s ⇒ Object
302 303 304 |
# File 'lib/google/cloud/vision/annotation/face.rb', line 302 def to_s "(head: #{head.inspect}, face: #{face.inspect})" end |