Module: CVFFI::FAST

Extended by:
NiceFFI::Library
Defined in:
lib/opencv-ffi-fast/fast.rb,
lib/opencv-ffi-fast/version.rb

Defined Under Namespace

Classes: FASTResultsArray, Params, Xy

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.detect(img, params) ⇒ Object



58
59
60
# File 'lib/opencv-ffi-fast/fast.rb', line 58

def self.detect( img, params )
  FASTDetect( params.points, img, params.threshold )
end

.FAST10Detect(img, threshold) ⇒ Object



82
# File 'lib/opencv-ffi-fast/fast.rb', line 82

def self.FAST10Detect( img, threshold ); FASTDetect( 10, img, threshold ); end

.FAST11Detect(img, threshold) ⇒ Object



83
# File 'lib/opencv-ffi-fast/fast.rb', line 83

def self.FAST11Detect( img, threshold ); FASTDetect( 11, img, threshold ); end

.FAST12Detect(img, threshold) ⇒ Object



84
# File 'lib/opencv-ffi-fast/fast.rb', line 84

def self.FAST12Detect( img, threshold ); FASTDetect( 12, img, threshold ); end

.FAST9Detect(img, threshold) ⇒ Object



81
# File 'lib/opencv-ffi-fast/fast.rb', line 81

def self.FAST9Detect( img, threshold );  FASTDetect( 9, img, threshold ); end

.fast_detect_function(sz) ⇒ Object

Leave result as pointer, not Xy.typed_pointer as it makes it easier to deference it to an array of Xy



103
104
105
# File 'lib/opencv-ffi-fast/fast.rb', line 103

def self.fast_detect_function( sz )
  attach_function "fast#{sz}_detect".to_sym, [ :pointer, :int, :int, :int, :int, :pointer ], :pointer
end

.FASTDetect(size, img, threshold) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/opencv-ffi-fast/fast.rb', line 62

def self.FASTDetect( size, img, threshold )
  nResults = FFI::MemoryPointer.new :int

  if img.is_a?( IplImage )
    # Ensure the image is b&w
    img = img.ensure_greyscale

    results = FFI::Pointer.new :pointer, method("fast#{size}_detect").call( img.imageData, img.width, img.height, img.widthStep, threshold, nResults )
  else
    raise ArgumentError, "Don't know how to deal with image class #{img.class}"
  end

  # Dereference the two pointers
  nPoints = nResults.read_int
  points = FFI::Pointer.new Xy, results

  FASTResultsArray.new( points, nPoints )
end