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,64 @@
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 rb_to_s(VALUE self);
35
+ VALUE rb_to_ary(VALUE self);
36
+
37
+ VALUE new_object(CvSize2D32f size);
38
+
39
+ __NAMESPACE_END_CVSIZE2D32F
40
+
41
+ inline CvSize2D32f*
42
+ CVSIZE2D32F(VALUE object)
43
+ {
44
+ CvSize2D32f *ptr;
45
+ Data_Get_Struct(object, CvSize2D32f, ptr);
46
+ return ptr;
47
+ }
48
+
49
+ inline CvSize2D32f
50
+ VALUE_TO_CVSIZE2D32F(VALUE object)
51
+ {
52
+ if (cCvSize2D32f::rb_compatible_q(cCvSize2D32f::rb_class(), object)) {
53
+ return cvSize2D32f(NUM2DBL(rb_funcall(object, rb_intern("width"), 0)),
54
+ NUM2DBL(rb_funcall(object, rb_intern("height"), 0)));
55
+ }
56
+ else {
57
+ raise_compatible_typeerror(object, cCvSize2D32f::rb_class());
58
+ }
59
+ throw "Should never reach here";
60
+ }
61
+
62
+ __NAMESPACE_END_OPENCV
63
+
64
+ #endif // RUBY_OPENCV_CVSIZE2D32F_H
@@ -0,0 +1,120 @@
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_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
45
+ rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
46
+ rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
47
+ rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
48
+ rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
49
+ }
50
+
51
+ VALUE
52
+ rb_allocate(VALUE klass)
53
+ {
54
+ CvSlice *ptr;
55
+ return Data_Make_Struct(klass, CvSlice, 0, -1, ptr);
56
+ }
57
+
58
+ /*
59
+ * call-seq:
60
+ * new(<i>start, end</i>)
61
+ *
62
+ * Create new slice object.
63
+ */
64
+ VALUE
65
+ rb_initialize(VALUE self, VALUE start, VALUE end)
66
+ {
67
+ CvSlice *self_ptr = CVSLICE(self);
68
+ self_ptr->start_index = NUM2INT(start);
69
+ self_ptr->end_index = NUM2INT(end);
70
+ return self;
71
+ }
72
+
73
+ /*
74
+ * call-seq:
75
+ * start_index
76
+ *
77
+ */
78
+ VALUE
79
+ rb_start_index_aref(VALUE self)
80
+ {
81
+ return INT2NUM(CVSLICE(self)->start_index);
82
+ }
83
+
84
+ /*
85
+ * call-seq:
86
+ * end_index
87
+ *
88
+ */
89
+ VALUE
90
+ rb_end_index_aref(VALUE self)
91
+ {
92
+ return INT2NUM(CVSLICE(self)->end_index);
93
+ }
94
+
95
+ /*
96
+ * call-seq:
97
+ * start_index = index
98
+ *
99
+ */
100
+ VALUE
101
+ rb_start_index_aset(VALUE self, VALUE index)
102
+ {
103
+ CVSLICE(self)->start_index = NUM2INT(index);
104
+ return self;
105
+ }
106
+
107
+ /*
108
+ * call-seq:
109
+ * end_index = index
110
+ *
111
+ */
112
+ VALUE
113
+ rb_end_index_aset(VALUE self, VALUE index)
114
+ {
115
+ CVSLICE(self)->end_index = NUM2INT(index);
116
+ return self;
117
+ }
118
+
119
+ __NAMESPACE_END_CVSLICE
120
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,61 @@
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_allocate(VALUE klass);
26
+ VALUE rb_initialize(VALUE self, VALUE start, VALUE end);
27
+ VALUE rb_start_index_aref(VALUE self);
28
+ VALUE rb_end_index_aref(VALUE self);
29
+ VALUE rb_start_index_aset(VALUE self, VALUE index);
30
+ VALUE rb_end_index_aset(VALUE self, VALUE index);
31
+
32
+ __NAMESPACE_END_CVSLICE
33
+
34
+ inline CvSlice*
35
+ CVSLICE(VALUE object)
36
+ {
37
+ CvSlice *ptr;
38
+ Data_Get_Struct(object, CvSlice, ptr);
39
+ return ptr;
40
+ }
41
+
42
+ inline CvSlice
43
+ VALUE_TO_CVSLICE(VALUE object)
44
+ {
45
+ if (rb_obj_is_kind_of(object, cCvSlice::rb_class())) {
46
+ CvSlice* ptr = CVSLICE(object);
47
+ return *ptr;
48
+ }
49
+ else if (rb_obj_is_kind_of(object, rb_cRange)) {
50
+ return cvSlice(NUM2INT(rb_funcall(object, rb_intern("begin"), 0)),
51
+ 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);
52
+ }
53
+ else {
54
+ raise_compatible_typeerror(object, cCvSlice::rb_class());
55
+ }
56
+ throw "Should never reach here";
57
+ }
58
+
59
+ __NAMESPACE_END_OPENCV
60
+
61
+ #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
@@ -0,0 +1,199 @@
1
+ /************************************************************
2
+
3
+ cvsurfparams.cpp -
4
+
5
+ $Author: ser1zw $
6
+
7
+ Copyright (C) 2011 ser1zw
8
+
9
+ ************************************************************/
10
+ #include "cvsurfparams.h"
11
+ /*
12
+ * Document-class: OpenCV::CvSURFParams
13
+ *
14
+ * C structure is here.
15
+ * typedef struct CvSURFParams {
16
+ * int extended;
17
+ * double hessianThreshold;
18
+ * int nOctaves;
19
+ * int nOctaveLayers;
20
+ * } CvSURFParams;
21
+ */
22
+ __NAMESPACE_BEGIN_OPENCV
23
+ __NAMESPACE_BEGIN_CVSURFPARAMS
24
+
25
+ VALUE rb_klass;
26
+
27
+ VALUE
28
+ rb_class()
29
+ {
30
+ return rb_klass;
31
+ }
32
+
33
+ void
34
+ define_ruby_class()
35
+ {
36
+ if (rb_klass)
37
+ return;
38
+ /*
39
+ * opencv = rb_define_module("OpenCV");
40
+ *
41
+ * note: this comment is used by rdoc.
42
+ */
43
+ VALUE opencv = rb_module_opencv();
44
+ rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
45
+ rb_define_alloc_func(rb_klass, rb_allocate);
46
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
47
+ rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
48
+ rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
49
+ rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
50
+ rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
51
+ rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
52
+ rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
53
+ rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
54
+ rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
55
+ }
56
+
57
+ VALUE
58
+ rb_allocate(VALUE klass)
59
+ {
60
+ CvSURFParams *ptr;
61
+ return Data_Make_Struct(klass, CvSURFParams, 0, -1, ptr);
62
+ }
63
+
64
+ /*
65
+ * call-seq:
66
+ * CvSURFParams.new(<i>hessian_threshold[,extended=false,n_octaves=3,n_octave_layers=4]</i>) -> cvsurfparams
67
+ *
68
+ * Create a CvSURFParams
69
+ */
70
+ VALUE
71
+ rb_initialize(int argc, VALUE *argv, VALUE self)
72
+ {
73
+ CvSURFParams *self_ptr = CVSURFPARAMS(self);
74
+ VALUE h_thresh, ext, noct, noctl;
75
+ rb_scan_args(argc, argv, "13", &h_thresh, &ext, &noct, &noctl);
76
+
77
+ self_ptr->hessianThreshold = NUM2DBL(h_thresh);
78
+ self_ptr->extended = NIL_P(ext) ? 0 : BOOL2INT(ext);
79
+ self_ptr->nOctaves = NIL_P(noct) ? 3 : NUM2INT(noct);
80
+ self_ptr->nOctaveLayers = NIL_P(noctl) ? 4 : NUM2INT(noctl);
81
+
82
+ return self;
83
+ }
84
+
85
+ /*
86
+ * call-seq:
87
+ * hessian_threshold -> number
88
+ * Return threshold of hessian
89
+ */
90
+ VALUE
91
+ rb_get_hessian_threshold(VALUE self)
92
+ {
93
+ return DBL2NUM(CVSURFPARAMS(self)->hessianThreshold);
94
+ }
95
+
96
+ /*
97
+ * call-seq:
98
+ * hessian_threshold = <i>value</i>
99
+ *
100
+ * Set threshold of hessian to <i>value</i>
101
+ */
102
+ VALUE
103
+ rb_set_hessian_threshold(VALUE self, VALUE value)
104
+ {
105
+ CVSURFPARAMS(self)->hessianThreshold = NUM2DBL(value);
106
+ return self;
107
+ }
108
+
109
+ /*
110
+ * call-seq:
111
+ * extended -> bool
112
+ * Return the type of descripters
113
+ * false: basic descriptors (64 elements each)
114
+ * true : exteneded descriptors (128 elements each)
115
+ */
116
+ VALUE
117
+ rb_get_extended(VALUE self)
118
+ {
119
+ return INT2BOOL(CVSURFPARAMS(self)->extended);
120
+ }
121
+
122
+ /*
123
+ * call-seq:
124
+ * extended = <i>value</i>
125
+ * Set the type of descripters
126
+ * false: basic descriptors (64 elements each)
127
+ * true : exteneded descriptors (128 elements each)
128
+ */
129
+ VALUE
130
+ rb_set_extended(VALUE self, VALUE value)
131
+ {
132
+ CVSURFPARAMS(self)->extended = BOOL2INT(value);
133
+ return self;
134
+ }
135
+
136
+ /*
137
+ * call-seq:
138
+ * n_octaves -> fixnum
139
+ * Return the number of octaves to be used for extraction
140
+ */
141
+ VALUE
142
+ rb_get_n_octaves(VALUE self)
143
+ {
144
+ return INT2NUM(CVSURFPARAMS(self)->nOctaves);
145
+ }
146
+
147
+ /*
148
+ * call-seq:
149
+ * n_octaves = <i>value</i>
150
+ * Set the number of octaves to be used for extraction
151
+ */
152
+ VALUE
153
+ rb_set_n_octaves(VALUE self, VALUE value)
154
+ {
155
+ CVSURFPARAMS(self)->nOctaves = NUM2INT(value);
156
+ return self;
157
+ }
158
+
159
+ /*
160
+ * call-seq:
161
+ * n_octave_layers -> fixnum
162
+ * Return the number of layers within each octave
163
+ */
164
+ VALUE
165
+ rb_get_n_octave_layers(VALUE self)
166
+ {
167
+ return INT2NUM(CVSURFPARAMS(self)->nOctaveLayers);
168
+ }
169
+
170
+ /*
171
+ * call-seq:
172
+ * n_octave_layers = <i>value</i>
173
+ * Set the number of layers within each octave
174
+ */
175
+ VALUE
176
+ rb_set_n_octave_layers(VALUE self, VALUE value)
177
+ {
178
+ CVSURFPARAMS(self)->nOctaveLayers = NUM2INT(value);
179
+ return self;
180
+ }
181
+
182
+ VALUE
183
+ new_object()
184
+ {
185
+ return rb_allocate(rb_klass);
186
+ }
187
+
188
+ VALUE
189
+ new_object(CvSURFParams* cvsurfparams)
190
+ {
191
+ VALUE object = rb_allocate(rb_klass);
192
+ CvSURFParams *ptr = CVSURFPARAMS(object);
193
+ ptr = cvsurfparams;
194
+ return object;
195
+ }
196
+
197
+ __NAMESPACE_END_CVSURFPARAMS
198
+ __NAMESPACE_END_OPENCV
199
+