Class: CVFFI::ImagePatch::Params

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

Constant Summary collapse

DEFAULTS =
{ size: 9,
oriented: false,
shape: :square }

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Params

Returns a new instance of Params.



196
197
198
199
200
201
202
203
204
205
206
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 196

def initialize( opts = {} )

  @params = {}
  DEFAULTS.each_key { |k|
    @params[k] = (opts[k] or opts[k.to_s] or DEFAULTS[k])
    define_singleton_method( k ) { @params[k] }
  }

  # Ensure the shape is a symbol
  @params[:shape] = @params[:shape].to_sym
end

Instance Method Details

#check_paramsObject



208
209
210
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 208

def check_params
  raise "Image patches need to be odd" unless size.odd?
end

#to_hashObject



212
213
214
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 212

def to_hash
  @params
end