afeld-opencv 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/.gitignore +23 -0
  2. data/Gemfile +6 -0
  3. data/History.txt +5 -0
  4. data/License.txt +30 -0
  5. data/Manifest.txt +217 -0
  6. data/README.rdoc +161 -0
  7. data/Rakefile +52 -0
  8. data/examples/alpha_blend.rb +21 -0
  9. data/examples/box.png +0 -0
  10. data/examples/box_in_scene.png +0 -0
  11. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  12. data/examples/contours/bitmap-contours.png +0 -0
  13. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  14. data/examples/contours/contour_retrieval_modes.rb +139 -0
  15. data/examples/contours/rotated-boxes.jpg +0 -0
  16. data/examples/convexhull.rb +47 -0
  17. data/examples/face_detect.rb +20 -0
  18. data/examples/find_obj.rb +169 -0
  19. data/examples/houghcircle.rb +22 -0
  20. data/examples/inpaint.png +0 -0
  21. data/examples/inpaint.rb +57 -0
  22. data/examples/lenna-rotated.jpg +0 -0
  23. data/examples/lenna.jpg +0 -0
  24. data/examples/match_kdtree.rb +88 -0
  25. data/examples/paint.rb +70 -0
  26. data/examples/snake.rb +43 -0
  27. data/examples/stuff.jpg +0 -0
  28. data/examples/tiffany.jpg +0 -0
  29. data/ext/opencv/curve.cpp +112 -0
  30. data/ext/opencv/curve.h +34 -0
  31. data/ext/opencv/cvavgcomp.cpp +67 -0
  32. data/ext/opencv/cvavgcomp.h +39 -0
  33. data/ext/opencv/cvbox2d.cpp +197 -0
  34. data/ext/opencv/cvbox2d.h +61 -0
  35. data/ext/opencv/cvcapture.cpp +499 -0
  36. data/ext/opencv/cvcapture.h +72 -0
  37. data/ext/opencv/cvchain.cpp +230 -0
  38. data/ext/opencv/cvchain.h +46 -0
  39. data/ext/opencv/cvcircle32f.cpp +116 -0
  40. data/ext/opencv/cvcircle32f.h +52 -0
  41. data/ext/opencv/cvcondensation.cpp +282 -0
  42. data/ext/opencv/cvcondensation.h +49 -0
  43. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  44. data/ext/opencv/cvconnectedcomp.h +49 -0
  45. data/ext/opencv/cvcontour.cpp +297 -0
  46. data/ext/opencv/cvcontour.h +48 -0
  47. data/ext/opencv/cvcontourtree.cpp +91 -0
  48. data/ext/opencv/cvcontourtree.h +41 -0
  49. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  50. data/ext/opencv/cvconvexitydefect.h +42 -0
  51. data/ext/opencv/cverror.cpp +159 -0
  52. data/ext/opencv/cverror.h +28 -0
  53. data/ext/opencv/cvfeaturetree.cpp +125 -0
  54. data/ext/opencv/cvfeaturetree.h +55 -0
  55. data/ext/opencv/cvfont.cpp +208 -0
  56. data/ext/opencv/cvfont.h +64 -0
  57. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  58. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  59. data/ext/opencv/cvhistogram.cpp +546 -0
  60. data/ext/opencv/cvhistogram.h +73 -0
  61. data/ext/opencv/cvhumoments.cpp +139 -0
  62. data/ext/opencv/cvhumoments.h +51 -0
  63. data/ext/opencv/cvline.cpp +154 -0
  64. data/ext/opencv/cvline.h +54 -0
  65. data/ext/opencv/cvmat.cpp +5627 -0
  66. data/ext/opencv/cvmat.h +280 -0
  67. data/ext/opencv/cvmatnd.cpp +44 -0
  68. data/ext/opencv/cvmatnd.h +28 -0
  69. data/ext/opencv/cvmemstorage.cpp +68 -0
  70. data/ext/opencv/cvmemstorage.h +53 -0
  71. data/ext/opencv/cvmoments.cpp +287 -0
  72. data/ext/opencv/cvmoments.h +75 -0
  73. data/ext/opencv/cvpoint.cpp +228 -0
  74. data/ext/opencv/cvpoint.h +64 -0
  75. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  76. data/ext/opencv/cvpoint2d32f.h +63 -0
  77. data/ext/opencv/cvpoint3d32f.cpp +246 -0
  78. data/ext/opencv/cvpoint3d32f.h +66 -0
  79. data/ext/opencv/cvrect.cpp +333 -0
  80. data/ext/opencv/cvrect.h +79 -0
  81. data/ext/opencv/cvscalar.cpp +236 -0
  82. data/ext/opencv/cvscalar.h +71 -0
  83. data/ext/opencv/cvseq.cpp +599 -0
  84. data/ext/opencv/cvseq.h +72 -0
  85. data/ext/opencv/cvsize.cpp +221 -0
  86. data/ext/opencv/cvsize.h +65 -0
  87. data/ext/opencv/cvsize2d32f.cpp +209 -0
  88. data/ext/opencv/cvsize2d32f.h +64 -0
  89. data/ext/opencv/cvslice.cpp +120 -0
  90. data/ext/opencv/cvslice.h +61 -0
  91. data/ext/opencv/cvsparsemat.cpp +44 -0
  92. data/ext/opencv/cvsparsemat.h +28 -0
  93. data/ext/opencv/cvsurfparams.cpp +199 -0
  94. data/ext/opencv/cvsurfparams.h +58 -0
  95. data/ext/opencv/cvsurfpoint.cpp +223 -0
  96. data/ext/opencv/cvsurfpoint.h +52 -0
  97. data/ext/opencv/cvtermcriteria.cpp +192 -0
  98. data/ext/opencv/cvtermcriteria.h +71 -0
  99. data/ext/opencv/cvtwopoints.cpp +116 -0
  100. data/ext/opencv/cvtwopoints.h +51 -0
  101. data/ext/opencv/cvutils.cpp +194 -0
  102. data/ext/opencv/cvutils.h +29 -0
  103. data/ext/opencv/cvvideowriter.cpp +137 -0
  104. data/ext/opencv/cvvideowriter.h +43 -0
  105. data/ext/opencv/gui.cpp +68 -0
  106. data/ext/opencv/gui.h +30 -0
  107. data/ext/opencv/iplconvkernel.cpp +192 -0
  108. data/ext/opencv/iplconvkernel.h +71 -0
  109. data/ext/opencv/iplimage.cpp +576 -0
  110. data/ext/opencv/iplimage.h +70 -0
  111. data/ext/opencv/lib/opencv.rb +3 -0
  112. data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
  113. data/ext/opencv/lib/opencv/version.rb +3 -0
  114. data/ext/opencv/mouseevent.cpp +181 -0
  115. data/ext/opencv/mouseevent.h +56 -0
  116. data/ext/opencv/opencv.cpp +710 -0
  117. data/ext/opencv/opencv.h +400 -0
  118. data/ext/opencv/pointset.cpp +284 -0
  119. data/ext/opencv/pointset.h +69 -0
  120. data/ext/opencv/trackbar.cpp +121 -0
  121. data/ext/opencv/trackbar.h +69 -0
  122. data/ext/opencv/window.cpp +357 -0
  123. data/ext/opencv/window.h +66 -0
  124. data/extconf.rb +65 -0
  125. data/images/CvMat_sobel.png +0 -0
  126. data/images/CvMat_sub_rect.png +0 -0
  127. data/images/CvSeq_relationmap.png +0 -0
  128. data/images/face_detect_from_lena.jpg +0 -0
  129. data/test/helper.rb +146 -0
  130. data/test/runner.rb +30 -0
  131. data/test/samples/airplane.jpg +0 -0
  132. data/test/samples/baboon.jpg +0 -0
  133. data/test/samples/baboon200.jpg +0 -0
  134. data/test/samples/baboon200_rotated.jpg +0 -0
  135. data/test/samples/blank0.jpg +0 -0
  136. data/test/samples/blank1.jpg +0 -0
  137. data/test/samples/blank2.jpg +0 -0
  138. data/test/samples/blank3.jpg +0 -0
  139. data/test/samples/blank4.jpg +0 -0
  140. data/test/samples/blank5.jpg +0 -0
  141. data/test/samples/blank6.jpg +0 -0
  142. data/test/samples/blank7.jpg +0 -0
  143. data/test/samples/blank8.jpg +0 -0
  144. data/test/samples/blank9.jpg +0 -0
  145. data/test/samples/cat.jpg +0 -0
  146. data/test/samples/contours.jpg +0 -0
  147. data/test/samples/fruits.jpg +0 -0
  148. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  149. data/test/samples/inpaint-mask.bmp +0 -0
  150. data/test/samples/lena-256x256.jpg +0 -0
  151. data/test/samples/lena-32x32.jpg +0 -0
  152. data/test/samples/lena-eyes.jpg +0 -0
  153. data/test/samples/lena-inpaint.jpg +0 -0
  154. data/test/samples/lena.jpg +0 -0
  155. data/test/samples/lines.jpg +0 -0
  156. data/test/samples/messy0.jpg +0 -0
  157. data/test/samples/messy1.jpg +0 -0
  158. data/test/samples/movie_sample.avi +0 -0
  159. data/test/samples/one_way_train_0000.jpg +0 -0
  160. data/test/samples/one_way_train_0001.jpg +0 -0
  161. data/test/samples/partially_blank0.jpg +0 -0
  162. data/test/samples/partially_blank1.jpg +0 -0
  163. data/test/samples/smooth0.jpg +0 -0
  164. data/test/samples/smooth1.jpg +0 -0
  165. data/test/samples/smooth2.jpg +0 -0
  166. data/test/samples/smooth3.jpg +0 -0
  167. data/test/samples/smooth4.jpg +0 -0
  168. data/test/samples/smooth5.jpg +0 -0
  169. data/test/samples/smooth6.jpg +0 -0
  170. data/test/samples/str-cv-rotated.jpg +0 -0
  171. data/test/samples/str-cv.jpg +0 -0
  172. data/test/samples/str-ov.jpg +0 -0
  173. data/test/samples/stuff.jpg +0 -0
  174. data/test/test_curve.rb +43 -0
  175. data/test/test_cvavgcomp.rb +24 -0
  176. data/test/test_cvbox2d.rb +76 -0
  177. data/test/test_cvcapture.rb +183 -0
  178. data/test/test_cvchain.rb +108 -0
  179. data/test/test_cvcircle32f.rb +41 -0
  180. data/test/test_cvconnectedcomp.rb +61 -0
  181. data/test/test_cvcontour.rb +150 -0
  182. data/test/test_cvcontourtree.rb +43 -0
  183. data/test/test_cverror.rb +50 -0
  184. data/test/test_cvfeaturetree.rb +65 -0
  185. data/test/test_cvfont.rb +58 -0
  186. data/test/test_cvhaarclassifiercascade.rb +63 -0
  187. data/test/test_cvhistogram.rb +271 -0
  188. data/test/test_cvhumoments.rb +83 -0
  189. data/test/test_cvline.rb +50 -0
  190. data/test/test_cvmat.rb +2752 -0
  191. data/test/test_cvmat_drawing.rb +318 -0
  192. data/test/test_cvmat_dxt.rb +147 -0
  193. data/test/test_cvmat_imageprocessing.rb +1943 -0
  194. data/test/test_cvmoments.rb +180 -0
  195. data/test/test_cvpoint.rb +75 -0
  196. data/test/test_cvpoint2d32f.rb +75 -0
  197. data/test/test_cvpoint3d32f.rb +93 -0
  198. data/test/test_cvrect.rb +144 -0
  199. data/test/test_cvscalar.rb +113 -0
  200. data/test/test_cvseq.rb +295 -0
  201. data/test/test_cvsize.rb +75 -0
  202. data/test/test_cvsize2d32f.rb +75 -0
  203. data/test/test_cvslice.rb +31 -0
  204. data/test/test_cvsurfparams.rb +57 -0
  205. data/test/test_cvsurfpoint.rb +66 -0
  206. data/test/test_cvtermcriteria.rb +56 -0
  207. data/test/test_cvtwopoints.rb +40 -0
  208. data/test/test_cvvideowriter.rb +58 -0
  209. data/test/test_iplconvkernel.rb +54 -0
  210. data/test/test_iplimage.rb +156 -0
  211. data/test/test_mouseevent.rb +17 -0
  212. data/test/test_opencv.rb +340 -0
  213. data/test/test_pointset.rb +130 -0
  214. data/test/test_preliminary.rb +130 -0
  215. data/test/test_trackbar.rb +47 -0
  216. data/test/test_window.rb +115 -0
  217. metadata +399 -0
