Class: OpenCV::CvANNMLP

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

Constants collapse

IDENTITY =
0
SIGMOID_SYM =
1
GAUSSIAN =
2
UPDATE_WEIGHTS =
1
NO_INPUT_SCALE =
2
NO_OUTPUT_SCALE =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ CvANNMLP

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



21864
21865
21866
21867
21868
21869
21870
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21864

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



21861
21862
21863
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21861

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



21856
21857
21858
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21856

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

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21800

def self.new(*args)
    if args.first.is_a?(FFI::Pointer) || args.first.is_a?(CvANNMLPStruct)
        raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1
        return super(args.first)
    end
    # wrapper for CvANN_MLP::CvANN_MLP()
    @@cvann_mlp_cvann_mlp_defaults0 ||= []
    if(args.size >= 0 && args.size <= 0)
        args.size.upto(-1) do |i|
            args[i] = @@cvann_mlp_cvann_mlp_defaults0[i]
        end
        begin
            return Rbind::cvann_mlp_cvann_mlp(*args)
        rescue TypeError => e
            @error = e
        end
    end

    # wrapper for CvANN_MLP::CvANN_MLP(const cv::Mat layerSizes, int activateFunc=CvANN_MLP::SIGMOID_SYM, double fparam1=0, double fparam2=0)
    @@cvann_mlp_cvann_mlp2_defaults1 ||= [nil, CvANN_MLP::SIGMOID_SYM, 0, 0]
    if(args.size >= 1 && args.size <= 4)
        args.size.upto(3) do |i|
            args[i] = @@cvann_mlp_cvann_mlp2_defaults1[i]
        end
        begin
            return Rbind::cvann_mlp_cvann_mlp2(*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.



21844
21845
21846
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21844

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



21835
21836
21837
21838
21839
21840
21841
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21835

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



21850
21851
21852
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21850

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)


21875
21876
21877
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21875

def __owner__?
    @__obj_ptr__[:bowner]
end

#clearObject

wrapper for void CvANN_MLP::clear()



21910
21911
21912
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21910

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

#create(layer_sizes, activate_func = CvANN_MLP::SIGMOID_SYM, _fparam1 = 0, _fparam2 = 0) ⇒ Object

methods wrapper for void CvANN_MLP::create(const cv::Mat layerSizes, int activateFunc=CvANN_MLP::SIGMOID_SYM, double fparam1=0, double fparam2=0)



21895
21896
21897
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21895

def create(layer_sizes, activate_func = CvANN_MLP::SIGMOID_SYM, _fparam1 = 0, _fparam2 = 0)
    Rbind::cvann_mlp_create( self, layer_sizes, activate_func, _fparam1, _fparam2)
end

#load(filename, name = 0) ⇒ Object

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



21920
21921
21922
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21920

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

#predict(inputs, outputs) ⇒ Object

wrapper for float CvANN_MLP::predict(const cv::Mat inputs, cv::Mat outputs)



21905
21906
21907
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21905

def predict(inputs, outputs)
    Rbind::cvann_mlp_predict( self, inputs, outputs)
end

#save(filename, name = 0) ⇒ Object

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



21915
21916
21917
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21915

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

#train(inputs, outputs, sample_weights, sample_idx = Cv::Mat.new(), params = CvANNMLPTrainParams.new(), flags = 0) ⇒ Object

wrapper for int CvANN_MLP::train(const cv::Mat inputs, const cv::Mat outputs, const cv::Mat sampleWeights, const cv::Mat sampleIdx=cv::Mat(), const CvANN_MLP_TrainParams params=CvANN_MLP_TrainParams(), int flags=0)



21900
21901
21902
# File 'lib/ruby/ropencv/ropencv_types.rb', line 21900

def train(inputs, outputs, sample_weights, sample_idx = Cv::Mat.new(), params = CvANNMLPTrainParams.new(), flags = 0)
    Rbind::cvann_mlp_train( self, inputs, outputs, sample_weights, sample_idx, params, flags)
end