Class: OpenCV::Cv::EM

Inherits:
Object
  • Object
show all
Extended by:
FFI::DataConverter
Defined in:
lib/ruby/ropencv/ropencv_types.rb

Constants collapse

COV_MAT_SPHERICAL =
0
COV_MAT_DIAGONAL =
1
COV_MAT_GENERIC =
2
COV_MAT_DEFAULT =
COV_MAT_DIAGONAL
DEFAULT_NCLUSTERS =
5
DEFAULT_MAX_ITERS =
100
START_E_STEP =
1
START_M_STEP =
2
START_AUTO_STEP =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ EM

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EM.



13318
13319
13320
13321
13322
13323
13324
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13318

def initialize(ptr)
    @__obj_ptr__ = if ptr.is_a? EMStruct
                       ptr
                   else
                       EMStruct.new(FFI::AutoPointer.new(ptr,EMStruct.method(:release)))
                   end
end

Instance Attribute Details

#__obj_ptr__Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13315
13316
13317
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13315

def __obj_ptr__
  @__obj_ptr__
end

Class Method Details

._create(name) ⇒ Object

wrapper for Ptr_Algorithm cv::EM::_create(const cv::String name)



13490
13491
13492
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13490

def self._create(name)
    Rbind::cv_em__create(name)
end

