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,180 @@
1
+ /************************************************************
2
+
3
+ cvsize2d32f.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvsize2d32f.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSize2D32f
13
+ *
14
+ * This class means one size on X axis Y axis.
15
+ * X and Y takes the value of the Float.
16
+ *
17
+ * C structure is here, very simple.
18
+ * typdef struct CvSize2D32f{
19
+ * float width;
20
+ * float height;
21
+ * }CvSize2D32f;
22
+ */
23
+ __NAMESPACE_BEGIN_OPENCV
24
+ __NAMESPACE_BEGIN_CVSIZE2D32F
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, "CvSize2D32f", 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_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
+
56
+ /*
57
+ * call-seq:
58
+ * compatible?(obj)
59
+ *
60
+ * Return compatibility to CvSize2D32f. Return true if object have method #width and #height.
61
+ *
62
+ * For example.
63
+ * class MySize
64
+ * def width
65
+ * 10.1
66
+ * end
67
+ * def height
68
+ * 20.2
69
+ * end
70
+ * end
71
+ * mp = MySize.new
72
+ * CvSize2D32f.compatible?(mp) #=> true
73
+ * CvSize2D32f.new(mp) #=> same as CvSize2D32f.new(10.1, 20.2)
74
+ */
75
+ VALUE
76
+ rb_compatible_q(VALUE klass, VALUE object)
77
+ {
78
+ return (rb_respond_to(object, rb_intern("width")) && rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
79
+ }
80
+
81
+ VALUE
82
+ rb_allocate(VALUE klass)
83
+ {
84
+ CvSize2D32f *ptr;
85
+ return Data_Make_Struct(klass, CvSize2D32f, 0, -1, ptr);
86
+ }
87
+
88
+ /*
89
+ * call-seq:
90
+ * new
91
+ * new(obj)
92
+ * new(width, height)
93
+ *
94
+ * Create new size of 2D, (width, height).
95
+ *
96
+ * new() is same as new(0.0, 0.0)
97
+ *
98
+ * new(obj) is same as new(obj.x.to_f, obj.y.to_f)
99
+ */
100
+ VALUE
101
+ rb_initialize(int argc, VALUE *argv, VALUE self)
102
+ {
103
+ VALUE obj, x, y;
104
+ switch(argc){
105
+ case 0:
106
+ break;
107
+ case 1:
108
+ obj = argv[0];
109
+ if(rb_compatible_q(rb_klass, obj)){
110
+ CVSIZE2D32F(self)->width = NUM2DBL(rb_funcall(rb_funcall(obj, rb_intern("width"), 0), rb_intern("to_f"), 0));
111
+ CVSIZE2D32F(self)->height = NUM2DBL(rb_funcall(rb_funcall(obj, rb_intern("height"), 0), rb_intern("to_f"), 0));
112
+ }else{
113
+ rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
114
+ }
115
+ break;
116
+ case 2:
117
+ x = argv[0], y = argv[1];
118
+ CVSIZE2D32F(self)->width = NUM2DBL(x);
119
+ CVSIZE2D32F(self)->height = NUM2DBL(y);
120
+ break;
121
+ default:
122
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
123
+ }
124
+ return self;
125
+ }
126
+
127
+ /*
128
+ * Return size of x-axis.
129
+ */
130
+ VALUE
131
+ rb_width(VALUE self)
132
+ {
133
+ return rb_float_new(CVSIZE2D32F(self)->width);
134
+ }
135
+
136
+ /*
137
+ * call-seq:
138
+ * width = val
139
+ *
140
+ * Set x-axis size, return self.
141
+ */
142
+ VALUE
143
+ rb_set_width(VALUE self, VALUE x)
144
+ {
145
+ CVSIZE2D32F(self)->width = NUM2DBL(x);
146
+ return self;
147
+ }
148
+
149
+ /*
150
+ * Return size of yaxis.
151
+ */
152
+ VALUE
153
+ rb_height(VALUE self)
154
+ {
155
+ return rb_float_new(CVSIZE2D32F(self)->height);
156
+ }
157
+
158
+ /*
159
+ * call-seq:
160
+ * height = val
161
+ *
162
+ * Set y-axis size, return self.
163
+ */
164
+ VALUE
165
+ rb_set_height(VALUE self, VALUE y)
166
+ {
167
+ CVSIZE2D32F(self)->height = NUM2DBL(y);
168
+ return self;
169
+ }
170
+
171
+ VALUE
172
+ new_object(CvSize2D32f size)
173
+ {
174
+ VALUE object = rb_allocate(rb_klass);
175
+ *CVSIZE2D32F(object) = size;
176
+ return object;
177
+ }
178
+
179
+ __NAMESPACE_END_CVSIZE2D32F
180
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,59 @@
1
+ /************************************************************
2
+
3
+ cvsize2d32f.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSIZE2D32F_H
11
+ #define RUBY_OPENCV_CVSIZE2D32F_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSIZE2D32F namespace cCvSize2D32f{
16
+ #define __NAMESPACE_END_CVSIZE2D32F }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSIZE2D32F
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 new_object(CvSize2D32f size);
35
+
36
+ __NAMESPACE_END_CVSIZE2D32F
37
+
38
+ inline CvSize2D32f*
39
+ CVSIZE2D32F(VALUE object)
40
+ {
41
+ CvSize2D32f *ptr;
42
+ Data_Get_Struct(object, CvSize2D32f, ptr);
43
+ return ptr;
44
+ }
45
+
46
+ inline CvSize2D32f
47
+ VALUE_TO_CVSIZE2D32F(VALUE object)
48
+ {
49
+ if(cCvSize2D32f::rb_compatible_q(cCvSize2D32f::rb_class(), object)){
50
+ return cvSize2D32f(NUM2DBL(rb_funcall(object, rb_intern("width"), 0)),
51
+ NUM2DBL(rb_funcall(object, rb_intern("height"), 0)));
52
+ }else{
53
+ rb_raise(rb_eTypeError, "require %s or compatible object.", rb_class2name(cCvSize2D32f::rb_class()));
54
+ }
55
+ }
56
+
57
+ __NAMESPACE_END_OPENCV
58
+
59
+ #endif // RUBY_OPENCV_CVSIZE2D32F_H
@@ -0,0 +1,82 @@
1
+ /************************************************************
2
+
3
+ cvslice.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvslice.h"
11
+ /*
12
+ * Document-class: OpenCV::CvClice
13
+ *
14
+ * C structure is here, very simple.
15
+ * typdef struct CvSlice{
16
+ * int start_index;
17
+ * int end_index;
18
+ * }CvSlice;
19
+ */
20
+ __NAMESPACE_BEGIN_OPENCV
21
+ __NAMESPACE_BEGIN_CVSLICE
22
+
23
+ VALUE rb_klass;
24
+
25
+ VALUE
26
+ rb_class()
27
+ {
28
+ return rb_klass;
29
+ }
30
+
31
+ void
32
+ define_ruby_class()
33
+ {
34
+ if (rb_klass)
35
+ return;
36
+ /*
37
+ * opencv = rb_define_module("OpenCV");
38
+ *
39
+ * note: this comment is used by rdoc.
40
+ */
41
+ VALUE opencv = rb_module_opencv();
42
+ rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
43
+ rb_define_alloc_func(rb_klass, rb_allocate);
44
+ rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
45
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
46
+ }
47
+
48
+ /*
49
+ * call-seq:
50
+ * compatible?(<i>obj</i>)
51
+ *
52
+ * same Object#kind_of(Range)
53
+ */
54
+ VALUE
55
+ rb_compatible_q(VALUE klass, VALUE object)
56
+ {
57
+ return rb_obj_is_kind_of(object, rb_cRange);
58
+ }
59
+
60
+ VALUE
61
+ rb_allocate(VALUE klass)
62
+ {
63
+ CvSlice *ptr;
64
+ return Data_Make_Struct(klass, CvSlice, 0, -1, ptr);
65
+ }
66
+
67
+ /*
68
+ * call-seq:
69
+ * new(<i>start, end</i>)
70
+ *
71
+ * Create new slice object.
72
+ */
73
+ VALUE
74
+ rb_initialize(VALUE self, VALUE start, VALUE end)
75
+ {
76
+ CVSLICE(self)->start_index = NUM2INT(start);
77
+ CVSLICE(self)->end_index = NUM2INT(end);
78
+ return self;
79
+ }
80
+
81
+ __NAMESPACE_END_CVSLICE
82
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,53 @@
1
+ /************************************************************
2
+
3
+ cvslice.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSLICE_H
11
+ #define RUBY_OPENCV_CVSLICE_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSLICE namespace cCvSlice{
16
+ #define __NAMESPACE_END_CVSLICE }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSLICE
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(VALUE self, VALUE start, VALUE end);
29
+
30
+ __NAMESPACE_END_CVSLICE
31
+
32
+ inline CvSlice*
33
+ CVSLICE(VALUE object)
34
+ {
35
+ CvSlice *ptr;
36
+ Data_Get_Struct(object, CvSlice, ptr);
37
+ return ptr;
38
+ }
39
+
40
+ inline CvSlice
41
+ VALUE_TO_CVSLICE(VALUE object)
42
+ {
43
+ if(cCvSlice::rb_compatible_q(cCvSlice::rb_class(), object)){
44
+ return cvSlice(NUM2INT(rb_funcall(object, rb_intern("begin"), 0)),
45
+ rb_funcall(object, rb_intern("exclude_end?"), 0) ? NUM2INT(rb_funcall(object, rb_intern("end"), 0)) : NUM2INT(rb_funcall(object, rb_intern("end"), 0)) - 1);
46
+ }else{
47
+ rb_raise(rb_eTypeError, "require %s or compatible object.", rb_class2name(cCvSlice::rb_class()));
48
+ }
49
+ }
50
+
51
+ __NAMESPACE_END_OPENCV
52
+
53
+ #endif // RUBY_OPENCV_CVSLICE_H
@@ -0,0 +1,44 @@
1
+ /***********************************************************
2
+
3
+ cvsparse.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvsparsemat.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSparseMat
13
+ *
14
+ */
15
+ __NAMESPACE_BEGIN_OPENCV
16
+ __NAMESPACE_BEGIN_CVSPARSEMAT
17
+
18
+ VALUE rb_klass;
19
+
20
+ VALUE
21
+ rb_class()
22
+ {
23
+ return rb_klass;
24
+ }
25
+
26
+ void
27
+ define_ruby_class()
28
+ {
29
+ if (rb_klass)
30
+ return;
31
+ /*
32
+ * opencv = rb_define_module("OpenCV");
33
+ * cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
34
+ *
35
+ * note: this comment is used by rdoc.
36
+ */
37
+ VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
38
+
39
+ rb_klass = rb_define_class_under(opencv, "CvSparseMat", cvmat);
40
+ }
41
+
42
+ __NAMESPACE_END_CVSPARSEMAT
43
+ __NAMESPACE_END_OPENCV
44
+
@@ -0,0 +1,28 @@
1
+ /************************************************************
2
+
3
+ cvsparsemat.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSPARSEMAT_H
11
+ #define RUBY_OPENCV_CVSPARSEMAT_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSPARSEMAT namespace cCvSparseMat{
16
+ #define __NAMESPACE_END_CVSPARSEMAT }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSPARSEMAT
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ __NAMESPACE_END_CVSPARSEMAT
26
+ __NAMESPACE_END_OPENCV
27
+
28
+ #endif // RUBY_OPENCV_CVSPARSEMAT_H