ruby-opencv 0.0.11 → 0.0.12.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.yardopts +3 -0
  4. data/Gemfile +1 -0
  5. data/Manifest.txt +2 -14
  6. data/README.md +1 -1
  7. data/Rakefile +10 -1
  8. data/examples/facerec/facerec_lbph.rb +1 -1
  9. data/ext/opencv/algorithm.cpp +6 -1
  10. data/ext/opencv/algorithm.h +1 -1
  11. data/ext/opencv/curve.cpp +48 -33
  12. data/ext/opencv/curve.h +1 -1
  13. data/ext/opencv/cvavgcomp.cpp +22 -25
  14. data/ext/opencv/cvavgcomp.h +1 -1
  15. data/ext/opencv/cvbox2d.cpp +56 -58
  16. data/ext/opencv/cvbox2d.h +1 -1
  17. data/ext/opencv/cvcapture.cpp +210 -109
  18. data/ext/opencv/cvcapture.h +1 -1
  19. data/ext/opencv/cvchain.cpp +71 -71
  20. data/ext/opencv/cvchain.h +1 -1
  21. data/ext/opencv/cvcircle32f.cpp +37 -27
  22. data/ext/opencv/cvcircle32f.h +1 -1
  23. data/ext/opencv/cvconnectedcomp.cpp +49 -36
  24. data/ext/opencv/cvconnectedcomp.h +1 -1
  25. data/ext/opencv/cvcontour.cpp +117 -81
  26. data/ext/opencv/cvcontour.h +1 -1
  27. data/ext/opencv/cvcontourtree.cpp +37 -32
  28. data/ext/opencv/cvcontourtree.h +1 -1
  29. data/ext/opencv/cvconvexitydefect.cpp +33 -44
  30. data/ext/opencv/cvconvexitydefect.h +1 -1
  31. data/ext/opencv/cverror.cpp +22 -66
  32. data/ext/opencv/cverror.h +1 -1
  33. data/ext/opencv/cvfeaturetree.cpp +31 -33
  34. data/ext/opencv/cvfeaturetree.h +1 -1
  35. data/ext/opencv/cvfont.cpp +98 -78
  36. data/ext/opencv/cvfont.h +1 -1
  37. data/ext/opencv/cvhaarclassifiercascade.cpp +39 -59
  38. data/ext/opencv/cvhaarclassifiercascade.h +1 -1
  39. data/ext/opencv/cvhistogram.cpp +259 -90
  40. data/ext/opencv/cvhistogram.h +1 -1
  41. data/ext/opencv/cvhumoments.cpp +99 -60
  42. data/ext/opencv/cvhumoments.h +1 -1
  43. data/ext/opencv/cvline.cpp +45 -40
  44. data/ext/opencv/cvline.h +1 -1
  45. data/ext/opencv/cvmat.cpp +1894 -1829
  46. data/ext/opencv/cvmat.h +2 -3
  47. data/ext/opencv/cvmemstorage.cpp +19 -14
  48. data/ext/opencv/cvmemstorage.h +1 -1
  49. data/ext/opencv/cvmoments.cpp +51 -45
  50. data/ext/opencv/cvmoments.h +1 -1
  51. data/ext/opencv/cvpoint.cpp +32 -26
  52. data/ext/opencv/cvpoint.h +1 -1
  53. data/ext/opencv/cvpoint2d32f.cpp +31 -26
  54. data/ext/opencv/cvpoint2d32f.h +1 -1
  55. data/ext/opencv/cvpoint3d32f.cpp +36 -29
  56. data/ext/opencv/cvpoint3d32f.h +1 -1
  57. data/ext/opencv/cvrect.cpp +38 -33
  58. data/ext/opencv/cvrect.h +1 -1
  59. data/ext/opencv/cvscalar.cpp +50 -45
  60. data/ext/opencv/cvscalar.h +1 -1
  61. data/ext/opencv/cvseq.cpp +53 -47
  62. data/ext/opencv/cvseq.h +1 -1
  63. data/ext/opencv/cvsize.cpp +32 -26
  64. data/ext/opencv/cvsize.h +1 -1
  65. data/ext/opencv/cvsize2d32f.cpp +31 -25
  66. data/ext/opencv/cvsize2d32f.h +1 -1
  67. data/ext/opencv/cvslice.cpp +28 -22
  68. data/ext/opencv/cvslice.h +1 -1
  69. data/ext/opencv/cvsurfparams.cpp +37 -28
  70. data/ext/opencv/cvsurfparams.h +1 -1
  71. data/ext/opencv/cvsurfpoint.cpp +76 -53
  72. data/ext/opencv/cvsurfpoint.h +1 -1
  73. data/ext/opencv/cvtermcriteria.cpp +32 -26
  74. data/ext/opencv/cvtermcriteria.h +1 -1
  75. data/ext/opencv/cvtwopoints.cpp +28 -22
  76. data/ext/opencv/cvtwopoints.h +1 -1
  77. data/ext/opencv/cvvideowriter.cpp +25 -20
  78. data/ext/opencv/cvvideowriter.h +1 -1
  79. data/ext/opencv/eigenfaces.cpp +10 -2
  80. data/ext/opencv/eigenfaces.h +1 -1
  81. data/ext/opencv/facerecognizer.cpp +15 -8
  82. data/ext/opencv/facerecognizer.h +2 -2
  83. data/ext/opencv/fisherfaces.cpp +10 -2
  84. data/ext/opencv/fisherfaces.h +1 -1
  85. data/ext/opencv/gui.cpp +26 -23
  86. data/ext/opencv/gui.h +1 -1
  87. data/ext/opencv/iplconvkernel.cpp +30 -24
  88. data/ext/opencv/iplconvkernel.h +1 -1
  89. data/ext/opencv/iplimage.cpp +49 -42
  90. data/ext/opencv/iplimage.h +1 -1
  91. data/ext/opencv/lbph.cpp +10 -2
  92. data/ext/opencv/lbph.h +1 -1
  93. data/ext/opencv/mouseevent.cpp +30 -25
  94. data/ext/opencv/mouseevent.h +1 -1
  95. data/ext/opencv/opencv.cpp +59 -60
  96. data/ext/opencv/opencv.h +1 -5
  97. data/ext/opencv/pointset.cpp +31 -25
  98. data/ext/opencv/pointset.h +1 -1
  99. data/ext/opencv/trackbar.cpp +27 -21
  100. data/ext/opencv/trackbar.h +1 -1
  101. data/ext/opencv/window.cpp +77 -57
  102. data/ext/opencv/window.h +1 -1
  103. data/lib/opencv/version.rb +2 -1
  104. data/ruby-opencv.gemspec +19 -18
  105. data/test/test_opencv.rb +5 -3
  106. data/yard_extension.rb +5 -0
  107. metadata +13 -27
  108. data/examples/matching_to_many_images/matching_to_many_images.rb +0 -16
  109. data/examples/matching_to_many_images/query.png +0 -0
  110. data/examples/matching_to_many_images/train/1.png +0 -0
  111. data/examples/matching_to_many_images/train/2.png +0 -0
  112. data/examples/matching_to_many_images/train/3.png +0 -0
  113. data/examples/matching_to_many_images/train/trainImages.txt +0 -3
  114. data/ext/opencv/cvcondensation.cpp +0 -282
  115. data/ext/opencv/cvcondensation.h +0 -49
  116. data/ext/opencv/cvmatnd.cpp +0 -44
  117. data/ext/opencv/cvmatnd.h +0 -28
  118. data/ext/opencv/cvsparsemat.cpp +0 -44
  119. data/ext/opencv/cvsparsemat.h +0 -28
  120. data/images/face_detect_from_lena.jpg +0 -0
  121. data/test/test_cvmat_matching.rb +0 -57
