opencv 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/History.txt +5 -0
  2. data/License.txt +30 -0
  3. data/Manifest.txt +115 -0
  4. data/README.txt +47 -0
  5. data/Rakefile +34 -0
  6. data/examples/convexhull.rb +41 -0
  7. data/examples/face_detect.rb +25 -0
  8. data/examples/houghcircle.rb +23 -0
  9. data/examples/inpaint.png +0 -0
  10. data/examples/inpaint.rb +43 -0
  11. data/examples/paint.rb +72 -0
  12. data/examples/snake.rb +43 -0
  13. data/examples/stuff.jpg +0 -0
  14. data/ext/curve.cpp +103 -0
  15. data/ext/curve.h +34 -0
  16. data/ext/cvavgcomp.cpp +67 -0
  17. data/ext/cvavgcomp.h +39 -0
  18. data/ext/cvbox2d.cpp +114 -0
  19. data/ext/cvbox2d.h +53 -0
  20. data/ext/cvcapture.cpp +276 -0
  21. data/ext/cvcapture.h +54 -0
  22. data/ext/cvchain.cpp +184 -0
  23. data/ext/cvchain.h +43 -0
  24. data/ext/cvchaincode.cpp +49 -0
  25. data/ext/cvchaincode.h +43 -0
  26. data/ext/cvcircle32f.cpp +90 -0
  27. data/ext/cvcircle32f.h +53 -0
  28. data/ext/cvcondensation.cpp +230 -0
  29. data/ext/cvcondensation.h +49 -0
  30. data/ext/cvconnectedcomp.cpp +115 -0
  31. data/ext/cvconnectedcomp.h +46 -0
  32. data/ext/cvcontour.cpp +219 -0
  33. data/ext/cvcontour.h +47 -0
  34. data/ext/cvcontourtree.cpp +86 -0
  35. data/ext/cvcontourtree.h +41 -0
  36. data/ext/cvconvexitydefect.cpp +103 -0
  37. data/ext/cvconvexitydefect.h +42 -0
  38. data/ext/cverror.cpp +140 -0
  39. data/ext/cverror.h +79 -0
  40. data/ext/cvfont.cpp +173 -0
  41. data/ext/cvfont.h +56 -0
  42. data/ext/cvhaarclassifiercascade.cpp +159 -0
  43. data/ext/cvhaarclassifiercascade.h +41 -0
  44. data/ext/cvhistogram.cpp +200 -0
  45. data/ext/cvhistogram.h +51 -0
  46. data/ext/cvindex.cpp +73 -0
  47. data/ext/cvindex.h +40 -0
  48. data/ext/cvline.cpp +106 -0
  49. data/ext/cvline.h +52 -0
  50. data/ext/cvmat.cpp +4809 -0
  51. data/ext/cvmat.h +286 -0
  52. data/ext/cvmatnd.cpp +44 -0
  53. data/ext/cvmatnd.h +28 -0
  54. data/ext/cvmemstorage.cpp +64 -0
  55. data/ext/cvmemstorage.h +53 -0
  56. data/ext/cvmoments.cpp +204 -0
  57. data/ext/cvmoments.h +48 -0
  58. data/ext/cvpoint.cpp +229 -0
  59. data/ext/cvpoint.h +59 -0
  60. data/ext/cvpoint2d32f.cpp +213 -0
  61. data/ext/cvpoint2d32f.h +61 -0
  62. data/ext/cvpoint3d32f.cpp +245 -0
  63. data/ext/cvpoint3d32f.h +64 -0
  64. data/ext/cvrect.cpp +340 -0
  65. data/ext/cvrect.h +79 -0
  66. data/ext/cvscalar.cpp +227 -0
  67. data/ext/cvscalar.h +63 -0
  68. data/ext/cvseq.cpp +583 -0
  69. data/ext/cvseq.h +71 -0
  70. data/ext/cvset.cpp +63 -0
  71. data/ext/cvset.h +39 -0
  72. data/ext/cvsize.cpp +223 -0
  73. data/ext/cvsize.h +63 -0
  74. data/ext/cvsize2d32f.cpp +180 -0
  75. data/ext/cvsize2d32f.h +59 -0
  76. data/ext/cvslice.cpp +82 -0
  77. data/ext/cvslice.h +53 -0
  78. data/ext/cvsparsemat.cpp +44 -0
  79. data/ext/cvsparsemat.h +28 -0
  80. data/ext/cvtermcriteria.cpp +183 -0
  81. data/ext/cvtermcriteria.h +71 -0
  82. data/ext/cvtwopoints.cpp +98 -0
  83. data/ext/cvtwopoints.h +50 -0
  84. data/ext/cvvector.cpp +206 -0
  85. data/ext/cvvector.h +54 -0
  86. data/ext/cvvideowriter.cpp +116 -0
  87. data/ext/cvvideowriter.h +41 -0
  88. data/ext/extconf.rb +61 -0
  89. data/ext/gui.cpp +65 -0
  90. data/ext/gui.h +33 -0
  91. data/ext/iplconvkernel.cpp +177 -0
  92. data/ext/iplconvkernel.h +52 -0
  93. data/ext/iplimage.cpp +238 -0
  94. data/ext/iplimage.h +54 -0
  95. data/ext/mouseevent.cpp +184 -0
  96. data/ext/mouseevent.h +59 -0
  97. data/ext/opencv.cpp +481 -0
  98. data/ext/opencv.h +356 -0
  99. data/ext/point3dset.cpp +41 -0
  100. data/ext/point3dset.h +31 -0
  101. data/ext/pointset.cpp +238 -0
  102. data/ext/pointset.h +69 -0
  103. data/ext/trackbar.cpp +122 -0
  104. data/ext/trackbar.h +65 -0
  105. data/ext/window.cpp +368 -0
  106. data/ext/window.h +56 -0
  107. data/images/CvMat_sobel.png +0 -0
  108. data/images/CvMat_sub_rect.png +0 -0
  109. data/images/CvSeq_relationmap.png +0 -0
  110. data/images/face_detect_from_lena.jpg +0 -0
  111. data/lib/opencv.rb +3 -0
  112. data/lib/version.rb +3 -0
  113. data/setup/setup.cygwin.rb +120 -0
  114. data/setup/setup.mingw.rb +99 -0
  115. data/setup/setup.mswin32.rb +103 -0
  116. data/test/test_opencv.rb +4 -0
  117. metadata +191 -0
