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
@@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVCONNECTEDCOMP
20
20
 
21
21
  VALUE rb_class();
22
22
 
23
- void define_ruby_class();
23
+ void init_ruby_class();
24
24
 
25
25
  VALUE rb_allocate(VALUE klass);
26
26
 
@@ -11,8 +11,9 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvContour
13
13
  *
14
- * Contour.
15
- * CvMat#find_contours
14
+ * Contour
15
+ *
16
+ * @see CvMat#find_contours
16
17
  */
17
18
  __NAMESPACE_BEGIN_OPENCV
18
19
  __NAMESPACE_BEGIN_CVCONTOUR
@@ -33,56 +34,19 @@ rb_class()
33
34
  return rb_klass;
34
35
  }
35
36
 
36
- void
37
- define_ruby_class()
38
- {
39
- if (rb_klass)
40
- return;
41
- /*
42
- * opencv = rb_define_module("OpenCV");
43
- * cvseq = rb_define_class_under(opencv, "CvSeq");
44
- * curve = rb_define_module_under(opencv, "Curve");
45
- * pointset = rb_define_module_under(opencv, "PointSet");
46
- *
47
- * note: this comment is used by rdoc.
48
- */
49
- VALUE opencv = rb_module_opencv();
50
- VALUE cvseq = cCvSeq::rb_class();
51
- VALUE curve = mCurve::rb_module();
52
- VALUE pointset = mPointSet::rb_module();
53
-
54
- rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
55
- rb_include_module(rb_klass, curve);
56
- rb_include_module(rb_klass, pointset);
57
-
58
- rb_define_alloc_func(rb_klass, rb_allocate);
59
-
60
- VALUE approx_option = rb_hash_new();
61
- rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
62
- rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
63
- rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
64
- rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
65
-
66
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
67
- rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
68
- rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
69
- rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
70
- rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
71
- rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
72
- rb_define_alias(rb_klass, "approx", "approx_poly");
73
- rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
74
- rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
75
- rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
76
- rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
77
- rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
78
- }
79
-
80
37
  VALUE
81
38
  rb_allocate(VALUE klass)
82
39
  {
83
40
  return Data_Wrap_Struct(klass, mark_root_object, unregister_object, NULL);
84
41
  }
85
42
 
43
+ /*
44
+ * Constructor
45
+ * @overload new(storage = nil)
46
+ * @param [CvMemStorage] storage Sequence location
47
+ * @return [CvContour] self
48
+ * @opencv_func cvCreateSeq
49
+ */
86
50
  VALUE
87
51
  rb_initialize(int argc, VALUE *argv, VALUE self)
88
52
  {
@@ -107,18 +71,33 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
107
71
  return self;
108
72
  }
109
73
 
74
+ /*
75
+ * Returns bounding box of the contour
76
+ * @overload rect
77
+ * @return [CvRect] Bounding box of the contour
78
+ */
110
79
  VALUE
111
80
  rb_rect(VALUE self)
112
81
  {
113
82
  return cCvRect::new_object(CVCONTOUR(self)->rect);
114
83
  }
115
84
 
85
+ /*
86
+ * Returns color of the contour
87
+ * @overload color
88
+ * @return [Number] Color of the contour
89
+ */
116
90
  VALUE
117
91
  rb_color(VALUE self)
118
92
  {
119
93
  return INT2NUM(CVCONTOUR(self)->color);
120
94
  }
121
95
 
96
+ /*
97
+ * Set color of the contour
98
+ * @overload color=value
99
+ * @param value [Number] Color of the contour
100
+ */
122
101
  VALUE
123
102
  rb_set_color(VALUE self, VALUE color)
124
103
  {
@@ -126,6 +105,11 @@ rb_set_color(VALUE self, VALUE color)
126
105
  return self;
127
106
  }
128
107
 
108
+ /*
109
+ * Returns reserved region values of the contour
110
+ * @overload reserved
111
+ * @return [Array<Number>] Reserved region values of the contour
112
+ */
129
113
  VALUE
130
114
  rb_reserved(VALUE self)
131
115
  {
@@ -136,17 +120,18 @@ rb_reserved(VALUE self)
136
120
  }
137
121
 