@@ -21,7 +21,7 @@ __NAMESPACE_BEGIN_CVCAPTURE
21
21
 
22
22
  VALUE rb_class();
23
23
 
24
- void define_ruby_class();
24
+ void init_ruby_class();
25
25
 
26
26
  void cvcapture_free(void *ptr);
27
27
  VALUE rb_open(int argc, VALUE *argv, VALUE klass);
@@ -11,8 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvChain
13
13
  *
14
- * Freeman chain code.
15
- * CvMat#find_contours(:method => :code)
14
+ * Freeman chain code
16
15
  */
17
16
  __NAMESPACE_BEGIN_OPENCV
18
17
  __NAMESPACE_BEGIN_CVCHAIN
@@ -31,45 +30,19 @@ rb_class()
31
30
  return rb_klass;
32
31
  }
33
32
 
34
- void
35
- define_ruby_class()
36
- {
37
- if (rb_klass)
38
- return;
39
- /*
40
- * opencv = rb_define_module("OpenCV");
41
- * cvseq = rb_define_class_under(opencv, "CvSeq");
42
- * curve = rb_define_module_under(opencv, "Curve");
43
- * note: this comment is used by rdoc.
44
- */
45
- VALUE opencv = rb_module_opencv();
46
- VALUE cvseq = cCvSeq::rb_class();
47
- VALUE curve = mCurve::rb_module();
48
-
49
- rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
50
- rb_include_module(rb_klass, curve);
51
- VALUE approx_chain_option = rb_hash_new();
52
- rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option);
53
- rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
54
- rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
55
- rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
56
- rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);
57
-
58
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
59
- rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
60
- rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
61
- rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
62
- rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
63
- rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
64
- rb_define_alias(rb_klass, "approx", "approx_chains");
65
- }
66
-
67
33
  VALUE
