Class: CVFFI::SIFT::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/opencv-ffi-ext/sift.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(k, d) ⇒ Results

Returns a new instance of Results.



47
48
49
50
# File 'lib/opencv-ffi-ext/sift.rb', line 47

def initialize( k, d )
  @kps = k
  @descs = d
end

Instance Attribute Details

#descsObject

Returns the value of attribute descs.



45
46
47
# File 'lib/opencv-ffi-ext/sift.rb', line 45

def descs
  @descs
end

#kpsObject

Returns the value of attribute kps.



45
46
47
# File 'lib/opencv-ffi-ext/sift.rb', line 45

def kps
  @kps
end

Class Method Details

.from_a(a) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/opencv-ffi-ext/sift.rb', line 69

def self.from_a( a )
  a = YAML::load(a) if a.is_a? String
  raise "Don't know what to do" unless a.is_a? Array
  raise "Result isn't a two-element array" unless a.length == 2

  kps = a[0]
  descs = a[1]
end

Instance Method Details

#sizeObject Also known as: length



52
53
54
# File 'lib/opencv-ffi-ext/sift.rb', line 52

def size
  @kps.length
end

#to_aObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/opencv-ffi-ext/sift.rb', line 57

def to_a
  a = Array.new
  a << Array.new( size ) { |i|
    kp = kps[i]
    [ kp.x, kp.y, kp.mag, kp.orien, kp.num_bins, kp.scale ]
  }
  a << Array.new( size ) { |i|
    d = descs[i]
    [d.x, d.y, d.fv, d.fv_length]
  }
end