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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.yardopts +3 -0
- data/Gemfile +1 -0
- data/Manifest.txt +2 -14
- data/README.md +1 -1
- data/Rakefile +10 -1
- data/examples/facerec/facerec_lbph.rb +1 -1
- data/ext/opencv/algorithm.cpp +6 -1
- data/ext/opencv/algorithm.h +1 -1
- data/ext/opencv/curve.cpp +48 -33
- data/ext/opencv/curve.h +1 -1
- data/ext/opencv/cvavgcomp.cpp +22 -25
- data/ext/opencv/cvavgcomp.h +1 -1
- data/ext/opencv/cvbox2d.cpp +56 -58
- data/ext/opencv/cvbox2d.h +1 -1
- data/ext/opencv/cvcapture.cpp +210 -109
- data/ext/opencv/cvcapture.h +1 -1
- data/ext/opencv/cvchain.cpp +71 -71
- data/ext/opencv/cvchain.h +1 -1
- data/ext/opencv/cvcircle32f.cpp +37 -27
- data/ext/opencv/cvcircle32f.h +1 -1
- data/ext/opencv/cvconnectedcomp.cpp +49 -36
- data/ext/opencv/cvconnectedcomp.h +1 -1
- data/ext/opencv/cvcontour.cpp +117 -81
- data/ext/opencv/cvcontour.h +1 -1
- data/ext/opencv/cvcontourtree.cpp +37 -32
- data/ext/opencv/cvcontourtree.h +1 -1
- data/ext/opencv/cvconvexitydefect.cpp +33 -44
- data/ext/opencv/cvconvexitydefect.h +1 -1
- data/ext/opencv/cverror.cpp +22 -66
- data/ext/opencv/cverror.h +1 -1
- data/ext/opencv/cvfeaturetree.cpp +31 -33
- data/ext/opencv/cvfeaturetree.h +1 -1
- data/ext/opencv/cvfont.cpp +98 -78
- data/ext/opencv/cvfont.h +1 -1
- data/ext/opencv/cvhaarclassifiercascade.cpp +39 -59
- data/ext/opencv/cvhaarclassifiercascade.h +1 -1
- data/ext/opencv/cvhistogram.cpp +259 -90
- data/ext/opencv/cvhistogram.h +1 -1
- data/ext/opencv/cvhumoments.cpp +99 -60
- data/ext/opencv/cvhumoments.h +1 -1
- data/ext/opencv/cvline.cpp +45 -40
- data/ext/opencv/cvline.h +1 -1
- data/ext/opencv/cvmat.cpp +1894 -1829
- data/ext/opencv/cvmat.h +2 -3
- data/ext/opencv/cvmemstorage.cpp +19 -14
- data/ext/opencv/cvmemstorage.h +1 -1
- data/ext/opencv/cvmoments.cpp +51 -45
- data/ext/opencv/cvmoments.h +1 -1
- data/ext/opencv/cvpoint.cpp +32 -26
- data/ext/opencv/cvpoint.h +1 -1
- data/ext/opencv/cvpoint2d32f.cpp +31 -26
- data/ext/opencv/cvpoint2d32f.h +1 -1
- data/ext/opencv/cvpoint3d32f.cpp +36 -29
- data/ext/opencv/cvpoint3d32f.h +1 -1
- data/ext/opencv/cvrect.cpp +38 -33
- data/ext/opencv/cvrect.h +1 -1
- data/ext/opencv/cvscalar.cpp +50 -45
- data/ext/opencv/cvscalar.h +1 -1
- data/ext/opencv/cvseq.cpp +53 -47
- data/ext/opencv/cvseq.h +1 -1
- data/ext/opencv/cvsize.cpp +32 -26
- data/ext/opencv/cvsize.h +1 -1
- data/ext/opencv/cvsize2d32f.cpp +31 -25
- data/ext/opencv/cvsize2d32f.h +1 -1
- data/ext/opencv/cvslice.cpp +28 -22
- data/ext/opencv/cvslice.h +1 -1
- data/ext/opencv/cvsurfparams.cpp +37 -28
- data/ext/opencv/cvsurfparams.h +1 -1
- data/ext/opencv/cvsurfpoint.cpp +76 -53
- data/ext/opencv/cvsurfpoint.h +1 -1
- data/ext/opencv/cvtermcriteria.cpp +32 -26
- data/ext/opencv/cvtermcriteria.h +1 -1
- data/ext/opencv/cvtwopoints.cpp +28 -22
- data/ext/opencv/cvtwopoints.h +1 -1
- data/ext/opencv/cvvideowriter.cpp +25 -20
- data/ext/opencv/cvvideowriter.h +1 -1
- data/ext/opencv/eigenfaces.cpp +10 -2
- data/ext/opencv/eigenfaces.h +1 -1
- data/ext/opencv/facerecognizer.cpp +15 -8
- data/ext/opencv/facerecognizer.h +2 -2
- data/ext/opencv/fisherfaces.cpp +10 -2
- data/ext/opencv/fisherfaces.h +1 -1
- data/ext/opencv/gui.cpp +26 -23
- data/ext/opencv/gui.h +1 -1
- data/ext/opencv/iplconvkernel.cpp +30 -24
- data/ext/opencv/iplconvkernel.h +1 -1
- data/ext/opencv/iplimage.cpp +49 -42
- data/ext/opencv/iplimage.h +1 -1
- data/ext/opencv/lbph.cpp +10 -2
- data/ext/opencv/lbph.h +1 -1
- data/ext/opencv/mouseevent.cpp +30 -25
- data/ext/opencv/mouseevent.h +1 -1
- data/ext/opencv/opencv.cpp +59 -60
- data/ext/opencv/opencv.h +1 -5
- data/ext/opencv/pointset.cpp +31 -25
- data/ext/opencv/pointset.h +1 -1
- data/ext/opencv/trackbar.cpp +27 -21
- data/ext/opencv/trackbar.h +1 -1
- data/ext/opencv/window.cpp +77 -57
- data/ext/opencv/window.h +1 -1
- data/lib/opencv/version.rb +2 -1
- data/ruby-opencv.gemspec +19 -18
- data/test/test_opencv.rb +5 -3
- data/yard_extension.rb +5 -0
- metadata +13 -27
- data/examples/matching_to_many_images/matching_to_many_images.rb +0 -16
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +0 -3
- data/ext/opencv/cvcondensation.cpp +0 -282
- data/ext/opencv/cvcondensation.h +0 -49
- data/ext/opencv/cvmatnd.cpp +0 -44
- data/ext/opencv/cvmatnd.h +0 -28
- data/ext/opencv/cvsparsemat.cpp +0 -44
- data/ext/opencv/cvsparsemat.h +0 -28
- data/images/face_detect_from_lena.jpg +0 -0
- data/test/test_cvmat_matching.rb +0 -57
data/ext/opencv/cvcapture.h
CHANGED
data/ext/opencv/cvchain.cpp
CHANGED
|
@@ -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
|
-
*
|
|
100
|
-
*
|
|
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
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
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
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
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
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
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
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
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
|
data/ext/opencv/cvchain.h
CHANGED
data/ext/opencv/cvcircle32f.cpp
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
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
|
data/ext/opencv/cvcircle32f.h
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|