68
34
  rb_allocate(VALUE klass)
69
35
  {
70
36
  return Data_Wrap_Struct(klass, mark_root_object, unregister_object, NULL);
71
37
  }
72
38
 
39
+ /*
40
+ * Create a new chain code
41
+ * @overload new(storage=nil)
42
+ * @param storage [CvMemStorage,nil] Sequence location (If storage is nil, allocates a new storage automatically)
43
+ * @return [CvChain] New CvChain instance
44
+ * @opencv_func cvCreateSeq (seq_flags=CV_SEQ_ELTYPE_CODE)
45
+ */
73
46
  VALUE
74
47
  rb_initialize(int argc, VALUE *argv, VALUE self)
75
48
  {
@@ -96,10 +69,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
96
69
  }
97
70
 
98
71
  /*
99
- * call-seq:
100
- * origin -> cvpoint
101
- *
102
- * Return Freeman chain code origin.
72
+ * Returns Freeman chain code origin
73
+ * @overload origin
74
+ * @return [CvPoint] Origin of the chain code
103
75
  */
104
76
  VALUE
105
77
  rb_origin(VALUE self)
@@ -108,10 +80,10 @@ rb_origin(VALUE self)
108
80
  }
109
81
 
110
82
  /*
111
- * call-seq:
112
- * origin = point -> self
113
- *
114
- * Set Freeman chain code origin.
83
+ * Set Freeman chain code origin
84
+ * @overload origin=value
85
+ * @param value [CvPoint] Origin of the chain code
86
+ * @return [CvChain] self
115
87
  */
116
88
  VALUE
117
89
  rb_set_origin(VALUE self, VALUE origin)
@@ -121,10 +93,11 @@ rb_set_origin(VALUE self, VALUE origin)
121
93
  }
122
94
 
123
95
  /*
124
- * call-seq:
125
- * codes -> array(contain fixnum)
126
- *
127
- * Return Freeman chain codes.
96
+ * Returns the chain codes
97
+ * @overload codes
98
+ * @return [Array<Fixnum>] Chain codes
99
+ * @opencv_func cvStartReadChainPoints
100
+ * @opencv_func CV_READ_SEQ_ELEM
128
101
  */
129
102
  VALUE
130
103
  rb_codes(VALUE self)
@@ -147,10 +120,11 @@ rb_codes(VALUE self)
147
120
  }
148
121
 
149
122
  /*
150
- * call-seq:
151
- * points -> array(contain cvpoint)
152
- *
153
- * Return points that represent by Freeman chain code.
123
+ * Returns the points of the chain codes
124
+ * @overload points
125
+ * @return [Array<CvPoint>] Points of the chain codes
126
+ * @opencv_func cvStartReadChainPoints
127
+ * @opencv_func CV_READ_CHAIN_POINT
154
128
  */
155
129
  VALUE
156
130
  rb_points(VALUE self)
@@ -174,26 +148,17 @@ rb_points(VALUE self)
174
148
  }
