Class: CVFFI::Rect

Inherits:
Object
  • Object
show all
Defined in:
lib/opencv-ffi-wrappers/core/rect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Rect

Returns a new instance of Rect.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opencv-ffi-wrappers/core/rect.rb', line 9

def initialize( args )
  case args
  when Array
    @origin = Point.new( args[0..1] )
    @size   = Size.new(  args[2..3] )
  when Hash
    if args[:size]
      @size = Size.new args[:size]
    else
      @size = Size.new(args)
    end

    if args[:origin] 
      @origin = Point.new( args[:origin] )
    elsif args[:center]
      @origin = Point.new( args[:center] - @size/2.0 )
    else
      @origin = Point.new(args)
    end

  else
    @size = Size.new args.size
    @origin = Point.new args.origin
  end
end

Instance Attribute Details

#originObject

Returns the value of attribute origin.



7
8
9
# File 'lib/opencv-ffi-wrappers/core/rect.rb', line 7

def origin
  @origin
end

#sizeObject

Returns the value of attribute size.



7
8
9
# File 'lib/opencv-ffi-wrappers/core/rect.rb', line 7

def size
  @size
end

Instance Method Details

#to_CvRectObject



35
36
37
38
# File 'lib/opencv-ffi-wrappers/core/rect.rb', line 35

def to_CvRect
  CvRect.new( :x => @origin.x, :y => @origin.y,
          :width => @size.width, :height => @size.height )
end