Class: FaceCrop::Detector::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/face_crop.rb

Overview

Region

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ Region

Returns a new instance of Region.



59
60
61
62
# File 'lib/face_crop.rb', line 59

def initialize(x, y, width, height)
  @width, @height = width, height
  @center = Point.new(x, y)
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



54
55
56
# File 'lib/face_crop.rb', line 54

def center
  @center
end

#colorObject

Returns the value of attribute color.



57
58
59
# File 'lib/face_crop.rb', line 57

def color
  @color
end

#heightObject

Returns the value of attribute height.



56
57
58
# File 'lib/face_crop.rb', line 56

def height
  @height
end

#widthObject

Returns the value of attribute width.



55
56
57
# File 'lib/face_crop.rb', line 55

def width
  @width
end

Instance Method Details

#bottom_rightObject



68
69
70
# File 'lib/face_crop.rb', line 68

def bottom_right
  @bottom_right ||= Point.new(@center.x + (width / 2), @center.y + (height / 2))
end

#to_sObject



72
73
74
# File 'lib/face_crop.rb', line 72

def to_s
  "#{center.x},#{center.y}-#{width}x#{height}"
end

#top_leftObject



64
65
66
# File 'lib/face_crop.rb', line 64

def top_left
  @top_left ||= Point.new(@center.x - (width / 2), @center.y - (height / 2))
end