.from_native(ptr, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

can be overwritten by the user



13310
13311
13312
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13310

def self.from_native(ptr,context)
    rbind_from_native(ptr,context)
end

.get_list(algorithms) ⇒ Object

wrapper for void cv::EM::getList(vector_string algorithms)



13485
13486
13487
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13485

def self.get_list(algorithms)
    Rbind::cv_em_get_list(algorithms)
end

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13267

def self.new(*args)
    if args.first.is_a?(FFI::Pointer) || args.first.is_a?(EMStruct)
        raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1
        return super(args.first)
    end
    # wrapper for cv::EM::EM(int nclusters=EM::DEFAULT_NCLUSTERS, int covMatType=EM::COV_MAT_DIAGONAL, const cv::TermCriteria termCrit=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, EM::DEFAULT_MAX_ITERS, FLT_EPSILON))
    @@cv_em_em_defaults0 ||= [EM::DEFAULT_NCLUSTERS, EM::COV_MAT_DIAGONAL, Cv::TermCriteria.new(TermCriteria::COUNT+TermCriteria::EPS, EM::DEFAULT_MAX_ITERS, FLT_EPSILON)]
    if(args.size >= 0 && args.size <= 3)
        args.size.upto(2) do |i|
            args[i] = @@cv_em_em_defaults0[i]
        end
        begin
            return Rbind::cv_em_em(*args)
        rescue TypeError => e
            @error = e
        end
    end

    raise ArgumentError, "no constructor for #{self}(#{args.inspect})"
end

.rbind_from_native(ptr, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13298
13299
13300
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13298

def self.rbind_from_native(ptr,context)
    EM.new(ptr)
end

.rbind_to_native(obj, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13289
13290
13291
13292
13293
13294
13295
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13289

def self.rbind_to_native(obj,context)
    if obj.is_a? EM
        obj.__obj_ptr__
    else
        raise TypeError, "expected kind of #{name}, was #{obj.class}"
    end
end

.to_native(obj, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

can be overwritten by the user



13304
13305
13306
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13304

def self.to_native(obj,context)
    rbind_to_native(obj,context)
end

Instance Method Details

#__owner__?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

returns true if the underlying pointer is owner of the real object

Returns:

  • (Boolean)


13329
13330
13331
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13329

def __owner__?
    @__obj_ptr__[:bowner]
end

#clearObject

methods wrapper for void cv::EM::clear()



13352
13353
13354
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13352

def clear()
    Rbind::cv_em_clear( self)
end

#get_algorithm(name) ⇒ Object

wrapper for Ptr_Algorithm cv::EM::getAlgorithm(const cv::String name)



13424
13425
13426
13427
13428
13429
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13424

def get_algorithm(name)
    result = Rbind::cv_em_get_algorithm( self, name)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#get_bool(name) ⇒ Object

wrapper for bool cv::EM::getBool(const cv::String name)



13395
13396
13397
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13395

def get_bool(name)
    Rbind::cv_em_get_bool( self, name)
end

#get_double(name) ⇒ Object

wrapper for double cv::EM::getDouble(const cv::String name)



13390
13391
13392
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13390

def get_double(name)
    Rbind::cv_em_get_double( self, name)
end

#get_int(name) ⇒ Object

wrapper for int cv::EM::getInt(const cv::String name)



13385
13386
13387
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13385

def get_int(name)
    Rbind::cv_em_get_int( self, name)
end

#get_mat(name) ⇒ Object

wrapper for cv::Mat cv::EM::getMat(const cv::String name)



13408
13409
13410
13411
13412
13413
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13408

def get_mat(name)
    result = Rbind::cv_em_get_mat( self, name)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#get_mat_vector(name) ⇒ Object

wrapper for vector_Mat cv::EM::getMatVector(const cv::String name)



13416
13417
13418
13419
13420
13421
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13416

def get_mat_vector(name)
    result = Rbind::cv_em_get_mat_vector( self, name)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#get_params(names) ⇒ Object

wrapper for void cv::EM::getParams(vector_string names)



13480
13481
13482
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13480

def get_params(names)
    Rbind::cv_em_get_params( self, names)
end

#get_string(name) ⇒ Object

wrapper for cv::String cv::EM::getString(const cv::String name)



13400
13401
13402
13403
13404
13405
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13400

def get_string(name)
    result = Rbind::cv_em_get_string( self, name)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#is_trainedObject

wrapper for bool cv::EM::isTrained()



13380
13381
13382
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13380

def is_trained()
    Rbind::cv_em_is_trained( self)
end

#param_help(name) ⇒ Object

wrapper for cv::String cv::EM::paramHelp(const cv::String name)



13467
13468
13469
13470
13471
13472
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13467

def param_help(name)
    result = Rbind::cv_em_param_help( self, name)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#param_type(name) ⇒ Object

wrapper for int cv::EM::paramType(const cv::String name)



13475
13476
13477
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13475

def param_type(name)
    Rbind::cv_em_param_type( self, name)
end

#predict(sample, probs = Cv::Mat.new()) ⇒ Object

wrapper for cv::Vec2d cv::EM::predict(const cv::Mat sample, cv::Mat probs=Mat())



13372
13373
13374
13375
13376
13377
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13372

def predict(sample, probs = Cv::Mat.new())
    result = Rbind::cv_em_predict( self, sample, probs)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#set_algorithm(name, value) ⇒ Object

wrapper for void cv::EM::setAlgorithm(const cv::String name, const Ptr_Algorithm value)



13462
13463
13464
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13462

def set_algorithm(name, value)
    Rbind::cv_em_set_algorithm( self, name, value)
end

#set_bool(name, value) ⇒ Object

wrapper for void cv::EM::setBool(const cv::String name, bool value)



13442
13443
13444
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13442

def set_bool(name, value)
    Rbind::cv_em_set_bool( self, name, value)
end

#set_double(name, value) ⇒ Object

wrapper for void cv::EM::setDouble(const cv::String name, double value)



13437
13438
13439
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13437

def set_double(name, value)
    Rbind::cv_em_set_double( self, name, value)
end

#set_int(name, value) ⇒ Object

wrapper for void cv::EM::setInt(const cv::String name, int value)



13432
13433
13434
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13432

def set_int(name, value)
    Rbind::cv_em_set_int( self, name, value)
end

#set_mat(name, value) ⇒ Object

wrapper for void cv::EM::setMat(const cv::String name, const cv::Mat value)



13452
13453
13454
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13452

def set_mat(name, value)
    Rbind::cv_em_set_mat( self, name, value)
end

#set_mat_vector(name, value) ⇒ Object

wrapper for void cv::EM::setMatVector(const cv::String name, const vector_Mat value)



13457
13458
13459
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13457

def set_mat_vector(name, value)
    Rbind::cv_em_set_mat_vector( self, name, value)
end

#set_string(name, value) ⇒ Object

wrapper for void cv::EM::setString(const cv::String name, const cv::String value)



13447
13448
13449
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13447

def set_string(name, value)
    Rbind::cv_em_set_string( self, name, value)
end

#train(samples, log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new()) ⇒ Object

wrapper for bool cv::EM::train(const cv::Mat samples, cv::Mat logLikelihoods=Mat(), cv::Mat labels=Mat(), cv::Mat probs=Mat())



13357
13358
13359
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13357

def train(samples, log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new())
    Rbind::cv_em_train( self, samples, log_likelihoods, labels, probs)
end

#traine(samples, _means0, _covs0 = Cv::Mat.new(), _weights0 = Cv::Mat.new(), log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new()) ⇒ Object

wrapper for bool cv::EM::trainE(const cv::Mat samples, const cv::Mat means0, const cv::Mat covs0=Mat(), const cv::Mat weights0=Mat(), cv::Mat logLikelihoods=Mat(), cv::Mat labels=Mat(), cv::Mat probs=Mat())



13362
13363
13364
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13362

def traine(samples, _means0, _covs0 = Cv::Mat.new(), _weights0 = Cv::Mat.new(), log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new())
    Rbind::cv_em_traine( self, samples, _means0, _covs0, _weights0, log_likelihoods, labels, probs)
end

#trainm(samples, _probs0, log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new()) ⇒ Object

wrapper for bool cv::EM::trainM(const cv::Mat samples, const cv::Mat probs0, cv::Mat logLikelihoods=Mat(), cv::Mat labels=Mat(), cv::Mat probs=Mat())



13367
13368
13369
# File 'lib/ruby/ropencv/ropencv_types.rb', line 13367

def trainm(samples, _probs0, log_likelihoods = Cv::Mat.new(), labels = Cv::Mat.new(), probs = Cv::Mat.new())
    Rbind::cv_em_trainm( self, samples, _probs0, log_likelihoods, labels, probs)
end