Class: OpenCV::CvSVM
- Inherits:
-
Object
- Object
- OpenCV::CvSVM
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/ropencv/ropencv_types.rb
Constants collapse
- C_SVC =
100
- NU_SVC =
101
- ONE_CLASS =
102
- EPS_SVR =
103
- NU_SVR =
104
- LINEAR =
0
- POLY =
1
- RBF =
2
- SIGMOID =
3
- C =
0
- GAMMA =
1
- P =
2
- NU =
3
- COEF =
4
- DEGREE =
5
Class Method Summary collapse
- .cast_from_cv_stat_model(ptr) ⇒ CvSVM (also: castFromCvStatModel)
- .new(*args) ⇒ Object
-
.null ⇒ Object
returns a null pointer to the object.
Instance Method Summary collapse
- #cast_to_cv_stat_model ⇒ CvStatModel (also: #castToCvStatModel)
- #clear ⇒ Void
- #get_support_vector_count ⇒ Fixnum
- #get_var_count ⇒ Fixnum
- #load(filename, name = 0) ⇒ Void
- #predict(sample, return_d_f_val = false) ⇒ Float
- #predict_all(samples, results) ⇒ Void
- #save(filename, name = 0) ⇒ Void
-
#to_s ⇒ Object
converts CvSVM into a string by crawling through all its attributes.
-
#train(train_data, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), params = CvSVMParams.new()) ⇒ Bool
methods.
- #train_auto(train_data, responses, var_idx, sample_idx, params, k_fold = 10, cgrid = CvSVM.new(CvSVM::C), gamma_grid = CvSVM.new(CvSVM::GAMMA), p_grid = CvSVM.new(CvSVM::P), nu_grid = CvSVM.new(CvSVM::NU), coeff_grid = CvSVM.new(CvSVM::COEF), degree_grid = CvSVM.new(CvSVM::DEGREE), balanced = false) ⇒ Bool
Class Method Details
.cast_from_cv_stat_model(ptr) ⇒ CvSVM Also known as: castFromCvStatModel
wrapper for static method CvSVM* CvSVM::castFromCvStatModel(CvStatModel* ptr)
42953 42954 42955 |
# File 'lib/ropencv/ropencv_types.rb', line 42953 def self.cast_from_cv_stat_model(ptr) Rbind::cvsvm_cast_from_cv_stat_model(ptr) end |
.cvsvm ⇒ Object .cvsvm(train_data, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), params = CvSVMParams.new()) ⇒ Object
42742 42743 42744 42745 42746 42747 42748 42749 42750 42751 42752 42753 42754 42755 42756 42757 42758 42759 42760 42761 42762 42763 42764 42765 42766 42767 42768 42769 42770 42771 42772 42773 42774 42775 42776 |
# File 'lib/ropencv/ropencv_types.rb', line 42742 def self.new(*args) if args.first.is_a?(FFI::Pointer) || args.first.is_a?(CvSVMStruct) raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1 return super(args.first) end # overloaded method wrapper for CvSVM::CvSVM() @@cvsvm_cvsvm_defaults0 ||= [] if(args.size >= 0 && args.size <= 0) targs = args.clone targs.size.upto(-1) do |i| targs[i] = @@cvsvm_cvsvm_defaults0[i] end begin return Rbind::cvsvm_cvsvm(*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for CvSVM::CvSVM(const cv::Mat trainData, const cv::Mat responses, const cv::Mat varIdx = cv::Mat(), const cv::Mat sampleIdx = cv::Mat(), const CvSVMParams params = CvSVMParams()) @@cvsvm_cvsvm2_defaults1 ||= [nil, nil, Cv::Mat.new(), Cv::Mat.new(), CvSVMParams.new()] if(args.size >= 2 && args.size <= 5) targs = args.clone targs.size.upto(4) do |i| targs[i] = @@cvsvm_cvsvm2_defaults1[i] end begin return Rbind::cvsvm_cvsvm2(*targs) rescue TypeError => e @error = e end end raise ArgumentError, "no constructor for #{self}(#{args.inspect})" end |
.null ⇒ Object
returns a null pointer to the object
42730 42731 42732 |
# File 'lib/ropencv/ropencv_types.rb', line 42730 def self.null new(CvSVMStruct.new) end |
Instance Method Details
#cast_to_cv_stat_model ⇒ CvStatModel Also known as: castToCvStatModel
method wrapper for CvStatModel* CvSVM::castToCvStatModel()
42939 42940 42941 42942 42943 42944 42945 42946 42947 |
# File 'lib/ropencv/ropencv_types.rb', line 42939 def cast_to_cv_stat_model() __validate_pointer__ result = Rbind::cvsvm_cast_to_cv_stat_model( self) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#clear ⇒ Void
method wrapper for void CvSVM::clear()
42925 42926 42927 42928 |
# File 'lib/ropencv/ropencv_types.rb', line 42925 def clear() __validate_pointer__ Rbind::cvsvm_clear( self) end |
#get_support_vector_count ⇒ Fixnum
method wrapper for int CvSVM::get_support_vector_count()
42918 42919 42920 42921 |
# File 'lib/ropencv/ropencv_types.rb', line 42918 def get_support_vector_count() __validate_pointer__ Rbind::cvsvm_get_support_vector_count( self) end |
#get_var_count ⇒ Fixnum
method wrapper for int CvSVM::get_var_count()
42932 42933 42934 42935 |
# File 'lib/ropencv/ropencv_types.rb', line 42932 def get_var_count() __validate_pointer__ Rbind::cvsvm_get_var_count( self) end |
#load(filename, name = 0) ⇒ Void
method wrapper for void CvSVM::load(c_string filename, c_string name = 0)
42971 42972 42973 42974 |
# File 'lib/ropencv/ropencv_types.rb', line 42971 def load(filename, name = 0) __validate_pointer__ Rbind::cvsvm_load( self, filename, name) end |
#predict(sample, return_d_f_val = false) ⇒ Float
method wrapper for float CvSVM::predict(const cv::Mat sample, bool returnDFVal = false)
42902 42903 42904 42905 |
# File 'lib/ropencv/ropencv_types.rb', line 42902 def predict(sample, return_d_f_val = false) __validate_pointer__ Rbind::cvsvm_predict( self, sample, return_d_f_val) end |
#predict_all(samples, results) ⇒ Void
method wrapper for void CvSVM::predict(const cv::Mat samples, cv::Mat& results)
42911 42912 42913 42914 |
# File 'lib/ropencv/ropencv_types.rb', line 42911 def predict_all(samples, results) __validate_pointer__ Rbind::cvsvm_predict_all( self, samples, results) end |
#save(filename, name = 0) ⇒ Void
method wrapper for void CvSVM::save(c_string filename, c_string name = 0)
42962 42963 42964 42965 |
# File 'lib/ropencv/ropencv_types.rb', line 42962 def save(filename, name = 0) __validate_pointer__ Rbind::cvsvm_save( self, filename, name) end |
#to_s ⇒ Object
converts CvSVM into a string by crawling through all its attributes
42842 42843 42844 |
# File 'lib/ropencv/ropencv_types.rb', line 42842 def to_s "#<CvSVM >" end |
#train(train_data, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), params = CvSVMParams.new()) ⇒ Bool
method wrapper for bool CvSVM::train(const cv::Mat trainData, const cv::Mat responses, const cv::Mat varIdx = cv::Mat(), const cv::Mat sampleIdx = cv::Mat(), const CvSVMParams params = CvSVMParams())
methods
42873 42874 42875 42876 |
# File 'lib/ropencv/ropencv_types.rb', line 42873 def train(train_data, responses, var_idx = Cv::Mat.new(), sample_idx = Cv::Mat.new(), params = CvSVMParams.new()) __validate_pointer__ Rbind::cvsvm_train( self, train_data, responses, var_idx, sample_idx, params) end |
#train_auto(train_data, responses, var_idx, sample_idx, params, k_fold = 10, cgrid = CvSVM.new(CvSVM::C), gamma_grid = CvSVM.new(CvSVM::GAMMA), p_grid = CvSVM.new(CvSVM::P), nu_grid = CvSVM.new(CvSVM::NU), coeff_grid = CvSVM.new(CvSVM::COEF), degree_grid = CvSVM.new(CvSVM::DEGREE), balanced = false) ⇒ Bool
method wrapper for bool CvSVM::train_auto(const cv::Mat trainData, const cv::Mat responses, const cv::Mat varIdx, const cv::Mat sampleIdx, const CvSVMParams params, int k_fold = 10, const CvParamGrid Cgrid = CvSVM::get_default_grid(CvSVM::C), const CvParamGrid gammaGrid = CvSVM::get_default_grid(CvSVM::GAMMA), const CvParamGrid pGrid = CvSVM::get_default_grid(CvSVM::P), const CvParamGrid nuGrid = CvSVM::get_default_grid(CvSVM::NU), const CvParamGrid coeffGrid = CvSVM::get_default_grid(CvSVM::COEF), const CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE), bool balanced = false)
42893 42894 42895 42896 |
# File 'lib/ropencv/ropencv_types.rb', line 42893 def train_auto(train_data, responses, var_idx, sample_idx, params, k_fold = 10, cgrid = CvSVM.new(CvSVM::C), gamma_grid = CvSVM.new(CvSVM::GAMMA), p_grid = CvSVM.new(CvSVM::P), nu_grid = CvSVM.new(CvSVM::NU), coeff_grid = CvSVM.new(CvSVM::COEF), degree_grid = CvSVM.new(CvSVM::DEGREE), balanced = false) __validate_pointer__ Rbind::cvsvm_train_auto( self, train_data, responses, var_idx, sample_idx, params, k_fold, cgrid, gamma_grid, p_grid, nu_grid, coeff_grid, degree_grid, balanced) end |