175
149
 
176
150
  /*
177
- * call-seq:
178
- * approx_chains(<i>[approx_chain_option]</i>) -> cvcontour
179
- *
180
- * Approximates Freeman chain(s) with polygonal curve.
181
- * <i>approx_chain_option</i> should be Hash include these keys.
182
- * :method - Approximation method.
183
- * :approx_none - translate all the points from the chain code into points;
184
- * :approx_simple(default) - compress horizontal, vertical, and diagonal segments, that is,
185
- * the function leaves only their ending points.
186
- * :approx_tc89_l1
187
- * :approx_tc89_kcos - apply one of the flavors of Teh-Chin chain approximation algorithm.
188
- * If set the difference between the current pixel and seed pixel is considered,
189
- * otherwise difference between neighbor pixels is considered (the range is floating).
190
- * :parameter - Method parameter (not used now).
191
- * :minimal_perimeter (default 0)
192
- * Approximates only those contours whose perimeters are not less than minimal_perimeter. Other chains are removed from the resulting structure.
193
- * :recursive (default false)
194
- * If not nil or false, the function approximates all chains that access can be obtained to
195
- * from self by h_next or v_next links. If 0, the single chain is approximated.
196
- *
151
+ * Approximates Freeman chains with a polygonal curve
152
+ * @overload approx_chain(options)
153
+ * @param options [Hash] Parameters
154
+ * @option options [Symbol] :method Approximation method (see the description of CvMat#find_contours)
155
+ * @option options [Number] :minimal_perimeter Approximates only those contours whose perimeters
156
+ * are not less than minimal_perimeter. Other chains are removed from the resulting structure.
157
+ * @option options [Boolean] :recursive Recursion flag. If it is true, the function approximates
158
+ * all chains that can be obtained from chain by using the h_next or v_next links.
159
+ * Otherwise, the single input chain is approximated.
160
+ * @return [CvSeq<CvPoint>] Polygonal curve
161
+ * @opencv_func cvApproxChains
197
162
  */
198
163
  VALUE
199
164
  rb_approx_chains(int argc, VALUE *argv, VALUE self)
@@ -229,5 +194,40 @@ new_object()
229
194
  return cCvSeq::new_sequence(cCvChain::rb_class(), seq, T_FIXNUM, storage);
230
195
  }
231
196
 
197
+ void
198
+ init_ruby_class()
199
+ {
200
+ #if 0
201
+ // For documentation using YARD
202
+ VALUE opencv = rb_define_module("OpenCV");
203
+ VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
204
+ VALUE curve = rb_define_module_under(opencv, "Curve");
205
+ #endif
206
+
207
+ if (rb_klass)
208
+ return;
209
+
210
+ VALUE opencv = rb_module_opencv();
211
+ VALUE cvseq = cCvSeq::rb_class();
212
+ VALUE curve = mCurve::rb_module();
213
+
214
+ rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
215
+ rb_include_module(rb_klass, curve);
216
+ VALUE approx_chain_option = rb_hash_new();
217
+ rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option);
218
+ rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
219
+ rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
220
+ rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
221
+ rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);
222
+
223
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
224
+ rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
225
+ rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
226
+ rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
227
+ rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
228
+ rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
229
+ rb_define_alias(rb_klass, "approx", "approx_chains");
230
+ }
231
+
232
232
  __NAMESPACE_END_CVCHAIN
233
233
  __NAMESPACE_END_OPENCV
@@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCHAIN
19
19
 
20
20
  VALUE rb_class();
21
21
 
22
- void define_ruby_class();
22
+ void init_ruby_class();
23
23
 
24
24
  VALUE rb_allocate(VALUE klass);
25
25
 
@@ -26,27 +26,6 @@ rb_class()
26
26
  return rb_klass;
27
27
  }
28
28
 
29
- void
30
- define_ruby_class()
31
- {
32
- if (rb_klass)
33
- return;
34
- /*
35
- * opencv = rb_define_module("OpenCV");
36
- *
37
- * note: this comment is used by rdoc.
38
- */
39
- VALUE opencv = rb_module_opencv();
40
-
41
- rb_klass = rb_define_class_under(opencv, "CvCircle32f", rb_cObject);
42
- rb_define_alloc_func(rb_klass, rb_allocate);
43
- rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
44
- rb_define_method(rb_klass, "radius", RUBY_METHOD_FUNC(rb_radius), 0);
45
- rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
46
- rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
47
- rb_define_alias(rb_klass, "to_a", "to_ary");
48
- }
49
-
50
29
  VALUE