138
122
  /*
139
- * call-seq:
140
- * approx_poly(<i>approx_poly_option</i>) -> cvcontour
141
- *
142
- * Approximates polygonal curve(s) with desired precision.
143
- * <i>approx_poly_option</i> should be Hash include these keys.
144
- * :method - Approximation method.
145
- * :dp - corresponds to Douglas-Peucker algorithm.
146
- * :accuracy - approximation accuracy. (high-accuracy will create more simple contours)
147
- * :recursive - (default false)
148
- * If not nil or false, the function approximates all chains that access can be obtained to
149
- * from self by h_next or v_next links. If 0, approximated this one.
123
+ * Approximates polygonal curves with desired precision
124
+ * @overload approx_poly(options)
125
+ * @param options [Hash] Parameters
126
+ * @option options [Symbol] :method Approximation method (default :dp)
127
+ * * :dp - Douglas-Peucker algorithm.
128
+ * @option options [Number] :accuracy Parameter specifying the approximation accuracy.
129
+ * This is the maximum distance between the original curve and its approximation.
130
+ * @option options [Boolean] :recursive Recursion flag. If true, the function approximates
131
+ * all the contours accessible from curve by h_next and v_next links.
132
+ * @return [CvContour] Result of the approximation
133
+ * @return [nil] Approximation faied
134
+ * @opencv_func cvApproxPoly
150
135
  */
151
136
  VALUE
152
137
  rb_approx_poly(int argc, VALUE *argv, VALUE self)
@@ -167,11 +152,10 @@ rb_approx_poly(int argc, VALUE *argv, VALUE self)
167
152
  }
168
153
 
169
154
  /*
170
- * call-seq:
171
- * bounding_rect -> rect
172
- *
173
155
  * Calculates up-right bounding rectangle of point set.
174
- *
156
+ * @overload bounding_rect
157
+ * @return [CvRect] Bounding rectangle
158
+ * @opencv_func cvBoundingRect
175
159
  */
176
160
  VALUE
177
161
  rb_bounding_rect(VALUE self)
@@ -187,14 +171,12 @@ rb_bounding_rect(VALUE self)
187
171
  }
188
172
 
189
173
  /*
190
- * call-seq:
191
- * create_tree([threshold = 0.0]) -> cvcontourtree
192
- *
193
- * Creates hierarchical representation of contour.
194
- * If the parameter <i>threshold</i> is less than or equal to 0,
195
- * the method creates full binary tree representation.
196
- * If the threshold is greater than 0, the function creates
197
- * representation with the precision threshold:
174
+ * Creates hierarchical representation of contour
175
+ * @overload create_tree(threshold = 0.0)
176
+ * @param threshold [Number] If <= 0, the method creates full binary tree representation.
177
+ * If > 0, the method creates representation with the precision threshold.
178
+ * @return [CvContourTree] Hierarchical representation of the contour
179
+ * @opencv_func cvCreateContourTree
198
180
  */
199
181
  VALUE
200
182
  rb_create_tree(int argc, VALUE *argv, VALUE self)
@@ -213,10 +195,14 @@ rb_create_tree(int argc, VALUE *argv, VALUE self)
213
195
  }
214
196
 
215
197
  /*
216
- * call-seq:
217
- * in?(<i>point</i>) -> true or nil or false
218
- *
219
- * Determines whether the <i>point</i> is inside contour(true), outside(false) or lies on an edge(nil).
198
+ * Performs a point-in-contour test.
199
+ * The method determines whether the point is inside a contour, outside,
200
+ * or lies on an edge (or coincides with a vertex).
201
+ * @overload in?(point)
202
+ * @param point [CvPoint2D32f] Point tested against the contour
203
+ * @return [Boolean] If the point is inside, returns true. If outside, returns false.
204
+ * If lies on an edge, returns nil.
205
+ * @opencv_func cvPointPolygonTest
220
206
  */
221
207
  VALUE
222
208
  rb_in_q(VALUE self, VALUE point)
@@ -232,10 +218,11 @@ rb_in_q(VALUE self, VALUE point)
232
218
  }
233
219
 
234
220
  /*
235
- * call-seq:
236
- * measure_distance(<i>point</i>) -> float
237
- *
238
- * Return distance between the point and the nearest contour edge.
221
+ * Calculates distance between a point and the nearest contour edgex
222
+ * @overload measure_distance(point)
223
+ * @param point [CvPoint2D32f] Point tested against the contour
224
+ * @return Signed distance between the point and the nearest contour edge
225
+ * @opencv_func cvPointPolygonTest
239
226
  */
240
227
  VALUE
241
228
  rb_measure_distance(VALUE self, VALUE point)
@@ -251,11 +238,14 @@ rb_measure_distance(VALUE self, VALUE point)
251
238
  }
252
239
 
253
240
  /*
254
- * call-seq:
255
- * point_polygon_test(<i>point, measure_dist</i>) -> float
256
- *
257
241
  * Determines whether the point is inside a contour, outside, or lies on an edge (or coinsides with a vertex).
258
- * It returns positive, negative or zero value, correspondingly. When measure_dist = false or 0, the return value is +1, -1 and 0, respectively. When measure_dist = true or 1, it is a signed distance between the point and the nearest contour edge.
242
+ * @overload point_polygon_test(point, measure_dist)
243
+ * @param point [CvPoint2D32f] Point tested against the contour
244
+ * @param measure_dist [Boolean] If true, the method estimates the signed distance from the point to
245
+ * the nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not.
246
+ * @return [Number] When measure_dist = false, the return value is +1, -1 and 0, respectively.
247
+ * When measure_dist = true, it is a signed distance between the point and the nearest contour edge.
248
+ * @opencv_func cvPointPolygonTest
259
249
  */
