bonanza-ruby-opencv 0.0.13.20140330211753

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.
Files changed (240) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.yardopts +3 -0
  4. data/DEVELOPERS_NOTE.md +137 -0
  5. data/Gemfile +9 -0
  6. data/History.txt +5 -0
  7. data/License.txt +30 -0
  8. data/Manifest.txt +239 -0
  9. data/README.md +98 -0
  10. data/Rakefile +99 -0
  11. data/config.yml +7 -0
  12. data/examples/alpha_blend.rb +21 -0
  13. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  14. data/examples/contours/bitmap-contours.png +0 -0
  15. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  16. data/examples/contours/contour_retrieval_modes.rb +139 -0
  17. data/examples/contours/rotated-boxes.jpg +0 -0
  18. data/examples/convexhull.rb +47 -0
  19. data/examples/face_detect.rb +20 -0
  20. data/examples/facerec/create_csv.rb +43 -0
  21. data/examples/facerec/facerec_eigenfaces.rb +132 -0
  22. data/examples/facerec/facerec_fisherfaces.rb +131 -0
  23. data/examples/facerec/facerec_lbph.rb +116 -0
  24. data/examples/facerec/readme.md +111 -0
  25. data/examples/find_obj.rb +169 -0
  26. data/examples/houghcircle.rb +22 -0
  27. data/examples/images/box.png +0 -0
  28. data/examples/images/box_in_scene.png +0 -0
  29. data/examples/images/inpaint.png +0 -0
  30. data/examples/images/lena-256x256.jpg +0 -0
  31. data/examples/images/lena-eyes.jpg +0 -0
  32. data/examples/images/lenna-rotated.jpg +0 -0
  33. data/examples/images/lenna.jpg +0 -0
  34. data/examples/images/stuff.jpg +0 -0
  35. data/examples/images/tiffany.jpg +0 -0
  36. data/examples/inpaint.rb +57 -0
  37. data/examples/match_kdtree.rb +88 -0
  38. data/examples/match_template.rb +26 -0
  39. data/examples/paint.rb +70 -0
  40. data/examples/snake.rb +43 -0
  41. data/ext/opencv/algorithm.cpp +291 -0
  42. data/ext/opencv/algorithm.h +38 -0
  43. data/ext/opencv/curve.cpp +127 -0
  44. data/ext/opencv/curve.h +34 -0
  45. data/ext/opencv/cvavgcomp.cpp +64 -0
  46. data/ext/opencv/cvavgcomp.h +39 -0
  47. data/ext/opencv/cvbox2d.cpp +195 -0
  48. data/ext/opencv/cvbox2d.h +61 -0
  49. data/ext/opencv/cvcapture.cpp +607 -0
  50. data/ext/opencv/cvcapture.h +72 -0
  51. data/ext/opencv/cvchain.cpp +233 -0
  52. data/ext/opencv/cvchain.h +46 -0
  53. data/ext/opencv/cvcircle32f.cpp +126 -0
  54. data/ext/opencv/cvcircle32f.h +52 -0
  55. data/ext/opencv/cvconnectedcomp.cpp +156 -0
  56. data/ext/opencv/cvconnectedcomp.h +49 -0
  57. data/ext/opencv/cvcontour.cpp +332 -0
  58. data/ext/opencv/cvcontour.h +48 -0
  59. data/ext/opencv/cvcontourtree.cpp +96 -0
  60. data/ext/opencv/cvcontourtree.h +41 -0
  61. data/ext/opencv/cvconvexitydefect.cpp +92 -0
  62. data/ext/opencv/cvconvexitydefect.h +42 -0
  63. data/ext/opencv/cverror.cpp +115 -0
  64. data/ext/opencv/cverror.h +28 -0
  65. data/ext/opencv/cvfeaturetree.cpp +123 -0
  66. data/ext/opencv/cvfeaturetree.h +55 -0
  67. data/ext/opencv/cvfont.cpp +228 -0
  68. data/ext/opencv/cvfont.h +64 -0
  69. data/ext/opencv/cvhaarclassifiercascade.cpp +148 -0
  70. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  71. data/ext/opencv/cvhistogram.cpp +715 -0
  72. data/ext/opencv/cvhistogram.h +73 -0
  73. data/ext/opencv/cvhumoments.cpp +178 -0
  74. data/ext/opencv/cvhumoments.h +51 -0
  75. data/ext/opencv/cvline.cpp +159 -0
  76. data/ext/opencv/cvline.h +54 -0
  77. data/ext/opencv/cvmat.cpp +6829 -0
  78. data/ext/opencv/cvmat.h +323 -0
  79. data/ext/opencv/cvmemstorage.cpp +73 -0
  80. data/ext/opencv/cvmemstorage.h +53 -0
  81. data/ext/opencv/cvmoments.cpp +293 -0
  82. data/ext/opencv/cvmoments.h +75 -0
  83. data/ext/opencv/cvpoint.cpp +265 -0
  84. data/ext/opencv/cvpoint.h +67 -0
  85. data/ext/opencv/cvpoint2d32f.cpp +216 -0
  86. data/ext/opencv/cvpoint2d32f.h +63 -0
  87. data/ext/opencv/cvpoint3d32f.cpp +252 -0
  88. data/ext/opencv/cvpoint3d32f.h +66 -0
  89. data/ext/opencv/cvrect.cpp +441 -0
  90. data/ext/opencv/cvrect.h +88 -0
  91. data/ext/opencv/cvscalar.cpp +301 -0
  92. data/ext/opencv/cvscalar.h +76 -0
  93. data/ext/opencv/cvseq.cpp +605 -0
  94. data/ext/opencv/cvseq.h +74 -0
  95. data/ext/opencv/cvsize.cpp +227 -0
  96. data/ext/opencv/cvsize.h +65 -0
  97. data/ext/opencv/cvsize2d32f.cpp +215 -0
  98. data/ext/opencv/cvsize2d32f.h +64 -0
  99. data/ext/opencv/cvslice.cpp +126 -0
  100. data/ext/opencv/cvslice.h +61 -0
  101. data/ext/opencv/cvsurfparams.cpp +208 -0
  102. data/ext/opencv/cvsurfparams.h +58 -0
  103. data/ext/opencv/cvsurfpoint.cpp +279 -0
  104. data/ext/opencv/cvsurfpoint.h +54 -0
  105. data/ext/opencv/cvtermcriteria.cpp +198 -0
  106. data/ext/opencv/cvtermcriteria.h +71 -0
  107. data/ext/opencv/cvtwopoints.cpp +122 -0
  108. data/ext/opencv/cvtwopoints.h +51 -0
  109. data/ext/opencv/cvutils.cpp +221 -0
  110. data/ext/opencv/cvutils.h +31 -0
  111. data/ext/opencv/cvvideowriter.cpp +142 -0
  112. data/ext/opencv/cvvideowriter.h +43 -0
  113. data/ext/opencv/eigenfaces.cpp +75 -0
  114. data/ext/opencv/eigenfaces.h +30 -0
  115. data/ext/opencv/extconf.rb +82 -0
  116. data/ext/opencv/facerecognizer.cpp +181 -0
  117. data/ext/opencv/facerecognizer.h +46 -0
  118. data/ext/opencv/fisherfaces.cpp +75 -0
  119. data/ext/opencv/fisherfaces.h +30 -0
  120. data/ext/opencv/gui.cpp +71 -0
  121. data/ext/opencv/gui.h +30 -0
  122. data/ext/opencv/iplconvkernel.cpp +198 -0
  123. data/ext/opencv/iplconvkernel.h +71 -0
  124. data/ext/opencv/iplimage.cpp +666 -0
  125. data/ext/opencv/iplimage.h +75 -0
  126. data/ext/opencv/lbph.cpp +78 -0
  127. data/ext/opencv/lbph.h +30 -0
  128. data/ext/opencv/mouseevent.cpp +186 -0
  129. data/ext/opencv/mouseevent.h +56 -0
  130. data/ext/opencv/opencv.cpp +833 -0
  131. data/ext/opencv/opencv.h +405 -0
  132. data/ext/opencv/pointset.cpp +280 -0
  133. data/ext/opencv/pointset.h +68 -0
  134. data/ext/opencv/trackbar.cpp +127 -0
  135. data/ext/opencv/trackbar.h +69 -0
  136. data/ext/opencv/window.cpp +377 -0
  137. data/ext/opencv/window.h +66 -0
  138. data/images/CvMat_sobel.png +0 -0
  139. data/images/CvMat_sub_rect.png +0 -0
  140. data/images/CvSeq_relationmap.png +0 -0
  141. data/lib/opencv.rb +12 -0
  142. data/lib/opencv/psyched_yaml.rb +22 -0
  143. data/lib/opencv/version.rb +4 -0
  144. data/test/eigenfaces_save.xml +7524 -0
  145. data/test/fisherfaces_save.xml +7530 -0
  146. data/test/helper.rb +166 -0
  147. data/test/lbph_save.xml +4304 -0
  148. data/test/runner.rb +30 -0
  149. data/test/samples/airplane.jpg +0 -0
  150. data/test/samples/baboon.jpg +0 -0
  151. data/test/samples/baboon200.jpg +0 -0
  152. data/test/samples/baboon200_rotated.jpg +0 -0
  153. data/test/samples/blank0.jpg +0 -0
  154. data/test/samples/blank1.jpg +0 -0
  155. data/test/samples/blank2.jpg +0 -0
  156. data/test/samples/blank3.jpg +0 -0
  157. data/test/samples/blank4.jpg +0 -0
  158. data/test/samples/blank5.jpg +0 -0
  159. data/test/samples/blank6.jpg +0 -0
  160. data/test/samples/blank7.jpg +0 -0
  161. data/test/samples/blank8.jpg +0 -0
  162. data/test/samples/blank9.jpg +0 -0
  163. data/test/samples/cat.jpg +0 -0
  164. data/test/samples/chessboard.jpg +0 -0
  165. data/test/samples/contours.jpg +0 -0
  166. data/test/samples/fruits.jpg +0 -0
  167. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  168. data/test/samples/inpaint-mask.bmp +0 -0
  169. data/test/samples/lena-256x256.jpg +0 -0
  170. data/test/samples/lena-32x32.jpg +0 -0
  171. data/test/samples/lena-eyes.jpg +0 -0
  172. data/test/samples/lena-inpaint.jpg +0 -0
  173. data/test/samples/lena.jpg +0 -0
  174. data/test/samples/lines.jpg +0 -0
  175. data/test/samples/messy0.jpg +0 -0
  176. data/test/samples/messy1.jpg +0 -0
  177. data/test/samples/movie_sample.avi +0 -0
  178. data/test/samples/one_way_train_0000.jpg +0 -0
  179. data/test/samples/one_way_train_0001.jpg +0 -0
  180. data/test/samples/partially_blank0.jpg +0 -0
  181. data/test/samples/partially_blank1.jpg +0 -0
  182. data/test/samples/smooth0.jpg +0 -0
  183. data/test/samples/smooth1.jpg +0 -0
  184. data/test/samples/smooth2.jpg +0 -0
  185. data/test/samples/smooth3.jpg +0 -0
  186. data/test/samples/smooth4.jpg +0 -0
  187. data/test/samples/smooth5.jpg +0 -0
  188. data/test/samples/smooth6.jpg +0 -0
  189. data/test/samples/str-cv-rotated.jpg +0 -0
  190. data/test/samples/str-cv.jpg +0 -0
  191. data/test/samples/str-ov.jpg +0 -0
  192. data/test/samples/stuff.jpg +0 -0
  193. data/test/test_curve.rb +43 -0
  194. data/test/test_cvavgcomp.rb +24 -0
  195. data/test/test_cvbox2d.rb +76 -0
  196. data/test/test_cvcapture.rb +183 -0
  197. data/test/test_cvchain.rb +108 -0
  198. data/test/test_cvcircle32f.rb +41 -0
  199. data/test/test_cvconnectedcomp.rb +61 -0
  200. data/test/test_cvcontour.rb +150 -0
  201. data/test/test_cvcontourtree.rb +43 -0
  202. data/test/test_cverror.rb +50 -0
  203. data/test/test_cvfeaturetree.rb +65 -0
  204. data/test/test_cvfont.rb +58 -0
  205. data/test/test_cvhaarclassifiercascade.rb +63 -0
  206. data/test/test_cvhistogram.rb +271 -0
  207. data/test/test_cvhumoments.rb +83 -0
  208. data/test/test_cvline.rb +50 -0
  209. data/test/test_cvmat.rb +3003 -0
  210. data/test/test_cvmat_drawing.rb +349 -0
  211. data/test/test_cvmat_dxt.rb +150 -0
  212. data/test/test_cvmat_imageprocessing.rb +2085 -0
  213. data/test/test_cvmoments.rb +180 -0
  214. data/test/test_cvpoint.rb +75 -0
  215. data/test/test_cvpoint2d32f.rb +75 -0
  216. data/test/test_cvpoint3d32f.rb +93 -0
  217. data/test/test_cvrect.rb +144 -0
  218. data/test/test_cvscalar.rb +113 -0
  219. data/test/test_cvseq.rb +295 -0
  220. data/test/test_cvsize.rb +75 -0
  221. data/test/test_cvsize2d32f.rb +75 -0
  222. data/test/test_cvslice.rb +31 -0
  223. data/test/test_cvsurfparams.rb +57 -0
  224. data/test/test_cvsurfpoint.rb +66 -0
  225. data/test/test_cvtermcriteria.rb +56 -0
  226. data/test/test_cvtwopoints.rb +40 -0
  227. data/test/test_cvvideowriter.rb +58 -0
  228. data/test/test_eigenfaces.rb +93 -0
  229. data/test/test_fisherfaces.rb +93 -0
  230. data/test/test_iplconvkernel.rb +54 -0
  231. data/test/test_iplimage.rb +232 -0
  232. data/test/test_lbph.rb +152 -0
  233. data/test/test_mouseevent.rb +17 -0
  234. data/test/test_opencv.rb +360 -0
  235. data/test/test_pointset.rb +128 -0
  236. data/test/test_preliminary.rb +130 -0
  237. data/test/test_trackbar.rb +47 -0
  238. data/test/test_window.rb +115 -0
  239. data/yard_extension.rb +5 -0
  240. metadata +399 -0