51
30
  rb_allocate(VALUE klass)
52
31
  {
@@ -55,7 +34,9 @@ rb_allocate(VALUE klass)
55
34
  }
56
35
 
57
36
  /*
58
- * Return parameter on center.
37
+ * Returns center point of the circle
38
+ * @overload center
39
+ * @return [CvPoint2D32f] Center point of the circle
59
40
  */
60
41
  VALUE
61
42
  rb_center(VALUE self)
@@ -64,7 +45,9 @@ rb_center(VALUE self)
64
45
  }
65
46
 
66
47
  /*
67
- * Return parameter on radius.
48
+ * Returns radius of the circle
49
+ * @overload radius
50
+ * @return [Number] Radius of the circle
68
51
  */
69
52
  VALUE
70
53
  rb_radius(VALUE self)
@@ -73,10 +56,10 @@ rb_radius(VALUE self)
73
56
  }
74
57
 
75
58
  /*
76
- * call-seq:
77
- * [<i>index</i>]
78
- *
79
- * Return value of <i>index</i> dimension.
59
+ * Accesses to parameters of the circle by array-like interface ([X-coordinate, Y-coordinate, radius])
60
+ * @overload []
61
+ * @param index [Integer] Index
62
+ * @return [Number] X-coordinate, Y-coordinate or radius of the circle
80
63
  */
81
64
  VALUE
82
65
  rb_aref(VALUE self, VALUE index)
@@ -98,6 +81,11 @@ rb_aref(VALUE self, VALUE index)
98
81
  return Qnil;
99
82
  }
100
83
 
84
+ /*
85
+ * Returns parameters of the circle as an array which contains [center<CvPoint2D32f>, radius<Number>]
86
+ * @overload to_ary
87
+ * @return [Array<CvPoint2D32f,Number>] An array which contains [center, radius]
88
+ */
101
89
  VALUE
102
90
  rb_to_ary(VALUE self)
103
91
  {
@@ -112,5 +100,27 @@ new_object(CvCircle32f circle32f)
112
100
  return object;
113
101
  }
114
102
 
103
+ void
104
+ init_ruby_class()
105
+ {
106
+ #if 0
107
+ // For documentation using YARD
108
+ VALUE opencv = rb_define_module("OpenCV");
109
+ #endif
110
+
111
+ if (rb_klass)
112
+ return;
113
+
114
+ VALUE opencv = rb_module_opencv();
115
+
116
+ rb_klass = rb_define_class_under(opencv, "CvCircle32f", rb_cObject);
117
+ rb_define_alloc_func(rb_klass, rb_allocate);
118
+ rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
119
+ rb_define_method(rb_klass, "radius", RUBY_METHOD_FUNC(rb_radius), 0);
120
+ rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
121
+ rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
122
+ rb_define_alias(rb_klass, "to_a", "to_ary");
123
+ }
124
+
115
125
  __NAMESPACE_END_CVCIRCLE32F
116
126
  __NAMESPACE_END_OPENCV
@@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVCIRCLE32F
26
26
 
27
27
  VALUE rb_class();
28
28
 
29
- void define_ruby_class();
29
+ void init_ruby_class();
30
30
 
31
31
  VALUE rb_allocate(VALUE klass);
32
32
  VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
@@ -10,17 +10,9 @@
10
10
  #include "cvconnectedcomp.h"
11
11
  /*
12
12
  * Document-class: OpenCV::CvConnectedComp
13
- *
13
+ *
14
+ * Connected component
14
15
  * see CvMat#flood_fill
15
- *
16
- * C structure is here.
17
- * typedef struct CvConnectedComp
18
- * {
19
- * double area;
20
- * CvScalar value;
21
- * CvRect rect;
22
- * CvSeq* contour;
23
- * } CvConnectedComp;
24
16
  */
25
17
  __NAMESPACE_BEGIN_OPENCV
