Class: OpenCV::CvKNearest
- Inherits:
-
Object
- Object
- OpenCV::CvKNearest
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/ropencv/ropencv_types.rb
Class Method Summary collapse
- .cast_from_cv_stat_model(ptr) ⇒ CvKNearest (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)
- #find_nearest(samples, k, results, neighbor_responses, dists) ⇒ Float
- #load(filename, name = 0) ⇒ Void
- #save(filename, name = 0) ⇒ Void
-
#to_s ⇒ Object
converts CvKNearest into a string by crawling through all its attributes.
-
#train(train_data, responses, sample_idx = Cv::Mat.new(), is_regression = false, max_k = 32, update_base = false) ⇒ Bool
methods.
Class Method Details
.cast_from_cv_stat_model(ptr) ⇒ CvKNearest Also known as: castFromCvStatModel
wrapper for static method CvKNearest* CvKNearest::castFromCvStatModel(CvStatModel* ptr)
42379 42380 42381 |
# File 'lib/ropencv/ropencv_types.rb', line 42379 def self.cast_from_cv_stat_model(ptr) Rbind::cvk_nearest_cast_from_cv_stat_model(ptr) end |
.cvk_nearest ⇒ Object .cvk_nearest(train_data, responses, sample_idx = Cv::Mat.new(), is_regression = false, max_k = 32) ⇒ Object
42229 42230 42231 42232 42233 42234 42235 42236 42237 42238 42239 42240 42241 42242 42243 42244 42245 42246 42247 42248 42249 42250 42251 42252 42253 42254 42255 42256 42257 42258 42259 42260 42261 42262 42263 |
# File 'lib/ropencv/ropencv_types.rb', line 42229 def self.new(*args) if args.first.is_a?(FFI::Pointer) || args.first.is_a?(CvKNearestStruct) raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1 return super(args.first) end # overloaded method wrapper for CvKNearest::CvKNearest() @@cvk_nearest_cvk_nearest_defaults0 ||= [] if(args.size >= 0 && args.size <= 0) targs = args.clone targs.size.upto(-1) do |i| targs[i] = @@cvk_nearest_cvk_nearest_defaults0[i] end begin return Rbind::cvk_nearest_cvk_nearest(*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for CvKNearest::CvKNearest(const cv::Mat trainData, const cv::Mat responses, const cv::Mat sampleIdx = cv::Mat(), bool isRegression = false, int max_k = 32) @@cvk_nearest_cvk_nearest2_defaults1 ||= [nil, nil, Cv::Mat.new(), false, 32] if(args.size >= 2 && args.size <= 5) targs = args.clone targs.size.upto(4) do |i| targs[i] = @@cvk_nearest_cvk_nearest2_defaults1[i] end begin return Rbind::cvk_nearest_cvk_nearest2(*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
42217 42218 42219 |
# File 'lib/ropencv/ropencv_types.rb', line 42217 def self.null new(CvKNearestStruct.new) end |
Instance Method Details
#cast_to_cv_stat_model ⇒ CvStatModel Also known as: castToCvStatModel
method wrapper for CvStatModel* CvKNearest::castToCvStatModel()
42365 42366 42367 42368 42369 42370 42371 42372 42373 |
# File 'lib/ropencv/ropencv_types.rb', line 42365 def cast_to_cv_stat_model() __validate_pointer__ result = Rbind::cvk_nearest_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 |
#find_nearest(samples, k, results, neighbor_responses, dists) ⇒ Float
method wrapper for float CvKNearest::find_nearest(const cv::Mat samples, int k, cv::Mat& results, cv::Mat& neighborResponses, cv::Mat& dists)
42358 42359 42360 42361 |
# File 'lib/ropencv/ropencv_types.rb', line 42358 def find_nearest(samples, k, results, neighbor_responses, dists) __validate_pointer__ Rbind::cvk_nearest_find_nearest( self, samples, k, results, neighbor_responses, dists) end |
#load(filename, name = 0) ⇒ Void
method wrapper for void CvKNearest::load(c_string filename, c_string name = 0)
42397 42398 42399 42400 |
# File 'lib/ropencv/ropencv_types.rb', line 42397 def load(filename, name = 0) __validate_pointer__ Rbind::cvk_nearest_load( self, filename, name) end |
#save(filename, name = 0) ⇒ Void
method wrapper for void CvKNearest::save(c_string filename, c_string name = 0)
42388 42389 42390 42391 |
# File 'lib/ropencv/ropencv_types.rb', line 42388 def save(filename, name = 0) __validate_pointer__ Rbind::cvk_nearest_save( self, filename, name) end |
#to_s ⇒ Object
converts CvKNearest into a string by crawling through all its attributes
42329 42330 42331 |
# File 'lib/ropencv/ropencv_types.rb', line 42329 def to_s "#<CvKNearest >" end |
#train(train_data, responses, sample_idx = Cv::Mat.new(), is_regression = false, max_k = 32, update_base = false) ⇒ Bool
method wrapper for bool CvKNearest::train(const cv::Mat trainData, const cv::Mat responses, const cv::Mat sampleIdx = cv::Mat(), bool isRegression = false, int maxK = 32, bool updateBase = false)
methods
42346 42347 42348 42349 |
# File 'lib/ropencv/ropencv_types.rb', line 42346 def train(train_data, responses, sample_idx = Cv::Mat.new(), is_regression = false, max_k = 32, update_base = false) __validate_pointer__ Rbind::cvk_nearest_train( self, train_data, responses, sample_idx, is_regression, max_k, update_base) end |