Class: OpenCV::CvDTree

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ CvDTree

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 CvDTree.



20577
20578
20579
20580
20581
20582
20583
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20577

def initialize(ptr)
    @__obj_ptr__ = if ptr.is_a? CvDTreeStruct
                       ptr
                   else
                       CvDTreeStruct.new(FFI::AutoPointer.new(ptr,CvDTreeStruct.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.



20574
20575
20576
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20574

def __obj_ptr__
  @__obj_ptr__
end

Class Method Details

.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



20569
20570
20571
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20569

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

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20526

def self.new(*args)
    if args.first.is_a?(FFI::Pointer) || args.first.is_a?(CvDTreeStruct)
        raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1
        return super(args.first)
    end
    # wrapper for CvDTree::CvDTree()
    @@cvd_tree_cvd_tree_defaults0 ||= []
    if(args.size >= 0 && args.size <= 0)
        args.size.upto(-1) do |i|
            args[i] = @@cvd_tree_cvd_tree_defaults0[i]
        end
        begin
            return Rbind::cvd_tree_cvd_tree(*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.



20557
20558
20559
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20557

def self.rbind_from_native(ptr,context)
    CvDTree.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.



20548
20549
20550
20551
20552
20553
20554
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20548

def self.rbind_to_native(obj,context)
    if obj.is_a? CvDTree
        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



20563
20564
20565
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20563

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)


20588
20589
20590
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20588

def __owner__?
    @__obj_ptr__[:bowner]
end

#clearObject

wrapper for void CvDTree::clear()



20623
20624
20625
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20623

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

#get_var_importanceObject

wrapper for cv::Mat CvDTree::getVarImportance()



20615
20616
20617
20618
20619
20620
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20615

def get_var_importance()
    result = Rbind::cvd_tree_get_var_importance( self)
    # 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

#load(filename, name = 0) ⇒ Object

wrapper for void CvDTree::load(c_string filename, c_string name=0)



20633
20634
20635
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20633

def load(filename, name = 0)
    Rbind::cvd_tree_load( self, filename, name)
end

#predict(sample, missing_data_mask = Cv::Mat.new(), preprocessed_input = false) ⇒ Object

wrapper for CvDTreeNode * CvDTree::predict(const cv::Mat sample, const cv::Mat missingDataMask=cv::Mat(), bool preprocessedInput=false)



20607
20608
20609
20610
20611
20612
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20607

def predict(sample, missing_data_mask = Cv::Mat.new(), preprocessed_input = false)
    result = Rbind::cvd_tree_predict( self, sample, missing_data_mask, preprocessed_input)
    # 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

#save(filename, name = 0) ⇒ Object

wrapper for void CvDTree::save(c_string filename, c_string name=0)



20628
20629
20630
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20628

def save(filename, name = 0)
    Rbind::cvd_tree_save( self, filename, name)
end

#train(train_data, tflag, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), var_type = Cv::Mat.new(), missing_data_mask = Cv::Mat.new(), params = CvDTreeParams.new()) ⇒ Object

methods wrapper for bool CvDTree::train(const cv::Mat trainData, int tflag, const cv::Mat responses, const cv::Mat varIdx=cv::Mat(), const cv::Mat sampleIdx=cv::Mat(), const cv::Mat varType=cv::Mat(), const cv::Mat missingDataMask=cv::Mat(), const CvDTreeParams params=CvDTreeParams())



20602
20603
20604
# File 'lib/ruby/ropencv/ropencv_types.rb', line 20602

def train(train_data, tflag, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), var_type = Cv::Mat.new(), missing_data_mask = Cv::Mat.new(), params = CvDTreeParams.new())
    Rbind::cvd_tree_train( self, train_data, tflag, responses, var_idx, sample_idx, var_type, missing_data_mask, params)
end