Module: CVFFI::VectorMath

Extended by:
NiceFFI::Library
Defined in:
lib/opencv-ffi-ext/vector_math.rb

Defined Under Namespace

Modules: NativeVectors Classes: ScalarArray, UcharArray

Class Method Summary collapse

Class Method Details

.L2distance(a, b, len = nil) ⇒ Object



83
84
85
86
# File 'lib/opencv-ffi-ext/vector_math.rb', line 83

def self.L2distance( a,b, len = nil)
  len ||= a.length
  L2distance_32f( a, b, len )
end

.L2distance_8u(a, b) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/opencv-ffi-ext/vector_math.rb', line 102

def self.L2distance_8u( a,b )
  ## Allow for some dynamic repacking
  raise "Arrays not same length" unless a.length == b.length
  a = uchar_array_cast( a )
  b = uchar_array_cast( b ) 

  realL2distance_8u( a, b )
end

.uchar_array_cast(a) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/opencv-ffi-ext/vector_math.rb', line 88

def self.uchar_array_cast( a )
  case a
  when UcharArray
    a
  else
    d = FFI::MemoryPointer.new :uint8, a.length
    d.write_array_of_uint8( a )
    #d.write_array_of_uint8( a.map{ |a| [[ a.to_i, 0 ].max, 255].min }  ) 
    UcharArray.new( len: a.length, data: d )
  #else
  #  raise "Can't convert type #{a} to a uchar_array"
  end
end