26
18
  __NAMESPACE_BEGIN_CVCONNECTEDCOMP
@@ -33,28 +25,6 @@ rb_class()
33
25
  return rb_klass;
34
26
  }
35
27
 
36
- void
37
- define_ruby_class()
38
- {
39
- if (rb_klass)
40
- return;
41
- /*
42
- * opencv = rb_define_module("OpenCV");
43
- *
44
- * note: this comment is used by rdoc.
45
- */
46
- VALUE opencv = rb_module_opencv();
47
-
48
- rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
49
- rb_define_alloc_func(rb_klass, rb_allocate);
50
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
51
- rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
52
- rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
53
- rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
54
- rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
55
- rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
56
- }
57
-
58
28
  VALUE
59
29
  rb_allocate(VALUE klass)
60
30
  {
@@ -62,6 +32,15 @@ rb_allocate(VALUE klass)
62
32
  return Data_Make_Struct(klass, CvConnectedComp, 0, -1, ptr);
63
33
  }
64
34
 
35
+ /*
36
+ * Constructor
37
+ * @overload new(area = nil, value = nil, rect = nil, contour = nil)
38
+ * @param area [Number] Area of the segmented component
39
+ * @param value [CvScalar] Average color of the connected component
40
+ * @param rect [CvRect] ROI of the segmented component
41
+ * @param contour [CvSeq] Optional component boundary
42
+ * @return [CvConnectedComp] self
43
+ */
65
44
  VALUE
66
45
  rb_initialize(int argc, VALUE *argv, VALUE self)
67
46
  {
@@ -80,7 +59,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
80
59
  }
81
60
 
82
61
  /*
83
- * Return area of connected component.
62
+ * Returns area of connected component
63
+ * @overload area
64
+ * @return [Number] Area of the connected component
84
65
  */
85
66
  VALUE
86
67
  rb_area(VALUE self)
@@ -90,6 +71,8 @@ rb_area(VALUE self)
90
71
 
91
72
  /*
92
73
  * Return average color of the connected component.
74
+ * @overload value
75
+ * @return [CvScalar] Average color of the connected component
93
76
  */
94
77
  VALUE
95
78
  rb_value(VALUE self)
@@ -98,7 +81,9 @@ rb_value(VALUE self)
98
81
  }
99
82
 
100
83
  /*
101
- * Return ROI of the component.
84
+ * Return ROI of the segmented component
85
+ * @overload rect
86
+ * @return [CvRect] ROI of the segmented component
102
87
  */
103
88
  VALUE
104
89
  rb_rect(VALUE self)
@@ -107,7 +92,10 @@ rb_rect(VALUE self)
107
92
  }
108
93
 
109
94
  /*
110
- * Set ROI of the component.
95
+ * Set ROI of the segmented component
96
+ * @overload rect=value
97
+ * @param value [CvRect] ROI to set
98
+ * @return [CvRect] ROI of the segmented component
111
99
  */
112
100
  VALUE
113
101
  rb_set_rect(VALUE self, VALUE rect)
@@ -117,7 +105,9 @@ rb_set_rect(VALUE self, VALUE rect)
117
105
  }
118
106
 
119
107
  /*
120
- * Return optional component boundary
108
+ * Returns optional component boundary
109
+ * @overload contour
110
+ * @return [CvContour] Optional component boundary
121
111
  */
122
112
  VALUE
123
113
  rb_contour(VALUE self)
@@ -139,5 +129,28 @@ new_object(CvConnectedComp comp)
139
129
  return object;
140
130
  }
141
131
 
132
+ void
133
+ init_ruby_class()
134
+ {
135
+ #if 0
136
+ // For documentation using YARD
137
+ VALUE opencv = rb_define_module("OpenCV");
138
+ #endif
139
+
140
+ if (rb_klass)
141
+ return;
142
+
143
+ VALUE opencv = rb_module_opencv();
144
+
145
+ rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
146
+ rb_define_alloc_func(rb_klass, rb_allocate);
147
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
148
+ rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
149
+ rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
150
+ rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
151
+ rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
152
+ rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
153
+ }
154
+
142
155
  __NAMESPACE_END_CVCONNECTEDCOMP
143
156
  __NAMESPACE_END_OPENCV