1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

add documents of CvFeatureTree

This commit is contained in:
ser1zw 2012-08-05 00:38:46 +09:00
parent 4faeaf0978
commit e7021b126c
3 changed files with 33 additions and 35 deletions

View file

@ -48,30 +48,12 @@ rb_allocate(VALUE klass)
rb_release_feature_tree, ptr);
}
void
define_ruby_class()
{
if (rb_klass)
return;
/*
* opencv = rb_define_module("OpenCV");
*
* note: this comment is used by rdoc.
*/
VALUE opencv = rb_module_opencv();
rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
rb_define_alloc_func(rb_klass, rb_allocate);
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
}
/*
* call-seq:
* new(desc)
*
* Create a new kd-tree
* @overload new(desc)
* @param desc [CvMat] Descriptors
* @return [CvFeatureTree] self
* @opencv_func cvCreateKDTree
*/
VALUE
rb_initialize(VALUE self, VALUE desc)
@ -91,18 +73,15 @@ rb_initialize(VALUE self, VALUE desc)
}
/*
* call-seq:
* find_features(desc, rows, cols, k, emax) -> array(results, dist)
*
* Find features from kd-tree
*
* desc: m x d matrix of (row-)vectors to find the nearest neighbors of.
* k: The number of neighbors to find.
* emax: The maximum number of leaves to visit.
*
* return
* results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
* dist: m x k matrix of distances to k nearest neighbors.
* @overload find_features(desc, k, emax)
* @param desc [CvMat] m x d matrix of (row-)vectors to find the nearest neighbors of.
* @param k [Integer] The number of neighbors to find.
* @param emax [Integer] The maximum number of leaves to visit.
* @return [Array] Array of [results, dist]
* - results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
* - dist: m x k matrix of distances to k nearest neighbors.
* @opencv_func cvFindFeatures
*/
VALUE
rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
@ -120,6 +99,25 @@ rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
return rb_assoc_new(results, dist);
}
void
init_ruby_class()
{
#if 0
// For documentation using YARD
VALUE opencv = rb_define_module("OpenCV");
#endif
if (rb_klass)
return;
VALUE opencv = rb_module_opencv();
rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
rb_define_alloc_func(rb_klass, rb_allocate);
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
}
__NAMESPACE_END_OPENCV
__NAMESPACE_END_CVFEATURETREE

View file

@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV
__NAMESPACE_BEGIN_CVFEATURETREE
VALUE rb_class();
void define_ruby_class();
void init_ruby_class();
VALUE rb_allocate(VALUE klass);
VALUE rb_initialize(VALUE self, VALUE desc);
VALUE rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax);

View file

@ -707,7 +707,7 @@ extern "C" {
mOpenCV::cCvCircle32f::init_ruby_class();
mOpenCV::cCvConDensation::define_ruby_class();
mOpenCV::cCvFeatureTree::define_ruby_class();
mOpenCV::cCvFeatureTree::init_ruby_class();
mOpenCV::cCvConnectedComp::init_ruby_class();
mOpenCV::cCvAvgComp::init_ruby_class();