Class: CVFFI::SURF::ResultsArray

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/opencv-ffi-wrappers/features2d/surf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#inject_with_index

Constructor Details

#initialize(kp, desc, pool, desc_type = Float64) ⇒ ResultsArray

Returns a new instance of ResultsArray.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 48

def initialize( kp, desc, pool, desc_type = Float64 )
  @kp = Sequence.new(kp)
  @desc = Sequence.new(desc)
  @pool = pool
  @desc_type = desc_type
  @results = Array.new( @kp.length )

  raise RuntimeError "SURF Keypoint and descriptor sequences different length (#{@kp.size} != #{@desc.size})" unless (@kp.size == @desc.size)

  destructor = Proc.new { poolPtr = FFI::MemoryPointer.new :pointer; poolPtr.putPointer( 0, @pool ); cvReleaseMemStorage( poolPtr ) }
  ObjectSpace.define_finalizer( self, destructor )
end

Instance Attribute Details

#descObject

Returns the value of attribute desc.



45
46
47
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 45

def desc
  @desc
end

#desc_typeObject

Returns the value of attribute desc_type.



46
47
48
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 46

def desc_type
  @desc_type
end

#kpObject

Returns the value of attribute kp.



45
46
47
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 45

def kp
  @kp
end

#poolObject

Returns the value of attribute pool.



45
46
47
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 45

def pool
  @pool
end

Instance Method Details

#[](i) ⇒ Object



71
72
73
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 71

def [](i)
  result(i)
end

#eachObject



65
66
67
68
69
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 65

def each
  @results.each_index { |i| 
    yield result(i) 
  }
end

#mark_on_image(img, opts) ⇒ Object



80
81
82
83
84
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 80

def mark_on_image( img, opts )
  each { |r|
    CVFFI::draw_circle( img, r.kp.pt, opts )
  }
end

#result(i) ⇒ Object



61
62
63
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 61

def result(i)
  @results[i] ||= Result.new( @kp[i], @desc_type.new( @desc[i] ) )
end

#sizeObject Also known as: length



75
76
77
# File 'lib/opencv-ffi-wrappers/features2d/surf.rb', line 75

def size
  @kp.size
end