@@ -0,0 +1,58 @@
1
+ /************************************************************
2
+
3
+ cvsurfparams.h -
4
+
5
+ $Author: ser1zw $
6
+
7
+ Copyright (C) 2011 ser1zw
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSURFPARAMS_H
11
+ #define RUBY_OPENCV_CVSURFPARAMS_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSURFPARAMS namespace cCvSURFParams {
16
+ #define __NAMESPACE_END_CVSURFPARAMS }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSURFPARAMS
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ VALUE rb_allocate(VALUE klass);
26
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
27
+ VALUE rb_get_hessian_threshold(VALUE self);
28
+ VALUE rb_set_hessian_threshold(VALUE self, VALUE value);
29
+ VALUE rb_get_extended(VALUE self);
30
+ VALUE rb_set_extended(VALUE self, VALUE value);
31
+ VALUE rb_get_n_octaves(VALUE self);
32
+ VALUE rb_set_n_octaves(VALUE self, VALUE value);
33
+ VALUE rb_get_n_octave_layers(VALUE self);
34
+ VALUE rb_set_n_octave_layers(VALUE self, VALUE value);
35
+
36
+ VALUE new_object(CvSURFPoint *cvsurfparams);
37
+
38
+ __NAMESPACE_END_CVSURFPARAMS
39
+
40
+ inline CvSURFParams*
41
+ CVSURFPARAMS(VALUE object)
42
+ {
43
+ CvSURFParams* ptr;
44
+ Data_Get_Struct(object, CvSURFParams, ptr);
45
+ return ptr;
46
+ }
47
+
48
+ inline CvSURFParams*
49
+ CVSURFPARAMS_WITH_CHECK(VALUE object)
50
+ {
51
+ if (!rb_obj_is_kind_of(object, cCvSURFParams::rb_class()))
52
+ raise_typeerror(object, cCvSURFParams::rb_class());
53
+ return CVSURFPARAMS(object);
54
+ }
55
+
56
+ __NAMESPACE_END_OPENCV
57
+
58
+ #endif // RUBY_OPENCV_CVSURFPARAMS_H
@@ -0,0 +1,223 @@
1
+ /************************************************************
2
+
3
+ cvsurfpoint.cpp -
4
+
5
+ $Author: ser1zw $
6
+
7
+ Copyright (C) 2011 ser1zw
8
+
9
+ ************************************************************/
10
+ #include "cvsurfpoint.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSURFPoint
13
+ *
14
+ * C structure is here.
15
+ * typedef struct CvSURFPoint {
16
+ * CvPoint2D32f pt; // position of the feature within the image
17
+ * int laplacian; // -1, 0 or +1. sign of the laplacian at the point.
18
+ * // can be used to speedup feature comparison
19
+ * // (normally features with laplacians of different
20
+ * // signs can not match)
21
+ * int size; // size of the feature
22
+ * float dir; // orientation of the feature: 0..360 degrees
23
+ * float hessian; // value of the hessian (can be used to
24
+ * // approximately estimate the feature strengths)
25
+ * } CvSURFPoint;
26
+ */
27
+ __NAMESPACE_BEGIN_OPENCV
28
+ __NAMESPACE_BEGIN_CVSURFPOINT
29
+
30
+ VALUE rb_klass;
31
+
32
+ VALUE
33
+ rb_class()
34
+ {
35
+ return rb_klass;
36
+ }
37
+
38
+ void
39
+ define_ruby_class()
40
+ {
41
+ if (rb_klass)
42
+ return;
43
+ /*
44
+ * opencv = rb_define_module("OpenCV");
45
+ *
46
+ * note: this comment is used by rdoc.
47
+ */
48
+ VALUE opencv = rb_module_opencv();
49
+ rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
50
+ rb_define_alloc_func(rb_klass, rb_allocate);
51
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
52
+ rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
53
+ rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
54
+ rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
55
+ rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
56
+ rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
57
+ rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
58
+ rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
59
+ rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
60
+ rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
61
+ rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
62
+ }
63
+
64
+ VALUE
65
+ rb_allocate(VALUE klass)
66
+ {
67
+ CvSURFPoint *ptr;
68
+ return Data_Make_Struct(klass, CvSURFPoint, 0, -1, ptr);
69
+ }
70
+
71
+ /*
72
+ * call-seq:
73
+ * CvSURFPoint.new(<i>pt,laplacian,size,dir,hessian</i>) -> cvsurfpoint
74
+ *
75
+ * Create a CvSURFPoint
76
+ */
77
+ VALUE
78
+ rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian)
79
+ {
80
+ CvSURFPoint *self_ptr = CVSURFPOINT(self);
81
+ self_ptr->pt = VALUE_TO_CVPOINT2D32F(pt);
82
+ self_ptr->laplacian = NUM2INT(laplacian);
83
+ self_ptr->size = NUM2INT(size);
84
+ self_ptr->dir = (float)NUM2DBL(dir);
85
+ self_ptr->hessian = (float)NUM2DBL(hessian);
86
+
87
+ return self;
88
+ }
89
+
90
+ /*
91
+ * call-seq:
92
+ * pt -> cvpoint2d32f
93
+ * Return position of the feature as CvPoint2D32f.
94
+ */
95
+ VALUE
96
+ rb_get_pt(VALUE self)
97
+ {
98
+ return REFER_OBJECT(cCvPoint2D32f::rb_class(), &CVSURFPOINT(self)->pt, self);
99
+ }
100
+
101
+ /*
102
+ * call-seq:
103
+ * pt = <i>value</i>
104
+ *
105
+ * Set position of the feature to <i>value</i>
106
+ */
107
+ VALUE
108
+ rb_set_pt(VALUE self, VALUE value)
109
+ {
110
+ CVSURFPOINT(self)->pt = VALUE_TO_CVPOINT2D32F(value);
111
+ return self;
112
+ }
113
+
114
+ /*
115
+ * call-seq:
116
+ * laplacian -> number
117
+ * Return sign of the laplacian at the point (-1, 0 or +1)
118
+ */
119
+ VALUE
120
+ rb_get_laplacian(VALUE self)
121
+ {
122
+ return INT2NUM(CVSURFPOINT(self)->laplacian);
123
+ }
124
+
125
+ /*
126
+ * call-seq:
127
+ * laplacian = <i>value</i> (-1, 0 or +1)
128
+ * Set sign of the laplacian at the point
129
+ */
130
+ VALUE
131
+ rb_set_laplacian(VALUE self, VALUE value)
132
+ {
133
+ int val = NUM2INT(value);
134
+ CVSURFPOINT(self)->laplacian = (val > 0) ? 1 : (val < 0) ? -1 : 0;
135
+ return self;
136
+ }
137
+
138
+ /*
139
+ * call-seq:
140
+ * size -> number
141
+ * Return size of feature
142
+ */
143
+ VALUE
144
+ rb_get_size(VALUE self)
145
+ {
146
+ return INT2NUM(CVSURFPOINT(self)->size);
147
+ }
148
+
149
+ /*
150
+ * call-seq:
151
+ * size = <i>value</i>
152
+ * Return size of feature
153
+ */
154
+ VALUE
155
+ rb_set_size(VALUE self, VALUE value)
156
+ {
157
+ CVSURFPOINT(self)->size = NUM2INT(value);
158
+ return self;
159
+ }
160
+
161
+ /*
162
+ * call-seq:
163
+ * dir -> number
164
+ * Return orientation of the feature: 0..360 degrees
165
+ */
166
+ VALUE
167
+ rb_get_dir(VALUE self)
168
+ {
169
+ return DBL2NUM((double)(CVSURFPOINT(self)->dir));
170
+ }
171
+
172
+ /*
173
+ * call-seq:
174
+ * dir = <i>value</i>
175
+ * Set orientation of the feature: 0..360 degrees
176
+ */
177
+ VALUE
178
+ rb_set_dir(VALUE self, VALUE value)
179
+ {
180
+ CVSURFPOINT(self)->dir = (float)NUM2DBL(value);
181
+ return self;
182
+ }
183
+
184
+ /*
185
+ * call-seq:
186
+ * hessian -> number
187
+ * Return value of the hessian
188
+ */
189
+ VALUE
190
+ rb_get_hessian(VALUE self)
191
+ {
192
+ return DBL2NUM((double)(CVSURFPOINT(self)->hessian));
193
+ }
194
+
195
+ /*
196
+ * call-seq:
197
+ * hessian = <i>value</i>
198
+ * Set value of the hessian
199
+ */
200
+ VALUE
201
+ rb_set_hessian(VALUE self, VALUE value)
202
+ {
203
+ CVSURFPOINT(self)->hessian = (float)NUM2DBL(value);
204
+ return self;
205
+ }
206
+
207
+ VALUE
208
+ new_object()
209
+ {
210
+ return rb_allocate(rb_klass);
211
+ }
212
+
213
+ VALUE
214
+ new_object(CvSURFPoint* cvsurfpoint)
215
+ {
216
+ VALUE object = rb_allocate(rb_klass);
217
+ CvSURFPoint *ptr = CVSURFPOINT(object);
218
+ ptr = cvsurfpoint;
219
+ return object;
220
+ }
221
+
222
+ __NAMESPACE_END_CVSURFPOINT
223
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,52 @@
1
+ /************************************************************
2
+
3
+ cvsurfpoint.h -
4
+
5
+ $Author: ser1zw $
6
+
7
+ Copyright (C) 2011 ser1zw
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSURFPOINT_H
11
+ #define RUBY_OPENCV_CVSURFPOINT_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVSURFPOINT namespace cCvSURFPoint {
16
+ #define __NAMESPACE_END_CVSURFPOINT }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVSURFPOINT
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ VALUE rb_allocate(VALUE klass);
26
+ VALUE rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian);
27
+ VALUE rb_get_pt(VALUE self);
28
+ VALUE rb_set_pt(VALUE self, VALUE value);
29
+ VALUE rb_get_laplacian(VALUE self);
30
+ VALUE rb_set_laplacian(VALUE self, VALUE value);
31
+ VALUE rb_get_size(VALUE self);
32
+ VALUE rb_set_size(VALUE self, VALUE value);
33
+ VALUE rb_get_dir(VALUE self);
34
+ VALUE rb_set_dir(VALUE self, VALUE value);
35
+ VALUE rb_get_hessian(VALUE self);
36
+ VALUE rb_set_hessian(VALUE self, VALUE value);
37
+
38
+ VALUE new_object(CvSURFPoint *cvsurfpoint);
39
+
40
+ __NAMESPACE_END_CVSURFPOINT
41
+
42
+ inline CvSURFPoint*
43
+ CVSURFPOINT(VALUE object)
44
+ {
45
+ CvSURFPoint* ptr;
46
+ Data_Get_Struct(object, CvSURFPoint, ptr);
47
+ return ptr;
48
+ }
49
+
50
+ __NAMESPACE_END_OPENCV
51
+
52
+ #endif // RUBY_OPENCV_CVSURFPOINT_H
@@ -0,0 +1,192 @@
1
+ /************************************************************
2
+
3
+ cvtermcriteria.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvtermcriteria.h"
11
+ /*
12
+ * Document-class: OpenCV::CvTermCriteria
13
+ *
14
+ * CvTermCriteria has parameter "max" and "eps".
15
+ * "max" is the maximum repetition frequency.
16
+ * "eps" is a minimum difference value during current and previous state
17
+ * (It is different to which state "eps" refer depending on the method).
18
+ *
19
+ * Because the name of CvTermCriteria seems to be very long, it has alias named CvTerm.
20
+ */
21
+ __NAMESPACE_BEGIN_OPENCV
22
+ __NAMESPACE_BEGIN_CVTERMCRITERIA
23
+
24
+ VALUE rb_klass;
25
+
26
+ VALUE
27
+ rb_class()
28
+ {
29
+ return rb_klass;
30
+ }
31
+
32
+ void
33
+ define_ruby_class()
34
+ {
35
+ if (rb_klass)
36
+ return;
37
+ /*
38
+ * opencv = rb_define_module("OpenCV");
39
+ *
40
+ * note: this comment is used by rdoc.
41
+ */
42
+ VALUE opencv = rb_module_opencv();
43
+
44
+ rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
45
+ /* CvTermCriteria: class */
46
+ rb_define_const(opencv, "CvTerm", rb_klass);
47
+ rb_define_alloc_func(rb_klass, rb_allocate);
48
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
49
+ rb_define_method(rb_klass, "type", RUBY_METHOD_FUNC(rb_type), 0);
50
+ rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
51
+ rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
52
+ rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
53
+ rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
54
+ rb_define_alias(rb_klass, "epsilon", "eps");
55
+ rb_define_alias(rb_klass, "epsilon=", "eps=");
56
+ }
57
+
58
+ VALUE
59
+ rb_allocate(VALUE klass)
60
+ {
61
+ CvTermCriteria *ptr;
62
+ return Data_Make_Struct(klass, CvTermCriteria, 0, -1, ptr);
63
+ }
64
+
65
+ /*
66
+ * call-seq:
67
+ * CvTermCriteria.new([max = 0][,eps = 0.0]) -> obj
68
+ * CvTermCriteria.new(int) = CvTermCriteria.new(int, 0.0)
69
+ * CvTermCriteria.new(float) = CvTermCriteria.new(0, float)
70
+ *
71
+ * Create new term criteria.
72
+ */
73
+ VALUE
74
+ rb_initialize(int argc, VALUE *argv, VALUE self)
75
+ {
76
+ VALUE max, eps;
77
+ rb_scan_args(argc, argv, "02", &max, &eps);
78
+ int type = 0;
79
+ if (!NIL_P(max))
80
+ type |= CV_TERMCRIT_ITER;
81
+ if (!NIL_P(eps))
82
+ type |= CV_TERMCRIT_EPS;
83
+ try {
84
+ *CVTERMCRITERIA(self) = cvTermCriteria(type, IF_INT(max, 0), IF_DBL(eps, 0.0));
85
+ }
86
+ catch (cv::Exception& e) {
87
+ raise_cverror(e);
88
+ }
89
+ return self;
90
+ }
91
+
92
+ /*
93
+ * call-seq:
94
+ * type -> int
95
+ *
96
+ * Return a combination of CV_TERMCRIT_ITER and CV_TERMCRIT_EPS
97
+ */
98
+ VALUE
99
+ rb_type(VALUE self)
100
+ {
101
+ return INT2NUM(CVTERMCRITERIA(self)->type);
102
+ }
103
+
104
+ /*
105
+ * call-seq:
106
+ * max -> int or nil
107
+ *
108
+ * Return the maximum repetition frequency.
109
+ */
110
+ VALUE
111
+ rb_max(VALUE self)
112
+ {
113
+ CvTermCriteria *ptr = CVTERMCRITERIA(self);
114
+ if (ptr->type & CV_TERMCRIT_ITER)
115
+ return INT2NUM(ptr->max_iter);
116
+ else
117
+ return Qnil;
118
+ }
119
+
120
+ /*
121
+ * call-seq:
122
+ * max = <i>val</i> -> self
123
+ *
124
+ * Set the maximum repetition frequency.
125
+ * If <i>val</i> is 0 (or negative value), repetition frequency is disregarded.
126
+ */
127
+ VALUE
128
+ rb_set_max(VALUE self, VALUE max_value)
129
+ {
130
+ CvTermCriteria *ptr = CVTERMCRITERIA(self);
131
+ int max = NUM2INT(max_value);
132
+ if (max > 0) {
133
+ ptr->type |= CV_TERMCRIT_ITER;
134
+ ptr->max_iter = max;
135
+ }
136
+ else {
137
+ ptr->type ^= CV_TERMCRIT_ITER;
138
+ ptr->max_iter = 0;
139
+ }
140
+ return self;
141
+ }
142
+
143
+ /*
144
+ * call-seq:
145
+ * eps -> float or nil
146
+ *
147
+ * Return the minimum difference value during current and previous state.
148
+ */
149
+ VALUE
150
+ rb_eps(VALUE self)
151
+ {
152
+ CvTermCriteria *ptr = CVTERMCRITERIA(self);
153
+ if (ptr->type & CV_TERMCRIT_EPS)
154
+ return rb_float_new(ptr->epsilon);
155
+ else
156
+ return Qnil;
157
+ }
158
+
159
+ /*
160
+ * call-seq:
161
+ * eps = <i>val</i> -> self
162
+ *
163
+ * Set the minimum difference value during current and previous state.
164
+ * If <i>val</i> is 0.0 (or negative value), the minimum difference value
165
+ * during current and previous state is disregarded.
166
+ */
167
+ VALUE
168
+ rb_set_eps(VALUE self, VALUE eps_value)
169
+ {
170
+ CvTermCriteria *ptr = CVTERMCRITERIA(self);
171
+ double eps = NUM2DBL(eps_value);
172
+ if (eps > 0) {
173
+ ptr->type = ptr->type | CV_TERMCRIT_EPS;
174
+ ptr->epsilon = eps;
175
+ }
176
+ else {
177
+ ptr->type = ptr->type ^ CV_TERMCRIT_EPS;
178
+ ptr->epsilon = 0;
179
+ }
180
+ return self;
181
+ }
182
+
183
+ VALUE
184
+ new_object(CvTermCriteria criteria)
185
+ {
186
+ VALUE object = rb_allocate(rb_klass);
187
+ *CVTERMCRITERIA(object) = criteria;
188
+ return object;
189
+ }
190
+
191
+ __NAMESPACE_END_CVTERMCRITERIA
192
+ __NAMESPACE_END_OPENCV