@@ -0,0 +1,71 @@
1
+ /************************************************************
2
+
3
+ cvseq.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSEQ_H
11
+ #define RUBY_OPENCV_CVSEQ_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSEQ namespace cCvSeq{
16
+ #define __NAMESPACE_END_CVSEQ }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSEQ
20
+
21
+ VALUE rb_class();
22
+ void define_ruby_class();
23
+
24
+ VALUE seqblock_class(void *ptr);
25
+
26
+ VALUE rb_allocate(VALUE klass);
27
+ void free(void *ptr);
28
+ void resist_class_information_of_sequence(CvSeq *seq, VALUE klass);
29
+
30
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
31
+ VALUE rb_total(VALUE self);
32
+ VALUE rb_empty_q(VALUE self);
33
+ VALUE rb_aref(VALUE self, VALUE index);
34
+ VALUE rb_first(VALUE self);
35
+ VALUE rb_last(VALUE self);
36
+ VALUE rb_index(VALUE self, VALUE object);
37
+ VALUE rb_h_prev(VALUE self);
38
+ VALUE rb_h_next(VALUE self);
39
+ VALUE rb_v_prev(VALUE self);
40
+ VALUE rb_v_next(VALUE self);
41
+ VALUE rb_push(VALUE self, VALUE args);
42
+ VALUE rb_pop(VALUE self);
43
+ VALUE rb_unshift(VALUE self, VALUE args);
44
+ VALUE rb_shift(VALUE self);
45
+ VALUE rb_each(VALUE self);
46
+ VALUE rb_each_index(VALUE self);
47
+ VALUE rb_each_with_index(VALUE self);
48
+ VALUE rb_insert(VALUE self, VALUE index, VALUE object);
49
+ VALUE rb_remove(VALUE self, VALUE index);
50
+ VALUE rb_clear(VALUE self);
51
+ VALUE rb_clone(VALUE self);
52
+
53
+ VALUE new_object(CvSeq *seq, VALUE klass);
54
+ VALUE new_object(CvSeq *seq, VALUE klass, VALUE storage);
55
+ //VALUE new_object(CvSeq *seq, VALUE storage, VALUE klass);
56
+ VALUE new_sequence(VALUE klass, CvSeq *seq, VALUE element_klass, VALUE storage);
57
+ VALUE auto_extend(VALUE object);
58
+
59
+ __NAMESPACE_END_CVSEQ
60
+
61
+ inline CvSeq*
62
+ CVSEQ(VALUE object)
63
+ {
64
+ CvSeq *ptr;
65
+ Data_Get_Struct(object, CvSeq, ptr);
66
+ return ptr;
67
+ }
68
+
69
+ __NAMESPACE_END_OPENCV
70
+
71
+ #endif // RUBY_OPENCV_CVSEQ_H
@@ -0,0 +1,63 @@
1
+ /************************************************************
2
+
3
+ cvseq.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvset.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSet
13
+ *
14
+ * Collection of nodes.
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_CVSET
18
+
19
+ VALUE rb_klass;
20
+
21
+ VALUE
22
+ rb_class()
23
+ {
24
+ return rb_klass;
25
+ }
26
+
27
+ void
28
+ define_ruby_class()
29
+ {
30
+ if(rb_klass)
31
+ return;
32
+ /*
33
+ * opencv = rb_define_module("OpenCV");
34
+ * cvseq = rb_define_class_under(opencv, "CvSeq", rb_cObject);
35
+ *
36
+ * note: this comment is used by rdoc.
37
+ */
38
+ VALUE opencv = rb_module_opencv(), cvseq = cCvSeq::rb_class();
39
+ rb_klass = rb_define_class_under(opencv, "CvSet", cvseq);
40
+ rb_define_method(rb_klass, "active_count", RUBY_METHOD_FUNC(rb_active_count), 0);
41
+ rb_define_method(rb_klass, "free?", RUBY_METHOD_FUNC(rb_free_q), 0);
42
+ }
43
+
44
+ /*
45
+ * ?
46
+ */
47
+ VALUE
48
+ rb_active_count(VALUE self)
49
+ {
50
+ return INT2FIX(CVSET(self)->active_count);
51
+ }
52
+
53
+ /*
54
+ * ?
55
+ */
56
+ VALUE
57
+ rb_free_q(VALUE self)
58
+ {
59
+ return CVSET(self)->free_elems->flags < 0 ? Qtrue : Qfalse;
60
+ }
61
+
62
+ __NAMESPACE_END_CVSET
63
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,39 @@
1
+ /************************************************************
2
+
3
+ cvset.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSET_H
11
+ #define RUBY_OPENCV_CVSET_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSET namespace cCvSet{
16
+ #define __NAMESPACE_END_CVSET }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSET
20
+
21
+ VALUE rb_class();
22
+ void define_ruby_class();
23
+
24
+ VALUE rb_active_count(VALUE self);
25
+ VALUE rb_free_q(VALUE self);
26
+
27
+ __NAMESPACE_END_CVSET
28
+
29
+ inline CvSet*
30
+ CVSET(VALUE object)
31
+ {
32
+ CvSet *ptr;
33
+ Data_Get_Struct(object, CvSet, ptr);
34
+ return ptr;
35
+ }
36
+
37
+ __NAMESPACE_END_OPENCV
38
+
39
+ #endif // RUBY_OPENCV_CVSET_H
@@ -0,0 +1,223 @@
1
+ /************************************************************
2
+
3
+ cvsize.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include"cvsize.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSize
13
+ *
14
+ * This class means one size on X axis Y axis.
15
+ * X and Y takes the value of the Fixnum.
16
+ *
17
+ * C structure is here, very simple.
18
+ * typdef struct CvSize{
19
+ * int width;
20
+ * int height;
21
+ * }
22
+ */
23
+ __NAMESPACE_BEGIN_OPENCV
24
+ __NAMESPACE_BEGIN_CVSIZE
25
+
26
+ VALUE rb_klass;
27
+
28
+ VALUE
29
+ rb_class()
30
+ {
31
+ return rb_klass;
32
+ }
33
+
34
+ void
35
+ define_ruby_class()
36
+ {
37
+ if(rb_klass)
38
+ return;
39
+ /*
40
+ * opencv = rb_define_module("OpenCV");
41
+ *
42
+ * note: this comment is used by rdoc.
43
+ */
44
+ VALUE opencv = rb_module_opencv();
45
+
46
+ rb_klass = rb_define_class_under(opencv, "CvSize", rb_cObject);
47
+ rb_define_alloc_func(rb_klass, rb_allocate);
48
+ rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
49
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
50
+ rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
51
+ rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
52
+ rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
53
+ rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
54
+
55
+ rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
56
+ rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
57
+ }
58
+
59
+ /*
60
+ * call-seq:
61
+ * compatible?(obj)
62
+ *
63
+ * Return compatibility to CvSize. Return true if object have method #width and #height.
64
+ *
65
+ * For example.
66
+ * class MySize
67
+ * def width
68
+ * 10
69
+ * end
70
+ * def height
71
+ * 20
72
+ * end
73
+ * end
74
+ * mp = MySize.new
75
+ * CvSize.compatible?(mp) #=> true
76
+ * CvSize.new(mp) #=> same as CvSize(10, 20)
77
+ */
78
+ VALUE
79
+ rb_compatible_q(VALUE klass, VALUE object)
80
+ {
81
+ return (rb_respond_to(object, rb_intern("width")) && rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
82
+ }
83
+
84
+ VALUE
85
+ rb_allocate(VALUE klass)
86
+ {
87
+ CvSize *ptr;
88
+ return Data_Make_Struct(klass, CvSize, 0, -1, ptr);
89
+ }
90
+
91
+ /*
92
+ * call-seq:
93
+ * new
94
+ * new(obj)
95
+ * new(width, height)
96
+ *
97
+ * Create new size of 2D, (width, height). It is dropped below the decimal point.
98
+ *
99
+ * new() is same as new(0, 0)
100
+ *
101
+ * new(obj) is same as new(obj.x.to_i, obj.y.to_i)
102
+ */
103
+ VALUE
104
+ rb_initialize(int argc, VALUE *argv, VALUE self)
105
+ {
106
+ VALUE obj, x, y;
107
+ switch (argc) {
108
+ case 0:
109
+ break;
110
+ case 1:
111
+ obj = argv[0];
112
+ if(rb_compatible_q(rb_klass, obj)) {
113
+ CVSIZE(self)->width = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("width"), 0), rb_intern("to_i"), 0));
114
+ CVSIZE(self)->height = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("height"), 0), rb_intern("to_i"), 0));
115
+ }else{
116
+ rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
117
+ }
118
+ break;
119
+ case 2:
120
+ x = argv[0], y = argv[1];
121
+ CVSIZE(self)->width = NUM2INT(x);
122
+ CVSIZE(self)->height = NUM2INT(y);
123
+ break;
124
+ default:
125
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
126
+ }
127
+ return Qnil;
128
+ }
129
+
130
+ /*
131
+ * Return size of x-axis.
132
+ */
133
+ VALUE
134
+ rb_width(VALUE self)
135
+ {
136
+ return INT2FIX(CVSIZE(self)->width);
137
+ }
138
+
139
+ /*
140
+ * call-seq:
141
+ * width = val
142
+ *
143
+ * Set x-axis size, return self.
144
+ * It is dropped below the decimal point.
145
+ */
146
+ VALUE
147
+ rb_set_width(VALUE self, VALUE x)
148
+ {
149
+ CVSIZE(self)->width = NUM2INT(x);
150
+ return self;
151
+ }
152
+
153
+ /*
154
+ * Return size of yaxis.
155
+ */
156
+ VALUE
157
+ rb_height(VALUE self)
158
+ {
159
+ return INT2FIX(CVSIZE(self)->height);
160
+ }
161
+
162
+ /*
163
+ * call-seq:
164
+ * height = val
165
+ *
166
+ * Set y-axis size, return self.
167
+ * It is dropped below the decimal point.
168
+ */
169
+ VALUE
170
+ rb_set_height(VALUE self, VALUE y)
171
+ {
172
+ CVSIZE(self)->height = NUM2INT(y);
173
+ return self;
174
+ }
175
+
176
+ /*
177
+ * call-seq:
178
+ * to_s -> "<OpenCV::CvSize:widthxheight>"
179
+ *
180
+ * Return width and height by String.
181
+ */
182
+ VALUE
183
+ rb_to_s(VALUE self)
184
+ {
185
+ const int i = 4;
186
+ VALUE str[i];
187
+ str[0] = rb_str_new2("<%s:%dx%d>");
188
+ str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
189
+ str[2] = rb_width(self);
190
+ str[3] = rb_height(self);
191
+ return rb_f_sprintf(i, str);
192
+ }
193
+
194
+ /*
195
+ * call-seq:
196
+ * to_ary -> [width, height]
197
+ *
198
+ * Return width and height by Array.
199
+ */
200
+ VALUE
201
+ rb_to_ary(VALUE self)
202
+ {
203
+ return rb_ary_new3(2, rb_width(self), rb_height(self));
204
+ }
205
+
206
+ VALUE
207
+ new_object()
208
+ {
209
+ VALUE object = rb_allocate(rb_klass);
210
+ *CVSIZE(object) = cvSize(0, 0);
211
+ return object;
212
+ }
213
+
214
+ VALUE
215
+ new_object(CvSize size)
216
+ {
217
+ VALUE object = rb_allocate(rb_klass);
218
+ *CVSIZE(object) = size;
219
+ return object;
220
+ }
221
+
222
+ __NAMESPACE_END_CVSIZE
223
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,63 @@
1
+ /************************************************************
2
+
3
+ cvsize.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSIZE_H
11
+ #define RUBY_OPENCV_CVSIZE_H
12
+
13
+ #include"opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSIZE namespace cCvSize{
16
+ #define __NAMESPACE_END_CVSIZE }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSIZE
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ VALUE rb_compatible_q(VALUE klass, VALUE object);
26
+
27
+ VALUE rb_allocate(VALUE klass);
28
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
29
+ VALUE rb_width(VALUE self);
30
+ VALUE rb_set_width(VALUE self, VALUE width);
31
+ VALUE rb_height(VALUE self);
32
+ VALUE rb_set_height(VALUE self, VALUE height);
33
+
34
+ VALUE rb_to_s(VALUE self);
35
+ VALUE rb_to_ary(VALUE self);
36
+
37
+ VALUE new_object();
38
+ VALUE new_object(CvSize size);
39
+
40
+ __NAMESPACE_END_CVSIZE
41
+
42
+ inline CvSize*
43
+ CVSIZE(VALUE object)
44
+ {
45
+ CvSize *ptr;
46
+ Data_Get_Struct(object, CvSize, ptr);
47
+ return ptr;
48
+ }
49
+
50
+ inline CvSize
51
+ VALUE_TO_CVSIZE(VALUE object)
52
+ {
53
+ if(cCvSize::rb_compatible_q(cCvSize::rb_class(), object)){
54
+ return cvSize(NUM2INT(rb_funcall(object, rb_intern("width"), 0)),
55
+ NUM2INT(rb_funcall(object, rb_intern("height"), 0)));
56
+ }else{
57
+ rb_raise(rb_eTypeError, "require %s or compatible object.", rb_class2name(cCvSize::rb_class()));
58
+ }
59
+ }
60
+
61
+ __NAMESPACE_END_OPENCV
62
+
63
+ #endif // RUBY_OPENCV_CVSIZE_H