260
250
  VALUE
261
251
  rb_point_polygon_test(VALUE self, VALUE point, VALUE measure_dist)
@@ -291,6 +281,52 @@ VALUE new_object()
291
281
  return object;
292
282
  }
293
283
 
284
+
285
+ void
286
+ init_ruby_class()
287
+ {
288
+ #if 0
289
+ // For documentation using YARD
290
+ VALUE opencv = rb_define_module("OpenCV");
291
+ VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
292
+ VALUE curve = rb_define_module_under(opencv, "Curve");
293
+ VALUE pointset = rb_define_module_under(opencv, "PointSet");
294
+ #endif
295
+
296
+ if (rb_klass)
297
+ return;
298
+
299
+ VALUE opencv = rb_module_opencv();
300
+ VALUE cvseq = cCvSeq::rb_class();
301
+ VALUE curve = mCurve::rb_module();
302
+ VALUE pointset = mPointSet::rb_module();
303
+
304
+ rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
305
+ rb_include_module(rb_klass, curve);
306
+ rb_include_module(rb_klass, pointset);
307
+
308
+ rb_define_alloc_func(rb_klass, rb_allocate);
309
+
310
+ VALUE approx_option = rb_hash_new();
311
+ rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
312
+ rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
313
+ rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
314
+ rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
315
+
316
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
317
+ rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
318
+ rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
319
+ rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
320
+ rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
321
+ rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
322
+ rb_define_alias(rb_klass, "approx", "approx_poly");
323
+ rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
324
+ rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
325
+ rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
326
+ rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
327
+ rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
328
+ }
329
+
294
330
  __NAMESPACE_END_CVCONTOUR
295
331
  __NAMESPACE_END_OPENCV
296
332
 
@@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCONTOUR
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_initialize(int argc, VALUE *argv, VALUE self);
25
25
  VALUE rb_rect(VALUE self);
@@ -11,15 +11,9 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvContourTree
13
13
  *
14
- * Contour tree. CvContour#create_tree
14
+ * Contour tree
15
15
  *
16
- * C structure is here.
17
- * typedef struct CvContourTree {
18
- * CV_SEQUENCE_FIELDS()
19
- * CvPoint p1;
20
- * CvPoint p2;
21
- * } CvContourTree;
22
- *
16
+ * @see CvContour#create_tree
23
17
  */
24
18
  __NAMESPACE_BEGIN_OPENCV
25
19
  __NAMESPACE_BEGIN_CVCONTOURTREE
@@ -32,32 +26,22 @@ rb_class()
32
26
  return rb_klass;
33
27
  }
34
28
 
35
- void
36
- define_ruby_class()
37
- {
38
- if (rb_klass)
39
- return;
40
- /*
41
- * opencv = rb_define_module("OpenCV");
42
- * cvseq = rb_define_class_under(opencv, "CvSeq");
43
- *
44
- * note: this comment is used by rdoc.
45
- */
46
- VALUE opencv = rb_module_opencv();
47
- VALUE cvseq = cCvSeq::rb_class();
48
-
49
- rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
50
- rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
51
- rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
52
- rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 1);
53
- }
54
-
29
+ /*
30
+ * Returns the first point of the binary tree root segment
31
+ * @overload p1
32
+ * @return [CvPoint] First point of the binary tree root segment
33
+ */
55
34
  VALUE
56
35
  rb_p1(VALUE self)
57
36
  {
58
37
  return REFER_OBJECT(cCvPoint::rb_class(), &CVCONTOURTREE(self)->p1, self);
59
38
  }
60
39
 
40
+ /*
41
+ * Returns the last point of the binary tree root segment
42
+ * @overload p2
43
+ * @return [CvPoint] Last point of the binary tree root segment
44
+ */
61
45
  VALUE
62
46
  rb_p2(VALUE self)
63
47
  {
@@ -65,12 +49,14 @@ rb_p2(VALUE self)
65
49
  }
66
50
 
67
51
  /*
68
- * call-seq:
69
- * contour(<i>[criteria = 0]</i>) -> cvcontour
70
- *
71
52
  * Restores the contour from its binary tree representation.
72
- * The parameter criteria determines the accuracy and/or the number of tree levels
53
+ *
54
+ * The parameter +criteria+ determines the accuracy and/or the number of tree levels
73
55
  * used for reconstruction, so it is possible to build approximated contour.
56
+ * @overload contour(criteria = 0)
57
+ * @param criteria [Integer] Criteria, where to stop reconstruction
58
+ * @return [CvContour] Contour tree
59
+ * @opencv_func cvContourFromContourTree
74
60
  */
