From e7021b126cefc3e94b5b9926fd5096d3d85d601c Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 5 Aug 2012 00:38:46 +0900 Subject: [PATCH] add documents of CvFeatureTree --- ext/opencv/cvfeaturetree.cpp | 64 +++++++++++++++++------------------- ext/opencv/cvfeaturetree.h | 2 +- ext/opencv/opencv.cpp | 2 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/ext/opencv/cvfeaturetree.cpp b/ext/opencv/cvfeaturetree.cpp index 316da98..b2f6f70 100644 --- a/ext/opencv/cvfeaturetree.cpp +++ b/ext/opencv/cvfeaturetree.cpp @@ -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 diff --git a/ext/opencv/cvfeaturetree.h b/ext/opencv/cvfeaturetree.h index 5389aa9..9ddd012 100644 --- a/ext/opencv/cvfeaturetree.h +++ b/ext/opencv/cvfeaturetree.h @@ -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); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 17b4cef..14ef78e 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -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();