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.



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

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.



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

def center
  @center
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#bottom_rightObject



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

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

#to_sObject



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

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

#top_leftObject



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

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