From 913391ada3f46a2c7edcfc35807a504f34cad512 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Tue, 21 Aug 2012 01:07:53 +0900 Subject: [PATCH] add documents of CvLine --- ext/opencv/cvline.cpp | 85 +++++++++++++++++++++++-------------------- ext/opencv/cvline.h | 2 +- ext/opencv/opencv.cpp | 2 +- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/ext/opencv/cvline.cpp b/ext/opencv/cvline.cpp index 792209d..20e3398 100644 --- a/ext/opencv/cvline.cpp +++ b/ext/opencv/cvline.cpp @@ -11,6 +11,8 @@ /* * Document-class: OpenCV::CvLine * + * Line parameters represented by a two-element (rho, theta) + * for CvMat#hough_lines */ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_CVLINE @@ -23,28 +25,6 @@ rb_class() return rb_klass; } -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, "CvLine", rb_cObject); - rb_define_alloc_func(rb_klass, rb_allocate); - rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0); - rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1); - rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0); - rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1); - rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1); - rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2); -} - VALUE rb_allocate(VALUE klass) { @@ -53,7 +33,9 @@ rb_allocate(VALUE klass) } /* - * Return parameter on rho. + * Returns distance from the coordinate origin (0, 0) + * @overload rho + * @return [Number] Distance from the coordinate origin */ VALUE rb_rho(VALUE self) @@ -62,10 +44,9 @@ rb_rho(VALUE self) } /* - * call-seq: - * rho = val - * - * Set rho parameter, return self. + * Set distance from the coordinate origin (0, 0) + * @overload rho=(value) + * @param value [Number] Distance from the coordinate origin */ VALUE rb_set_rho(VALUE self, VALUE rho) @@ -75,7 +56,9 @@ rb_set_rho(VALUE self, VALUE rho) } /* - * Return parameter on theta. + * Returns line rotation angle in radians + * @overload theta + * @return [Number] Line rotation angle in radians */ VALUE rb_theta(VALUE self) @@ -84,10 +67,9 @@ rb_theta(VALUE self) } /* - * call-seq: - * y = val - * - * Set theta parameter, return self. + * Set line rotation angle in radians + * @overload theta=(value) + * @param value [Number] Line rotation angle */ VALUE rb_set_theta(VALUE self, VALUE theta) @@ -97,10 +79,10 @@ rb_set_theta(VALUE self, VALUE theta) } /* - * call-seq: - * [index] - * - * Return value of index dimension. + * Returns value of rho, theta + * @overload [](index) + * @param index [Integer] Index + * @return [Number] If index = 0, returns rho, else if index = 1, returns theta. */ VALUE rb_aref(VALUE self, VALUE index) @@ -120,10 +102,11 @@ rb_aref(VALUE self, VALUE index) } /* - * call-seq: - * [index] = value - * - * Set value of index dimension to value + * Set value of rho, theta + * @overload []=(index, value) + * @param index [Integer] Index + * @param value [Number] Value + * @return [Number] If index = 0, set rho, else if index = 1, set theta. */ VALUE rb_aset(VALUE self, VALUE index, VALUE value) @@ -150,5 +133,27 @@ new_object(CvLine line) return object; } +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, "CvLine", rb_cObject); + rb_define_alloc_func(rb_klass, rb_allocate); + rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0); + rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1); + rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0); + rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1); + rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1); + rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2); +} + __NAMESPACE_END_CVLINE __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvline.h b/ext/opencv/cvline.h index b62e1c0..a5618a9 100644 --- a/ext/opencv/cvline.h +++ b/ext/opencv/cvline.h @@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVLINE VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 1a58d53..584e250 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -702,7 +702,7 @@ extern "C" { mOpenCV::cCvCapture::init_ruby_class(); mOpenCV::cCvVideoWriter::define_ruby_class(); - mOpenCV::cCvLine::define_ruby_class(); + mOpenCV::cCvLine::init_ruby_class(); mOpenCV::cCvTwoPoints::define_ruby_class(); mOpenCV::cCvCircle32f::init_ruby_class();