@@ -0,0 +1,34 @@
1
+ /************************************************************
2
+
3
+ curve.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVSEQ_CURVE_H
11
+ #define RUBY_OPENCV_CVSEQ_CURVE_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CURVE namespace mCurve {
16
+ #define __NAMESPACE_END_CURVE }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CURVE
20
+
21
+ VALUE rb_module();
22
+
23
+ void init_ruby_module();
24
+
25
+ VALUE rb_closed_q(VALUE self);
26
+ VALUE rb_convex_q(VALUE self);
27
+ VALUE rb_hole_q(VALUE self);
28
+ VALUE rb_simple_q(VALUE self);
29
+ VALUE rb_arc_length(int argc, VALUE *argv, VALUE self);
30
+
31
+ __NAMESPACE_END_CURVE
32
+ __NAMESPACE_END_OPENCV
33
+
34
+ #endif // RUBY_OPENCV_CVSEQ_CURVE_H
@@ -0,0 +1,64 @@
1
+ /************************************************************
2
+
3
+ cvavgcomp.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvavgcomp.h"
11
+ /*
12
+ * Document-class: OpenCV::CvAvgComp
13
+ *
14
+ * CvRect with parameter "neighbors"
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_AVGCOMP
18
+
19
+ VALUE rb_klass;
20
+
21
+ VALUE
22
+ rb_class()
23
+ {
24
+ return rb_klass;
25
+ }
26
+
27
+ VALUE
28
+ rb_allocate(VALUE klass)
29
+ {
30
+ CvAvgComp *ptr;
31
+ return Data_Make_Struct(klass, CvAvgComp, 0, -1, ptr);
32
+ }
33
+
34
+ /*
35
+ * Return neighbors
36
+ * @overload neighbors
37
+ * @return [Integer] neighbors
38
+ */
39
+ VALUE
40
+ rb_neighbors(VALUE self)
41
+ {
42
+ return INT2NUM(CVAVGCOMP(self)->neighbors);
43
+ }
44
+
45
+ void
46
+ init_ruby_class()
47
+ {
48
+ #if 0
49
+ // For documentation using YARD
50
+ VALUE opencv = rb_define_module("OpenCV");
51
+ VALUE cvrect = rb_define_class_under(opencv, "CvRect", rb_cObject);
52
+ #endif
53
+
54
+ if (rb_klass)
55
+ return;
56
+
57
+ VALUE opencv = rb_module_opencv(), cvrect = cCvRect::rb_class();
58
+ rb_klass = rb_define_class_under(opencv, "CvAvgComp", cvrect);
59
+ rb_define_alloc_func(rb_klass, rb_allocate);
60
+ rb_define_method(rb_klass, "neighbors", RUBY_METHOD_FUNC(rb_neighbors), 0);
61
+ }
62
+
63
+ __NAMESPACE_END_AVGCOMP
64
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,39 @@
1
+ /**********************************************************************
2
+
3
+ cvavgcomp.h
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ **********************************************************************/
10
+ #ifndef RUBY_OPENCV_AVGCOMP_H
11
+ #define RUBY_OPENCV_AVGCOMP_H
12
+
13
+ #define __NAMESPACE_BEGIN_AVGCOMP namespace cCvAvgComp {
14
+ #define __NAMESPACE_END_AVGCOMP }
15
+
16
+ #include <opencv.h>
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_AVGCOMP
20
+
21
+ VALUE rb_class();
22
+
23
+ void init_ruby_class();
24
+
25
+ VALUE rb_allocate(VALUE klass);
26
+ VALUE rb_neighbors(VALUE self);
27
+
28
+ __NAMESPACE_END_AVGCOMP
29
+
30
+ inline CvAvgComp *CVAVGCOMP(VALUE object){
31
+ CvAvgComp *ptr;
32
+ Data_Get_Struct(object, CvAvgComp, ptr);
33
+ return ptr;
34
+ }
35
+
36
+ __NAMESPACE_END_OPENCV
37
+
38
+
39
+ #endif // RUBY_OPENCV_AVGCOMP_H
@@ -0,0 +1,195 @@
1
+ /************************************************************
2
+
3
+ cvbox2d.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvbox2d.h"
11
+ /*
12
+ * Document-class: OpenCV::CvBox2D
13
+ *
14
+ * Stores coordinates of a rotated rectangle.
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_CVBOX2D
18
+
19
+ VALUE rb_klass;
20
+
21
+ VALUE
22
+ rb_class()
23
+ {
24
+ return rb_klass;
25
+ }
26
+
27
+ VALUE
28
+ rb_allocate(VALUE klass)
29
+ {
30
+ CvBox2D *ptr;
31
+ return Data_Make_Struct(klass, CvBox2D, 0, -1, ptr);
32
+ }
33
+
34
+ /*
35
+ * Create a box
36
+ * @overload new(center=nil, size=nil, angle=nil)
37
+ * @param center [CvPoint2D32f,nil] Center of the box
38
+ * @param size [CvSize,nil] Size of the box
39
+ * @param angle [Number,nil] Angle between the horizontal axis and the first side in degrees
40
+ * @return [CvBox2D] New box
41
+ */
42
+ VALUE
43
+ rb_initialize(int argc, VALUE *argv, VALUE self)
44
+ {
45
+ VALUE center, size, angle;
46
+ CvBox2D* self_ptr = CVBOX2D(self);
47
+ rb_scan_args(argc, argv, "03", &center, &size, &angle);
48
+
49
+ if (!NIL_P(center)) {
50
+ self_ptr->center = VALUE_TO_CVPOINT2D32F(center);
51
+ }
52
+ if (!NIL_P(size)) {
53
+ self_ptr->size = VALUE_TO_CVSIZE2D32F(size);
54
+ self_ptr->angle = NUM2DBL(angle);
55
+ }
56
+
57
+ return self;
58
+ }
59
+
60
+ /*
61
+ * Returns center point of the box
62
+ * @overload center
63
+ * @return [CvPoint2D32f] Center of the box
64
+ */
65
+ VALUE
66
+ rb_center(VALUE self)
67
+ {
68
+ return REFER_OBJECT(cCvPoint2D32f::rb_class(), &CVBOX2D(self)->center, self);
69
+ }
70
+
71
+ /*
72
+ * Set center point of the box
73
+ * @overload center=value
74
+ * @param value [CvPoint2D32f] Center of the box
75
+ * @return [CvBox2D] self
76
+ */
77
+ VALUE
78
+ rb_set_center(VALUE self, VALUE value)
79
+ {
80
+ CVBOX2D(self)->center = VALUE_TO_CVPOINT2D32F(value);
81
+ return self;
82
+ }
83
+
84
+ /*
85
+ * Returns size of the box
86
+ * @overload size
87
+ * @return [CvSize2D32f] Size of the box
88
+ */
89
+ VALUE
90
+ rb_size(VALUE self)
91
+ {
92
+ return REFER_OBJECT(cCvSize2D32f::rb_class(), &CVBOX2D(self)->size, self);
93
+ }
94
+
95
+ /*
96
+ * Set size of the box
97
+ * @overload size=value
98
+ * @param value [CvSize2D32f] Size of the box
99
+ * @return [CvBox2D] self
100
+ */
101
+ VALUE
102
+ rb_set_size(VALUE self, VALUE value)
103
+ {
104
+ CVBOX2D(self)->size = VALUE_TO_CVSIZE2D32F(value);
105
+ return self;
106
+ }
107
+
108
+ /*
109
+ * Returns angle of the box
110
+ * @overload angle
111
+ * @return [Float] Angle of the box
112
+ */
113
+ VALUE
114
+ rb_angle(VALUE self)
115
+ {
116
+ return rb_float_new(CVBOX2D(self)->angle);
117
+ }
118
+
119
+ /*
120
+ * Set angle of the box
121
+ * @overload angle=value
122
+ * @param value [Number] Angle of the box
123
+ * @return [CvBox2D] self
124
+ */
125
+ VALUE
126
+ rb_set_angle(VALUE self, VALUE value)
127
+ {
128
+ CVBOX2D(self)->angle = NUM2DBL(value);
129
+ return self;
130
+ }
131
+
132
+ /*
133
+ * Find box vertices
134
+ * @overload points
135
+ * @return [Array<CvPoint2D32f>] Vertices of the box
136
+ * @opencv_func cvBoxPoints
137
+ */
138
+ VALUE
139
+ rb_points(VALUE self)
140
+ {
141
+ const int n = 4;
142
+ CvPoint2D32f p[n];
143
+ try {
144
+ cvBoxPoints(*CVBOX2D(self), p);
145
+ }
146
+ catch (cv::Exception& e) {
147
+ raise_cverror(e);
148
+ }
149
+ VALUE points = rb_ary_new2(n);
150
+ for (int i = 0; i < n; ++i) {
151
+ rb_ary_store(points, i, cCvPoint2D32f::new_object(p[i]));
152
+ }
153
+ return points;
154
+ }
155
+
156
+ VALUE
157
+ new_object()
158
+ {
159
+ return rb_allocate(cCvBox2D::rb_class());
160
+ }
161
+
162
+ VALUE
163
+ new_object(CvBox2D box)
164
+ {
165
+ VALUE object = rb_allocate(rb_klass);
166
+ *CVBOX2D(object) = box;
167
+ return object;
168
+ }
169
+
170
+ void
171
+ init_ruby_class()
172
+ {
173
+ #if 0
174
+ // For documentation using YARD
175
+ VALUE opencv = rb_define_module("OpenCV");
176
+ #endif
177
+
178
+ if (rb_klass)
179
+ return;
180
+
181
+ VALUE opencv = rb_module_opencv();
182
+ rb_klass = rb_define_class_under(opencv, "CvBox2D", rb_cObject);
183
+ rb_define_alloc_func(rb_klass, rb_allocate);
184
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
185
+ rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
186
+ rb_define_method(rb_klass, "center=", RUBY_METHOD_FUNC(rb_set_center), 1);
187
+ rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
188
+ rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
189
+ rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
190
+ rb_define_method(rb_klass, "angle=", RUBY_METHOD_FUNC(rb_set_angle), 1);
191
+ rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
192
+ }
193
+
194
+ __NAMESPACE_END_CVBOX2D
195
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,61 @@
1
+ /************************************************************
2
+
3
+ cvbox2d.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVBOX2D_H
11
+ #define RUBY_OPENCV_CVBOX2D_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVBOX2D namespace cCvBox2D {
16
+ #define __NAMESPACE_END_CVBOX2D }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVBOX2D
20
+
21
+ VALUE rb_class();
22
+
23
+ void init_ruby_class();
24
+
25
+ VALUE rb_allocate(VALUE klass);
26
+
27
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
28
+ VALUE rb_center(VALUE self);
29
+ VALUE rb_set_center(VALUE self, VALUE value);
30
+ VALUE rb_size(VALUE self);
31
+ VALUE rb_set_size(VALUE self, VALUE value);
32
+ VALUE rb_angle(VALUE self);
33
+ VALUE rb_set_angle(VALUE self, VALUE value);
34
+ VALUE rb_points(VALUE self);
35
+
36
+ VALUE new_object();
37
+ VALUE new_object(CvBox2D box);
38
+
39
+ __NAMESPACE_END_CVBOX2D
40
+
41
+ inline CvBox2D*
42
+ CVBOX2D(VALUE object){
43
+ CvBox2D *ptr;
44
+ Data_Get_Struct(object, CvBox2D, ptr);
45
+ return ptr;
46
+ }
47
+
48
+ inline CvBox2D
49
+ VALUE_TO_CVBOX2D(VALUE object){
50
+ if (rb_obj_is_kind_of(object, cCvBox2D::rb_class())) {
51
+ return *CVBOX2D(object);
52
+ }
53
+ else {
54
+ raise_typeerror(object, cCvBox2D::rb_class());
55
+ }
56
+ throw "Should never reach here";
57
+ }
58
+
59
+ __NAMESPACE_END_OPENCV
60
+
61
+ #endif // RUBY_OPENCV_CVBOX2D_H
@@ -0,0 +1,607 @@
1
+ /************************************************************
2
+
3
+ cvcapture.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvcapture.h"
11
+ /*
12
+ * Document-class: OpenCV::CvCapture
13
+ *
14
+ * Class for video capturing from video files or cameras
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_CVCAPTURE
18
+
19
+ VALUE rb_klass;
20
+
21
+ VALUE
22
+ rb_class()
23
+ {
24
+ return rb_klass;
25
+ }
26
+
27
+ void
28
+ cvcapture_free(void *ptr)
29
+ {
30
+ if (ptr)
31
+ cvReleaseCapture((CvCapture**)&ptr);
32
+ }
33
+
34
+ /*
35
+ * Open video file or a capturing device for video capturing
36
+ * @scope class
37
+ * @overload open(dev = nil)
38
+ * @param dev [String,Fixnum,Simbol,nil] Video capturing device
39
+ * * If dev is a string (i.e "stream.avi"), reads video stream from a file.
40
+ * * If dev is a number or symbol (included in CvCapture::INTERFACE), reads video stream from a device.
41
+ * * If dev is a nil, same as CvCapture.open(:any)
42
+ * @return [CvCapture] Opened CvCapture instance
43
+ * @opencv_func cvCaptureFromCAM
44
+ * @opencv_func cvCaptureFromFile
45
+ */
46
+ VALUE
47
+ rb_open(int argc, VALUE *argv, VALUE self)
48
+ {
49
+ VALUE device;
50
+ rb_scan_args(argc, argv, "01", &device);
51
+ CvCapture *capture = 0;
52
+ try {
53
+ switch (TYPE(device)) {
54
+ case T_STRING:
55
+ capture = cvCaptureFromFile(StringValueCStr(device));
56
+ break;
57
+ case T_FIXNUM:
58
+ capture = cvCaptureFromCAM(FIX2INT(device));
59
+ break;
60
+ case T_SYMBOL: {
61
+ VALUE cap_index = rb_hash_lookup(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
62
+ if (NIL_P(cap_index))
63
+ rb_raise(rb_eArgError, "undefined interface.");
64
+ capture = cvCaptureFromCAM(NUM2INT(cap_index));
65
+ break;
66
+ }
67
+ case T_NIL:
68
+ capture = cvCaptureFromCAM(CV_CAP_ANY);
69
+ break;
70
+ }
71
+ }
72
+ catch (cv::Exception& e) {
73
+ raise_cverror(e);
74
+ }
75
+ if (!capture)
76
+ rb_raise(rb_eStandardError, "Invalid capture format.");
77
+ return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, capture);
78
+ }
79
+
80
+ /*
81
+ * Grabs the next frame from video file or capturing device.
82
+ * @overload grab
83
+ * @return [Boolean] If grabbing a frame successed, returns true, otherwise returns false.
84
+ * @opencv_func cvGrabFrame
85
+ */
86
+ VALUE
87
+ rb_grab(VALUE self)
88
+ {
89
+ int grab = 0;
90
+ try {
91
+ grab = cvGrabFrame(CVCAPTURE(self));
92
+ }
93
+ catch (cv::Exception& e) {
94
+ raise_cverror(e);
95
+ }
96
+ return grab ? Qtrue : Qfalse;
97
+ }
98
+
99
+ /*
100
+ * Decodes and returns the grabbed video frame.
101
+ * @overload retrieve
102
+ * @return [IplImage] Grabbed video frame
103
+ * @return [nil] Failed to grabbing a frame
104
+ * @opencv_func cvRetrieveFrame
105
+ */
106
+ VALUE
107
+ rb_retrieve(VALUE self)
108
+ {
109
+ VALUE image = Qnil;
110
+ IplImage *frame = NULL;
111
+ try {
112
+ if (!(frame = cvRetrieveFrame(CVCAPTURE(self)))) {
113
+ return Qnil;
114
+ }
115
+ image = cIplImage::new_object(frame->width, frame->height,
116
+ CV_MAKETYPE(IPL2CV_DEPTH(frame->depth), frame->nChannels));
117
+ if (frame->origin == IPL_ORIGIN_TL) {
118
+ cvCopy(frame, CVARR(image));
119
+ }
120
+ else {
121
+ cvFlip(frame, CVARR(image));
122
+ }
123
+ }
124
+ catch (cv::Exception& e) {
125
+ raise_cverror(e);
126
+ }
127
+ return image;
128
+
129
+ }
130
+
131
+ /*
132
+ * Grabs, decodes and returns the next video frame.
133
+ * @overload query
134
+ * @return [IplImage] Next video frame
135
+ * @return [nil] Failed to read next video frame
136
+ * @opencv_func cvQueryFrame
137
+ */
138
+ VALUE
139
+ rb_query(VALUE self)
140
+ {
141
+ VALUE image = Qnil;
142
+ IplImage *frame = NULL;
143
+ try {
144
+ if (!(frame = cvQueryFrame(CVCAPTURE(self)))) {
145
+ return Qnil;
146
+ }
147
+ image = cIplImage::new_object(frame->width, frame->height,
148
+ CV_MAKETYPE(IPL2CV_DEPTH(frame->depth), frame->nChannels));
149
+ if (frame->origin == IPL_ORIGIN_TL) {
150
+ cvCopy(frame, CVARR(image));
151
+ }
152
+ else {
153
+ cvFlip(frame, CVARR(image));
154
+ }
155
+ }
156
+ catch (cv::Exception& e) {
157
+ raise_cverror(e);
158
+ }
159
+ return image;
160
+ }
161
+
162
+ VALUE
163
+ rb_get_capture_property(VALUE self, int id)
164
+ {
165
+ double result = 0;
166
+ try {
167
+ result = cvGetCaptureProperty(CVCAPTURE(self), id);
168
+ }
169
+ catch (cv::Exception& e) {
170
+ raise_cverror(e);
171
+ }
172
+ return rb_float_new(result);
173
+ }
174
+
175
+ VALUE
176
+ rb_set_capture_property(VALUE self, int id, VALUE value)
177
+ {
178
+ double result = 0;
179
+ try {
180
+ result = cvSetCaptureProperty(CVCAPTURE(self), id, NUM2DBL(value));
181
+ }
182
+ catch (cv::Exception& e) {
183
+ raise_cverror(e);
184
+ }
185
+ return rb_float_new(result);
186
+ }
187
+
188
+ /*
189
+ * Get film current position in milliseconds or video capture timestamp.
190
+ * @overload millisecond
191
+ * @return [Number] Current position of the video file in milliseconds or video capture timestamp
192
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_MSEC)
193
+ */
194
+ VALUE
195
+ rb_get_millisecond(VALUE self)
196
+ {
197
+ return rb_get_capture_property(self, CV_CAP_PROP_POS_MSEC);
198
+ }
199
+
200
+ /*
201
+ * Set film current position in milliseconds or video capture timestamp.
202
+ * @overload millisecond=value
203
+ * @param value [Number] Position in milliseconds or video capture timestamp.
204
+ * @return [Number]
205
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_MSEC)
206
+ */
207
+ VALUE
208
+ rb_set_millisecond(VALUE self, VALUE value)
209
+ {
210
+ return rb_set_capture_property(self, CV_CAP_PROP_POS_MSEC, value);
211
+ }
212
+
213
+ /*
214
+ * Get 0-based index of the frame to be decoded/captured next
215
+ * @overload frames
216
+ * @return [Number] 0-based index of the frame to be decoded/captured next
217
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_FRAMES)
218
+ */
219
+ VALUE
220
+ rb_get_frames(VALUE self)
221
+ {
222
+ return rb_get_capture_property(self, CV_CAP_PROP_POS_FRAMES);
223
+ }
224
+
225
+ /*
226
+ * Set 0-based index of the frame to be decoded/captured next
227
+ * @overload frames=value
228
+ * @param value [Number] 0-based index of the frame to be decoded/captured next
229
+ * @return [Number]
230
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_FRAMES)
231
+ */
232
+ VALUE
233
+ rb_set_frames(VALUE self, VALUE value)
234
+ {
235
+ return rb_set_capture_property(self, CV_CAP_PROP_POS_FRAMES, value);
236
+ }
237
+ /*
238
+ * Get relative position of video file
239
+ * @overload avi_ratio
240
+ * @return [Number] Relative position of video file (0: Start of the film, 1: End of the film)
241
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_AVI_RATIO)
242
+ */
243
+ VALUE
244
+ rb_get_avi_ratio(VALUE self)
245
+ {
246
+ return rb_get_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO);
247
+ }
248
+ /*
249
+ * Set relative position of video file
250
+ * @overload avi_ratio=value
251
+ * @param value [Number] Relative position of video file (0: Start of the film, 1: End of the film)
252
+ * @return [Number]
253
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_AVI_RATIO)
254
+ */
255
+ VALUE
256
+ rb_set_avi_ratio(VALUE self, VALUE value)
257
+ {
258
+ return rb_set_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO, value);
259
+ }
260
+
261
+ /*
262
+ * Get size of frames in the video stream.
263
+ * @overload size
264
+ * @return [Size] Size of frames in the video stream.
265
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH,CV_CAP_PROP_FRAME_HEIGHT)
266
+ */
267
+ VALUE
268
+ rb_get_size(VALUE self)
269
+ {
270
+ CvSize size;
271
+ try {
272
+ CvCapture* self_ptr = CVCAPTURE(self);
273
+ size = cvSize((int)cvGetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_WIDTH),
274
+ (int)cvGetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_HEIGHT));
275
+ }
276
+ catch (cv::Exception& e) {
277
+ raise_cverror(e);
278
+ }
279
+ return cCvSize::new_object(size);
280
+ }
281
+
282
+ /*
283
+ * Set size of frames in the video stream.
284
+ * @overload size=value
285
+ * @param value [CvSize] Size of frames
286
+ * @return [Number]
287
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH,CV_CAP_PROP_FRAME_HEIGHT)
288
+ */
289
+ VALUE
290
+ rb_set_size(VALUE self, VALUE value)
291
+ {
292
+ double result = 0;
293
+ CvSize size = VALUE_TO_CVSIZE(value);
294
+ try {
295
+ CvCapture* self_ptr = CVCAPTURE(self);
296
+ cvSetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_WIDTH, size.width);
297
+ result = cvSetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_HEIGHT, size.height);
298
+ }
299
+ catch (cv::Exception& e) {
300
+ raise_cverror(e);
301
+ }
302
+ return DBL2NUM(result);
303
+ }
304
+
305
+ /*
306
+ * Get width of frames in the video stream.
307
+ * @overload width
308
+ * @return [Number] Width of frames in the video stream.
309
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_FRAME_WIDTH)
310
+ */
311
+ VALUE
312
+ rb_get_width(VALUE self)
313
+ {
314
+ return rb_get_capture_property(self, CV_CAP_PROP_FRAME_WIDTH);
315
+ }
316
+
317
+ /*
318
+ * Set width of frames in the video stream.
319
+ * @overload width=value
320
+ * @param value [Number] Width of frames
321
+ * @return [Number]
322
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH)
323
+ */
324
+ VALUE
325
+ rb_set_width(VALUE self, VALUE value)
326
+ {
327
+ return rb_set_capture_property(self, CV_CAP_PROP_FRAME_WIDTH, value);
328
+ }
329
+
330
+ /*
331
+ * Get height of frames in the video stream.
332
+ * @overload height
333
+ * @return [Number] Height of frames in the video stream.
334
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_HEIGHT)
335
+ */
336
+ VALUE
337
+ rb_get_height(VALUE self)
338
+ {
339
+ return rb_get_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT);
340
+ }
341
+
342
+ /*
343
+ * Set height of frames in the video stream.
344
+ * @overload height=value
345
+ * @param value [Number] Height of frames
346
+ * @return [Number]
347
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_HEIGHT)
348
+ */
349
+ VALUE
350
+ rb_set_height(VALUE self, VALUE value)
351
+ {
352
+ return rb_set_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT, value);
353
+ }
354
+
355
+ /*
356
+ * Get frame rate
357
+ * @overload fps
358
+ * @return [Number] Frame rate
359
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FPS)
360
+ */
361
+ VALUE
362
+ rb_get_fps(VALUE self)
363
+ {
364
+ return rb_get_capture_property(self, CV_CAP_PROP_FPS);
365
+ }
366
+
367
+ /*
368
+ * Set frame rate
369
+ * @overload fps=value
370
+ * @param value [Number] Frame rate
371
+ * @return [Number]
372
+ * @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FPS)
373
+ */
374
+ VALUE
375
+ rb_set_fps(VALUE self, VALUE value)
376
+ {
377
+ return rb_set_capture_property(self, CV_CAP_PROP_FPS, value);
378
+ }
379
+
380
+ /*
381
+ * Get 4 character code of codec. see http://www.fourcc.org/
382
+ * @overload fourcc
383
+ * @return [Number] Codec code
384
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FOURCC)
385
+ */
386
+ VALUE
387
+ rb_get_fourcc(VALUE self)
388
+ {
389
+ char str[4];
390
+ double fourcc = cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FOURCC);
391
+ sprintf(str, "%s", (char*)&fourcc);
392
+ return rb_str_new2(str);
393
+ }
394
+
395
+ /*
396
+ * Get number of frames in video file.
397
+ * @overload frame_count
398
+ * @return [Number] Number of frames
399
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_COUNT)
400
+ */
401
+ VALUE
402
+ rb_get_frame_count(VALUE self)
403
+ {
404
+ return rb_get_capture_property(self, CV_CAP_PROP_FRAME_COUNT);
405
+ }
406
+
407
+ /*
408
+ * Get format of images returned by CvCapture#retrieve
409
+ * @overload format
410
+ * @return [Number] format
411
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FORMAT)
412
+ */
413
+ VALUE
414
+ rb_get_format(VALUE self)
415
+ {
416
+ return rb_get_capture_property(self, CV_CAP_PROP_FORMAT);
417
+ }
418
+
419
+ /*
420
+ * Get a backend-specific value indicating the current capture mode
421
+ * @overload mode
422
+ * @return [Number] Backend-specific value indicating the current capture mode
423
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_MODE)
424
+ */
425
+ VALUE
426
+ rb_get_mode(VALUE self)
427
+ {
428
+ return rb_get_capture_property(self, CV_CAP_PROP_MODE);
429
+ }
430
+
431
+ /*
432
+ * Get brightness of the image (only for cameras)
433
+ * @overload brightness
434
+ * @return [Number] Brightness
435
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_BRIGHTNESS)
436
+ */
437
+ VALUE
438
+ rb_get_brightness(VALUE self)
439
+ {
440
+ return rb_get_capture_property(self, CV_CAP_PROP_BRIGHTNESS);
441
+ }
442
+
443
+ /*
444
+ * Get contrast of the image (only for cameras)
445
+ * @overload contrast
446
+ * @return [Number] Contrast
447
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_CONTRAST)
448
+ */
449
+ VALUE
450
+ rb_get_contrast(VALUE self)
451
+ {
452
+ return rb_get_capture_property(self, CV_CAP_PROP_CONTRAST);
453
+ }
454
+
455
+ /*
456
+ * Get saturation of the image (only for cameras)
457
+ * @overload saturation
458
+ * @return [Number] Saturation
459
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_SATURATION)
460
+ */
461
+ VALUE
462
+ rb_get_saturation(VALUE self)
463
+ {
464
+ return rb_get_capture_property(self, CV_CAP_PROP_SATURATION);
465
+ }
466
+ /*
467
+ * Get hue of the image (only for cameras)
468
+ * @overload hue
469
+ * @return [Number] Hue
470
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_HUE)
471
+ */
472
+ VALUE
473
+ rb_get_hue(VALUE self)
474
+ {
475
+ return rb_get_capture_property(self, CV_CAP_PROP_HUE);
476
+ }
477
+
478
+ /*
479
+ * Get gain of the image (only for cameras)
480
+ * @overload gain
481
+ * @return [Number] Gain
482
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_GAIN)
483
+ */
484
+ VALUE
485
+ rb_get_gain(VALUE self)
486
+ {
487
+ return rb_get_capture_property(self, CV_CAP_PROP_GAIN);
488
+ }
489
+
490
+ /*
491
+ * Get exposure (only for cameras)
492
+ * @overload exposure
493
+ * @return [Number] Exposure
494
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_EXPOSURE)
495
+ */
496
+ VALUE
497
+ rb_get_exposure(VALUE self)
498
+ {
499
+ return rb_get_capture_property(self, CV_CAP_PROP_EXPOSURE);
500
+ }
501
+
502
+ /*
503
+ * Get boolean flags indicating whether images should be converted to RGB
504
+ * @overload convert_rgb
505
+ * @return [Boolean] Whether images should be converted to RGB
506
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_CONVERT_RGB)
507
+ */
508
+ VALUE
509
+ rb_get_convert_rgb(VALUE self)
510
+ {
511
+ int flag = 0;
512
+ try {
513
+ flag = (int)cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_CONVERT_RGB);
514
+ }
515
+ catch (cv::Exception& e) {
516
+ raise_cverror(e);
517
+ }
518
+ return flag ? Qtrue : Qfalse;
519
+ }
520
+
521
+ /*
522
+ * Get rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)
523
+ * @overload rectification
524
+ * @return [Number] Rectification flag
525
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_RECTIFICATION)
526
+ */
527
+ VALUE
528
+ rb_get_rectification(VALUE self)
529
+ {
530
+ return rb_get_capture_property(self, CV_CAP_PROP_RECTIFICATION);
531
+ }
532
+
533
+ void
534
+ init_ruby_class()
535
+ {
536
+ #if 0
537
+ // For documentation using YARD
538
+ VALUE opencv = rb_define_module("OpenCV");
539
+ #endif
540
+
541
+ if (rb_klass)
542
+ return;
543
+
544
+ VALUE opencv = rb_module_opencv();
545
+
546
+ rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
547
+
548
+ VALUE video_interface = rb_hash_new();
549
+ /*
550
+ * :any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394,
551
+ * :stereo, :tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime
552
+ */
553
+ rb_define_const(rb_klass, "INTERFACE", video_interface);
554
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
555
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
556
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("vfw")), INT2FIX(CV_CAP_VFW));
557
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l")), INT2FIX(CV_CAP_V4L));
558
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l2")), INT2FIX(CV_CAP_V4L2));
559
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("fireware")), INT2FIX(CV_CAP_FIREWARE));
560
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("ieee1394")), INT2FIX(CV_CAP_IEEE1394));
561
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("dc1394")), INT2FIX(CV_CAP_DC1394));
562
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("cmu1394")), INT2FIX(CV_CAP_CMU1394));
563
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("stereo")), INT2FIX(CV_CAP_STEREO));
564
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx")), INT2FIX(CV_CAP_TYZX));
565
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_left")), INT2FIX(CV_TYZX_LEFT));
566
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_right")), INT2FIX(CV_TYZX_RIGHT));
567
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_color")), INT2FIX(CV_TYZX_COLOR));
568
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_z")), INT2FIX(CV_TYZX_Z));
569
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("qt")), INT2FIX(CV_CAP_QT));
570
+ rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
571
+
572
+ rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
573
+
574
+ rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
575
+ rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
576
+ rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
577
+ rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
578
+ rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
579
+ rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
580
+ rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
581
+ rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
582
+ rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
583
+ rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
584
+ rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
585
+ rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
586
+ rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
587
+ rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
588
+ rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
589
+ rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
590
+ rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
591
+ rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
592
+ rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
593
+ rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
594
+ rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
595
+ rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
596
+ rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
597
+ rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
598
+ rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
599
+ rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
600
+ rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
601
+ rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
602
+ rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
603
+ }
604
+
605
+ __NAMESPACE_END_CVCAPTURE
606
+ __NAMESPACE_END_OPENCV
607
+