75
61
  VALUE
76
62
  rb_contour(VALUE self, VALUE criteria)
@@ -87,5 +73,24 @@ rb_contour(VALUE self, VALUE criteria)
87
73
  return cCvSeq::new_sequence(cCvContour::rb_class(), contour, cCvPoint::rb_class(), storage);
88
74
  }
89
75
 
76
+ void
77
+ init_ruby_class()
78
+ {
79
+ #if 0
80
+ // For documentation using YARD
81
+ VALUE opencv = rb_define_module("OpenCV");
82
+ VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
83
+ #endif
84
+ if (rb_klass)
85
+ return;
86
+ VALUE opencv = rb_module_opencv();
87
+ VALUE cvseq = cCvSeq::rb_class();
88
+
89
+ rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
90
+ rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
91
+ rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
92
+ rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 1);
93
+ }
94
+
90
95
  __NAMESPACE_END_CVCONTOURTREE
91
96
  __NAMESPACE_END_OPENCV
@@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCONTOURTREE
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_p1(VALUE self);
25
25
  VALUE rb_p2(VALUE self);
@@ -11,15 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvConvexityDefect
13
13
  *
14
- * Convexity.
15
- * C structure is here.
16
- * typedef struct CvConvexityDefect {
17
- * CvPoint* start;
18
- * CvPoint* end;
19
- * CvPoint* depth_point;
20
- * float depth;
21
- * } CvConvexityDefect;
22
- *
14
+ * Convexity defect
23
15
  */
24
16
  __NAMESPACE_BEGIN_OPENCV
25
17
  __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
@@ -32,30 +24,10 @@ rb_class()
32
24
  return rb_klass;
33
25
  }
34
26
 
35
- void
36
- define_ruby_class()
37
- {
38
- if (rb_klass)
39
- return;
40
- /*
41
- * opencv = rb_define_module("OpenCV");
42
- *
43
- * note: this comment is used by rdoc.
44
- */
45
- VALUE opencv = rb_module_opencv();
46
-
47
- rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
48
- rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
49
- rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
50
- rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
51
- rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
52
- }
53
-
54
27
  /*
55
- * call-seq:
56
- * start -> cvpoint
57
- *
58
- * Return start point as CvPoint.
28
+ * Returns the point of the contour where the defect begins
29
+ * @overload start
30
+ * @return [CvPoint] Start point of the contour
59
31
  */
60
32
  VALUE
61
33
  rb_start(VALUE self)
@@ -64,10 +36,9 @@ rb_start(VALUE self)
64
36
  }
65
37
 
66
38
  /*
67
- * call-seq:
68
- * end -> cvpoint
69
- *
70
- * Return end point as CvPoint.
39
+ * Returns the point of the contour where the defect ends
40
+ * @overload end
41
+ * @return [CvPoint] End point of the contour
71
42
  */
72
43
  VALUE
73
44
  rb_end(VALUE self)
@@ -76,10 +47,9 @@ rb_end(VALUE self)
76
47
  }
77
48
 
78
49
  /*
79
- * call-seq:
80
- * depth_point -> cvpoint
81
- *
82
- * Return depth point as CvPoint.
50
+ * Returns the farthest from the convex hull point within the defect
51
+ * @overload depth_point
52
+ * @return [CvPoint] The farthest from the convex hull point within the defect
83
53
  */
84
54
  VALUE
85
55
  rb_depth_point(VALUE self)
@@ -88,10 +58,9 @@ rb_depth_point(VALUE self)
88
58
  }
89
59
 
90
60
  /*
91
- * call-seq:
92
- * depth -> float
93
- *
94
- * Return depth.
61
+ * Returns distance between the farthest point and the convex hull
62
+ * @overload depth
63
+ * @return [Number] Distance between the farthest point and the convex hull
95
64
  */
96
65
  VALUE
97
66
  rb_depth(VALUE self)
@@ -99,5 +68,25 @@ rb_depth(VALUE self)
99
68
  return rb_float_new(CVCONVEXITYDEFECT(self)->depth);
100
69
  }
101
70
 
71
+ void
72
+ init_ruby_class()
73
+ {
74
+ #if 0
75
+ // For documentation using YARD
76
+ VALUE opencv = rb_define_module("OpenCV");
77
+ #endif
78
+
79
+ if (rb_klass)
80
+ return;
81
+
82
+ VALUE opencv = rb_module_opencv();
83
+
84
+ rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
85
+ rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
86
+ rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
87
+ rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
88
+ rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
89
+ }
90
+
102
91
  __NAMESPACE_END_CVCONVEXITYDEFECT
103
92
  __NAMESPACE_END_OPENCV