ruby-opencv 0.0.9-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/DEVELOPERS_NOTE.md +137 -0
  4. data/Gemfile +8 -0
  5. data/History.txt +5 -0
  6. data/License.txt +30 -0
  7. data/Manifest.txt +227 -0
  8. data/README.md +98 -0
  9. data/Rakefile +90 -0
  10. data/config.yml +7 -0
  11. data/examples/alpha_blend.rb +21 -0
  12. data/examples/box.png +0 -0
  13. data/examples/box_in_scene.png +0 -0
  14. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  15. data/examples/contours/bitmap-contours.png +0 -0
  16. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  17. data/examples/contours/contour_retrieval_modes.rb +139 -0
  18. data/examples/contours/rotated-boxes.jpg +0 -0
  19. data/examples/convexhull.rb +47 -0
  20. data/examples/face_detect.rb +20 -0
  21. data/examples/find_obj.rb +169 -0
  22. data/examples/houghcircle.rb +22 -0
  23. data/examples/inpaint.png +0 -0
  24. data/examples/inpaint.rb +57 -0
  25. data/examples/lenna-rotated.jpg +0 -0
  26. data/examples/lenna.jpg +0 -0
  27. data/examples/match_kdtree.rb +88 -0
  28. data/examples/matching_to_many_images.rb +16 -0
  29. data/examples/matching_to_many_images/query.png +0 -0
  30. data/examples/matching_to_many_images/train/1.png +0 -0
  31. data/examples/matching_to_many_images/train/2.png +0 -0
  32. data/examples/matching_to_many_images/train/3.png +0 -0
  33. data/examples/matching_to_many_images/train/trainImages.txt +3 -0
  34. data/examples/paint.rb +70 -0
  35. data/examples/snake.rb +43 -0
  36. data/examples/stuff.jpg +0 -0
  37. data/examples/tiffany.jpg +0 -0
  38. data/ext/opencv/curve.cpp +112 -0
  39. data/ext/opencv/curve.h +34 -0
  40. data/ext/opencv/cvavgcomp.cpp +67 -0
  41. data/ext/opencv/cvavgcomp.h +39 -0
  42. data/ext/opencv/cvbox2d.cpp +197 -0
  43. data/ext/opencv/cvbox2d.h +61 -0
  44. data/ext/opencv/cvcapture.cpp +506 -0
  45. data/ext/opencv/cvcapture.h +72 -0
  46. data/ext/opencv/cvchain.cpp +233 -0
  47. data/ext/opencv/cvchain.h +46 -0
  48. data/ext/opencv/cvcircle32f.cpp +116 -0
  49. data/ext/opencv/cvcircle32f.h +52 -0
  50. data/ext/opencv/cvcondensation.cpp +282 -0
  51. data/ext/opencv/cvcondensation.h +49 -0
  52. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  53. data/ext/opencv/cvconnectedcomp.h +49 -0
  54. data/ext/opencv/cvcontour.cpp +296 -0
  55. data/ext/opencv/cvcontour.h +48 -0
  56. data/ext/opencv/cvcontourtree.cpp +91 -0
  57. data/ext/opencv/cvcontourtree.h +41 -0
  58. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  59. data/ext/opencv/cvconvexitydefect.h +42 -0
  60. data/ext/opencv/cverror.cpp +159 -0
  61. data/ext/opencv/cverror.h +28 -0
  62. data/ext/opencv/cvfeaturetree.cpp +125 -0
  63. data/ext/opencv/cvfeaturetree.h +55 -0
  64. data/ext/opencv/cvfont.cpp +208 -0
  65. data/ext/opencv/cvfont.h +64 -0
  66. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  67. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  68. data/ext/opencv/cvhistogram.cpp +546 -0
  69. data/ext/opencv/cvhistogram.h +73 -0
  70. data/ext/opencv/cvhumoments.cpp +139 -0
  71. data/ext/opencv/cvhumoments.h +51 -0
  72. data/ext/opencv/cvline.cpp +154 -0
  73. data/ext/opencv/cvline.h +54 -0
  74. data/ext/opencv/cvmat.cpp +5848 -0
  75. data/ext/opencv/cvmat.h +284 -0
  76. data/ext/opencv/cvmatnd.cpp +44 -0
  77. data/ext/opencv/cvmatnd.h +28 -0
  78. data/ext/opencv/cvmemstorage.cpp +68 -0
  79. data/ext/opencv/cvmemstorage.h +53 -0
  80. data/ext/opencv/cvmoments.cpp +287 -0
  81. data/ext/opencv/cvmoments.h +75 -0
  82. data/ext/opencv/cvpoint.cpp +228 -0
  83. data/ext/opencv/cvpoint.h +64 -0
  84. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  85. data/ext/opencv/cvpoint2d32f.h +63 -0
  86. data/ext/opencv/cvpoint3d32f.cpp +245 -0
  87. data/ext/opencv/cvpoint3d32f.h +66 -0
  88. data/ext/opencv/cvrect.cpp +333 -0
  89. data/ext/opencv/cvrect.h +79 -0
  90. data/ext/opencv/cvscalar.cpp +236 -0
  91. data/ext/opencv/cvscalar.h +71 -0
  92. data/ext/opencv/cvseq.cpp +599 -0
  93. data/ext/opencv/cvseq.h +74 -0
  94. data/ext/opencv/cvsize.cpp +221 -0
  95. data/ext/opencv/cvsize.h +65 -0
  96. data/ext/opencv/cvsize2d32f.cpp +209 -0
  97. data/ext/opencv/cvsize2d32f.h +64 -0
  98. data/ext/opencv/cvslice.cpp +120 -0
  99. data/ext/opencv/cvslice.h +61 -0
  100. data/ext/opencv/cvsparsemat.cpp +44 -0
  101. data/ext/opencv/cvsparsemat.h +28 -0
  102. data/ext/opencv/cvsurfparams.cpp +199 -0
  103. data/ext/opencv/cvsurfparams.h +58 -0
  104. data/ext/opencv/cvsurfpoint.cpp +223 -0
  105. data/ext/opencv/cvsurfpoint.h +52 -0
  106. data/ext/opencv/cvtermcriteria.cpp +192 -0
  107. data/ext/opencv/cvtermcriteria.h +71 -0
  108. data/ext/opencv/cvtwopoints.cpp +116 -0
  109. data/ext/opencv/cvtwopoints.h +51 -0
  110. data/ext/opencv/cvutils.cpp +192 -0
  111. data/ext/opencv/cvutils.h +30 -0
  112. data/ext/opencv/cvvideowriter.cpp +137 -0
  113. data/ext/opencv/cvvideowriter.h +43 -0
  114. data/ext/opencv/extconf.rb +83 -0
  115. data/ext/opencv/gui.cpp +68 -0
  116. data/ext/opencv/gui.h +30 -0
  117. data/ext/opencv/iplconvkernel.cpp +192 -0
  118. data/ext/opencv/iplconvkernel.h +71 -0
  119. data/ext/opencv/iplimage.cpp +644 -0
  120. data/ext/opencv/iplimage.h +73 -0
  121. data/ext/opencv/mouseevent.cpp +181 -0
  122. data/ext/opencv/mouseevent.h +56 -0
  123. data/ext/opencv/opencv.cpp +722 -0
  124. data/ext/opencv/opencv.h +400 -0
  125. data/ext/opencv/pointset.cpp +274 -0
  126. data/ext/opencv/pointset.h +68 -0
  127. data/ext/opencv/trackbar.cpp +121 -0
  128. data/ext/opencv/trackbar.h +69 -0
  129. data/ext/opencv/window.cpp +357 -0
  130. data/ext/opencv/window.h +66 -0
  131. data/images/CvMat_sobel.png +0 -0
  132. data/images/CvMat_sub_rect.png +0 -0
  133. data/images/CvSeq_relationmap.png +0 -0
  134. data/images/face_detect_from_lena.jpg +0 -0
  135. data/lib/opencv.rb +12 -0
  136. data/lib/opencv/psyched_yaml.rb +22 -0
  137. data/lib/opencv/version.rb +3 -0
  138. data/ruby-opencv.gemspec +44 -0
  139. data/test/helper.rb +166 -0
  140. data/test/runner.rb +30 -0
  141. data/test/samples/airplane.jpg +0 -0
  142. data/test/samples/baboon.jpg +0 -0
  143. data/test/samples/baboon200.jpg +0 -0
  144. data/test/samples/baboon200_rotated.jpg +0 -0
  145. data/test/samples/blank0.jpg +0 -0
  146. data/test/samples/blank1.jpg +0 -0
  147. data/test/samples/blank2.jpg +0 -0
  148. data/test/samples/blank3.jpg +0 -0
  149. data/test/samples/blank4.jpg +0 -0
  150. data/test/samples/blank5.jpg +0 -0
  151. data/test/samples/blank6.jpg +0 -0
  152. data/test/samples/blank7.jpg +0 -0
  153. data/test/samples/blank8.jpg +0 -0
  154. data/test/samples/blank9.jpg +0 -0
  155. data/test/samples/cat.jpg +0 -0
  156. data/test/samples/chessboard.jpg +0 -0
  157. data/test/samples/contours.jpg +0 -0
  158. data/test/samples/fruits.jpg +0 -0
  159. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  160. data/test/samples/inpaint-mask.bmp +0 -0
  161. data/test/samples/lena-256x256.jpg +0 -0
  162. data/test/samples/lena-32x32.jpg +0 -0
  163. data/test/samples/lena-eyes.jpg +0 -0
  164. data/test/samples/lena-inpaint.jpg +0 -0
  165. data/test/samples/lena.jpg +0 -0
  166. data/test/samples/lines.jpg +0 -0
  167. data/test/samples/messy0.jpg +0 -0
  168. data/test/samples/messy1.jpg +0 -0
  169. data/test/samples/movie_sample.avi +0 -0
  170. data/test/samples/one_way_train_0000.jpg +0 -0
  171. data/test/samples/one_way_train_0001.jpg +0 -0
  172. data/test/samples/partially_blank0.jpg +0 -0
  173. data/test/samples/partially_blank1.jpg +0 -0
  174. data/test/samples/smooth0.jpg +0 -0
  175. data/test/samples/smooth1.jpg +0 -0
  176. data/test/samples/smooth2.jpg +0 -0
  177. data/test/samples/smooth3.jpg +0 -0
  178. data/test/samples/smooth4.jpg +0 -0
  179. data/test/samples/smooth5.jpg +0 -0
  180. data/test/samples/smooth6.jpg +0 -0
  181. data/test/samples/str-cv-rotated.jpg +0 -0
  182. data/test/samples/str-cv.jpg +0 -0
  183. data/test/samples/str-ov.jpg +0 -0
  184. data/test/samples/stuff.jpg +0 -0
  185. data/test/test_curve.rb +43 -0
  186. data/test/test_cvavgcomp.rb +24 -0
  187. data/test/test_cvbox2d.rb +76 -0
  188. data/test/test_cvcapture.rb +183 -0
  189. data/test/test_cvchain.rb +108 -0
  190. data/test/test_cvcircle32f.rb +41 -0
  191. data/test/test_cvconnectedcomp.rb +61 -0
  192. data/test/test_cvcontour.rb +150 -0
  193. data/test/test_cvcontourtree.rb +43 -0
  194. data/test/test_cverror.rb +50 -0
  195. data/test/test_cvfeaturetree.rb +65 -0
  196. data/test/test_cvfont.rb +58 -0
  197. data/test/test_cvhaarclassifiercascade.rb +63 -0
  198. data/test/test_cvhistogram.rb +271 -0
  199. data/test/test_cvhumoments.rb +83 -0
  200. data/test/test_cvline.rb +50 -0
  201. data/test/test_cvmat.rb +2947 -0
  202. data/test/test_cvmat_drawing.rb +349 -0
  203. data/test/test_cvmat_dxt.rb +150 -0
  204. data/test/test_cvmat_imageprocessing.rb +2025 -0
  205. data/test/test_cvmat_matching.rb +57 -0
  206. data/test/test_cvmoments.rb +180 -0
  207. data/test/test_cvpoint.rb +75 -0
  208. data/test/test_cvpoint2d32f.rb +75 -0
  209. data/test/test_cvpoint3d32f.rb +93 -0
  210. data/test/test_cvrect.rb +144 -0
  211. data/test/test_cvscalar.rb +113 -0
  212. data/test/test_cvseq.rb +295 -0
  213. data/test/test_cvsize.rb +75 -0
  214. data/test/test_cvsize2d32f.rb +75 -0
  215. data/test/test_cvslice.rb +31 -0
  216. data/test/test_cvsurfparams.rb +57 -0
  217. data/test/test_cvsurfpoint.rb +66 -0
  218. data/test/test_cvtermcriteria.rb +56 -0
  219. data/test/test_cvtwopoints.rb +40 -0
  220. data/test/test_cvvideowriter.rb +58 -0
  221. data/test/test_iplconvkernel.rb +54 -0
  222. data/test/test_iplimage.rb +236 -0
  223. data/test/test_mouseevent.rb +17 -0
  224. data/test/test_opencv.rb +324 -0
  225. data/test/test_pointset.rb +126 -0
  226. data/test/test_preliminary.rb +130 -0
  227. data/test/test_trackbar.rb +47 -0
  228. data/test/test_window.rb +115 -0
  229. metadata +386 -0
@@ -0,0 +1,73 @@
1
+ /************************************************************
2
+
3
+ iplimage.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_IPLIMAGE_H
11
+ #define RUBY_OPENCV_IPLIMAGE_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_IPLIMAGE namespace cIplImage {
16
+ #define __NAMESPACE_END_IPLIMAGE }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_IPLIMAGE
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
+
28
+ VALUE rb_load_image(int argc, VALUE *argv, VALUE self);
29
+ VALUE rb_decode_image(int argc, VALUE *argv, VALUE self);
30
+
31
+ VALUE rb_color_model(VALUE self);
32
+
33
+ VALUE rb_get_roi(VALUE self);
34
+ VALUE rb_set_roi(VALUE self, VALUE roi);
35
+ VALUE rb_reset_roi(VALUE self);
36
+
37
+ VALUE rb_get_coi(VALUE self);
38
+ VALUE rb_set_coi(VALUE self, VALUE coi);
39
+ VALUE rb_reset_coi(VALUE self);
40
+
41
+ VALUE rb_pyr_segmentation(VALUE self, VALUE level, VALUE threshold1, VALUE threshold2);
42
+
43
+ VALUE rb_smoothness(int argc, VALUE *argv, VALUE self);
44
+ typedef enum { SMOOTH = 1, BLANK = 2, MESSY = 3 } Smoothness;
45
+ Smoothness compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, const double blankDensity, const double messyDensity, const double highFreqRatio, double &outLowDensity, double &outHighDensity);
46
+ void cvShiftDFT(CvArr *src_arr, CvArr *dst_arr );
47
+ IplImage* create_fourier_image(const IplImage *im);
48
+ IplImage* create_frequency_filtered_image(const IplImage *pImage, int low, int high);
49
+ void high_pass_range(const IplImage *pImage, float lostPercentage, int &outLow, int &outHigh);
50
+
51
+ VALUE new_object(int width, int height, int type);
52
+ VALUE new_object(CvSize size, int type);
53
+ __NAMESPACE_END_IPLIMAGE
54
+
55
+ inline IplImage*
56
+ IPLIMAGE(VALUE object)
57
+ {
58
+ IplImage *ptr, stub;
59
+ Data_Get_Struct(object, IplImage, ptr);
60
+ return cvGetImage(ptr, &stub);
61
+ }
62
+
63
+ inline IplImage*
64
+ IPLIMAGE_WITH_CHECK(VALUE object)
65
+ {
66
+ if (!rb_obj_is_kind_of(object, cIplImage::rb_class()))
67
+ raise_typeerror(object, cIplImage::rb_class());
68
+ return IPLIMAGE(object);
69
+ }
70
+
71
+ __NAMESPACE_END_OPENCV
72
+
73
+ #endif // RUBY_OPENCV_IPLIMAGE_H
@@ -0,0 +1,181 @@
1
+ /************************************************************
2
+
3
+ mouseevent.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "mouseevent.h"
11
+ /*
12
+ * Document-module: OpenCV::GUI::MouseEvent
13
+ *
14
+ * MouseEvent object.
15
+ * have
16
+ * see OpenCV::GUI::Window#set_mouse_callback.
17
+ */
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_GUI
20
+ __NAMESPACE_BEGIN_MOUSEEVENT
21
+
22
+ VALUE rb_klass;
23
+
24
+ VALUE
25
+ rb_class()
26
+ {
27
+ return rb_klass;
28
+ }
29
+
30
+ void
31
+ define_ruby_class()
32
+ {
33
+ if (rb_klass)
34
+ return;
35
+ /*
36
+ * opencv = rb_define_module("OpenCV");
37
+ * GUI = rb_define_module_under(opencv, "GUI");
38
+ * cvpoint = rb_define_class_under(opencv, "CvPoint", rb_cObject);
39
+ */
40
+ VALUE GUI = rb_module_GUI();
41
+ VALUE cvpoint = cCvPoint::rb_class();
42
+ rb_klass = rb_define_class_under(GUI, "MouseEvent", cvpoint);
43
+ rb_define_alloc_func(rb_klass, rb_allocate);
44
+ rb_define_method(rb_klass, "event", RUBY_METHOD_FUNC(rb_event), 0);
45
+ rb_define_method(rb_klass, "left_button?", RUBY_METHOD_FUNC(rb_left_button_q), 0);
46
+ rb_define_method(rb_klass, "right_button?", RUBY_METHOD_FUNC(rb_right_button_q), 0);
47
+ rb_define_method(rb_klass, "middle_button?", RUBY_METHOD_FUNC(rb_middle_button_q), 0);
48
+ rb_define_method(rb_klass, "ctrl_key?", RUBY_METHOD_FUNC(rb_ctrl_key_q), 0);
49
+ rb_define_method(rb_klass, "shift_key?", RUBY_METHOD_FUNC(rb_shift_key_q), 0);
50
+ rb_define_method(rb_klass, "alt_key?", RUBY_METHOD_FUNC(rb_alt_key_q), 0);
51
+ }
52
+
53
+ VALUE
54
+ rb_allocate(VALUE klass)
55
+ {
56
+ MouseEvent *ptr;
57
+ return Data_Make_Struct(klass, MouseEvent, 0, 0, ptr);
58
+ }
59
+
60
+ /*
61
+ * call-seq:
62
+ * event -> symbol
63
+ *
64
+ * Return Symbol about mouse event.
65
+ *
66
+ * Currently, return these symbol:
67
+ * :move
68
+ * When mouse move.
69
+ * :right_button_down
70
+ * When mouse right button down.
71
+ * :left_button_down
72
+ * When mosue left button down.
73
+ * :middle_button_down
74
+ * When mosue middle button down.
75
+ * :left_button_up
76
+ * When mouse left button down.
77
+ * :right_button_up
78
+ * When mouse right button down.
79
+ * :middle_button_up
80
+ * When mouse middle button down.
81
+ *
82
+ * note: original OpenCV define "double-click" event(e.g. CV_EVENT_LBUTTONDBLCLK).
83
+ * But never call these event. Is it bug?
84
+ */
85
+ VALUE rb_event(VALUE self)
86
+ {
87
+ switch(MOUSEEVENT(self)->event) {
88
+ case CV_EVENT_MOUSEMOVE:
89
+ return ID2SYM(rb_intern("move"));
90
+ case CV_EVENT_LBUTTONDOWN:
91
+ return ID2SYM(rb_intern("left_button_down"));
92
+ case CV_EVENT_RBUTTONDOWN:
93
+ return ID2SYM(rb_intern("right_button_down"));
94
+ case CV_EVENT_MBUTTONDOWN:
95
+ return ID2SYM(rb_intern("middle_button_down"));
96
+ case CV_EVENT_LBUTTONUP:
97
+ return ID2SYM(rb_intern("left_button_up"));
98
+ case CV_EVENT_RBUTTONUP:
99
+ return ID2SYM(rb_intern("right_button_up"));
100
+ case CV_EVENT_MBUTTONUP:
101
+ return ID2SYM(rb_intern("middle_button_up"));
102
+ case CV_EVENT_LBUTTONDBLCLK:
103
+ return ID2SYM(rb_intern("left_button_double_click"));
104
+ case CV_EVENT_RBUTTONDBLCLK:
105
+ return ID2SYM(rb_intern("right_button_double_click"));
106
+ case CV_EVENT_MBUTTONDBLCLK:
107
+ return ID2SYM(rb_intern("middle_button_double_click"));
108
+ }
109
+ return Qnil;
110
+ }
111
+
112
+ /*
113
+ * Return true when mouse left button is pushed. Otherwise return false.
114
+ */
115
+ VALUE
116
+ rb_left_button_q(VALUE self)
117
+ {
118
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_LBUTTON ? Qtrue : Qfalse;
119
+ }
120
+
121
+ /*
122
+ * Return true when mouse right button is pushed. Otherwise return false.
123
+ */
124
+ VALUE
125
+ rb_right_button_q(VALUE self)
126
+ {
127
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_RBUTTON ? Qtrue : Qfalse;
128
+ }
129
+
130
+ /*
131
+ * Return true when mouse middle button is pushed. Otherwise return false.
132
+ */
133
+ VALUE
134
+ rb_middle_button_q(VALUE self)
135
+ {
136
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_MBUTTON ? Qtrue : Qfalse;
137
+ }
138
+
139
+ /*
140
+ * Return true when CTRL key is pushed. Otherwise return false.
141
+ */
142
+ VALUE
143
+ rb_ctrl_key_q(VALUE self)
144
+ {
145
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_CTRLKEY ? Qtrue : Qfalse;
146
+ }
147
+
148
+ /*
149
+ * Return true when shift key is pushed. Otherwise return false.
150
+ */
151
+ VALUE
152
+ rb_shift_key_q(VALUE self)
153
+ {
154
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_SHIFTKEY ? Qtrue : Qfalse;
155
+ }
156
+
157
+ /*
158
+ * Return true when ALT key is pushed. Otherwise return false.
159
+ */
160
+ VALUE
161
+ rb_alt_key_q(VALUE self)
162
+ {
163
+ return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_ALTKEY ? Qtrue : Qfalse;
164
+ }
165
+
166
+ VALUE
167
+ new_object(int event, int x, int y, int flags)
168
+ {
169
+ VALUE object = rb_allocate(rb_class());
170
+ MouseEvent *mouseevent = MOUSEEVENT(object);
171
+ mouseevent->point.x = x;
172
+ mouseevent->point.y = y;
173
+ mouseevent->event = event;
174
+ mouseevent->flags = flags;
175
+ return object;
176
+ }
177
+
178
+ __NAMESPACE_END_MOUSEEVENT
179
+ __NAMESPACE_END_GUI
180
+ __NAMESPACE_END_OPENCV
181
+
@@ -0,0 +1,56 @@
1
+ /************************************************************
2
+
3
+ mouseevent.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #define __NAMESPACE_BEGIN_MOUSEEVENT namespace cMouseEvent {
11
+ #define __NAMESPACE_END_MOUSEEVENT }
12
+
13
+ #ifndef RUBY_OPENCV_GUI_MOUSEEVENT_H
14
+ #define RUBY_OPENCV_GUI_MOUSEEVENT_H
15
+
16
+ #include "opencv.h"
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_GUI
20
+ __NAMESPACE_BEGIN_MOUSEEVENT
21
+
22
+ typedef struct MouseEvent {
23
+ CvPoint point;
24
+ int event;
25
+ int flags;
26
+ } MouseEvent;
27
+
28
+ VALUE rb_class();
29
+
30
+ void define_ruby_class();
31
+
32
+ VALUE rb_allocate(VALUE klass);
33
+
34
+ VALUE rb_event(VALUE self);
35
+
36
+ VALUE rb_left_button_q(VALUE self);
37
+ VALUE rb_right_button_q(VALUE self);
38
+ VALUE rb_middle_button_q(VALUE self);
39
+ VALUE rb_ctrl_key_q(VALUE self);
40
+ VALUE rb_shift_key_q(VALUE self);
41
+ VALUE rb_alt_key_q(VALUE self);
42
+
43
+ VALUE new_object(int event, int x, int y, int flag);
44
+
45
+ inline MouseEvent *MOUSEEVENT(VALUE object) {
46
+ MouseEvent *ptr;
47
+ Data_Get_Struct(object, MouseEvent, ptr);
48
+ return ptr;
49
+ }
50
+
51
+ __NAMESPACE_END_MOUSEEVENT
52
+ __NAMESPACE_END_GUI
53
+ __NAMESPACE_END_OPENCV
54
+
55
+ #endif // RUBY_OPENCV_GUI_MOUSEEVENT_H
56
+
@@ -0,0 +1,722 @@
1
+ /************************************************************
2
+
3
+ opencv.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2008 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ /*
11
+ * Document-module: OpenCV
12
+ *
13
+ * =What is OpenCV?
14
+ *
15
+ * OpenCV is "Open Source Computer Vision Library".
16
+ * OpenCV is developed by Intel and many opensource developers.
17
+ * This library include many useful function for computer vision, such as object-detection.
18
+ *
19
+ * OpenCV is developed at
20
+ * sourceforge.net[http://sourceforge.net/projects/opencvlibrary]
21
+ *
22
+ * =What is Ruby/OpenCV?
23
+ * Ruby/OpenCV is manual Wrapper of OpenCV (not use SWIG).
24
+ * This library seem to be *Ruby*.
25
+ * * object-oriented
26
+ * * support Garbage Collection by Ruby
27
+ * Ruby/OpenCV is developed
28
+ * http://rubyforge.org/projects/opencv (Official)
29
+ * and
30
+ * http://blueruby.mydns.jp/pages/opencv (Japanese)
31
+ *
32
+ * =How to install
33
+ *
34
+ * Show INSTALL
35
+ *
36
+ * =How to generate this documentation?
37
+ * This document created by rdoc.
38
+ * If you have Ruby 1.8 or later, you might use rdoc command.
39
+ * for example
40
+ * > cd opencv
41
+ * > rdoc
42
+ * and show "./doc/index.html"
43
+ */
44
+ #include "opencv.h"
45
+
46
+ __NAMESPACE_BEGIN_OPENCV
47
+
48
+
49
+ /*
50
+ * Hashtable for protect from GC
51
+ */
52
+ st_table *root_table = st_init_numtable();
53
+
54
+ /*
55
+ * Mark root object. (protect from GC)
56
+ */
57
+ void
58
+ mark_root_object(void *ptr)
59
+ {
60
+ VALUE value;
61
+ if (ptr && st_lookup(root_table, (st_data_t)ptr, (st_data_t*)&value)) {
62
+ rb_gc_mark(value);
63
+ }
64
+ }
65
+
66
+ /*
67
+ * Look-up Root root object.
68
+ */
69
+ VALUE
70
+ lookup_root_object(void *ptr)
71
+ {
72
+ VALUE value = 0;
73
+ if (ptr)
74
+ st_lookup(root_table, (st_data_t)ptr, (st_data_t*)&value);
75
+ return value;
76
+ }
77
+
78
+ /*
79
+ * Register root object.
80
+ */
81
+ void
82
+ register_root_object(void *ptr, VALUE root)
83
+ {
84
+ st_insert(root_table, (st_data_t)ptr, (st_data_t)root);
85
+ }
86
+
87
+ /*
88
+ * Delete mark symbol from hashtable only, not free memory.
89
+ */
90
+ void
91
+ unregister_object(void *ptr)
92
+ {
93
+ st_delete(root_table, (st_data_t*)&ptr, 0);
94
+ }
95
+
96
+ /*
97
+ * Delete mark symbol from hash table, then free memory.
98
+ */
99
+ void
100
+ free_object(void *ptr)
101
+ {
102
+ if (ptr) {
103
+ unregister_object(ptr);
104
+ try {
105
+ cvFree(&ptr);
106
+ }
107
+ catch (cv::Exception& e) {
108
+ raise_cverror(e);
109
+ }
110
+ }
111
+ }
112
+
113
+ /*
114
+ * Release OpenCV specific structure(i.e CvMat, IplImage..) from memory and delete from hashtable.
115
+ */
116
+ void
117
+ release_object(void *ptr)
118
+ {
119
+ if (ptr) {
120
+ unregister_object(ptr);
121
+ try {
122
+ cvRelease(&ptr);
123
+ }
124
+ catch (cv::Exception& e) {
125
+ raise_cverror(e);
126
+ }
127
+ }
128
+ }
129
+
130
+ /*
131
+ * Release IplConvKernel object from memory and delete from hashtable.
132
+ */
133
+ void
134
+ release_iplconvkernel_object(void *ptr)
135
+ {
136
+ if (ptr) {
137
+ unregister_object(ptr);
138
+ try {
139
+ cvReleaseStructuringElement((IplConvKernel**)(&ptr));
140
+ }
141
+ catch (cv::Exception& e) {
142
+ raise_cverror(e);
143
+ }
144
+ }
145
+ }
146
+
147
+ VALUE rb_module;
148
+ VALUE rb_opencv_constants;
149
+
150
+ VALUE
151
+ rb_module_opencv()
152
+ {
153
+ return rb_module;
154
+ }
155
+
156
+ void
157
+ define_ruby_module()
158
+ {
159
+ if (rb_module)
160
+ return;
161
+ rb_module = rb_define_module("OpenCV");
162
+
163
+ /* OpenCV version */
164
+ rb_define_const(rb_module, "CV_VERSION", rb_str_new2(CV_VERSION));
165
+ rb_define_const(rb_module, "CV_MAJOR_VERSION", INT2FIX(CV_MAJOR_VERSION));
166
+ rb_define_const(rb_module, "CV_MINOR_VERSION", INT2FIX(CV_MINOR_VERSION));
167
+ rb_define_const(rb_module, "CV_SUBMINOR_VERSION", INT2FIX(CV_SUBMINOR_VERSION));
168
+
169
+ /* 0: 8bit unsigned */
170
+ rb_define_const(rb_module, "CV_8U", INT2FIX(CV_8U));
171
+ /* 1: 8bit signed */
172
+ rb_define_const(rb_module, "CV_8S", INT2FIX(CV_8S));
173
+ /* 2: 16bit unsigned */
174
+ rb_define_const(rb_module, "CV_16U", INT2FIX(CV_16U));
175
+ /* 3: 16bit signed */
176
+ rb_define_const(rb_module, "CV_16S", INT2FIX(CV_16S));
177
+ /* 4: 32bit signed */
178
+ rb_define_const(rb_module, "CV_32S", INT2FIX(CV_32S));
179
+ /* 5: 32bit floating-point */
180
+ rb_define_const(rb_module, "CV_32F", INT2FIX(CV_32F));
181
+ /* 6: 64bit floating-point */
182
+ rb_define_const(rb_module, "CV_64F", INT2FIX(CV_64F));
183
+
184
+ /* Color types of loaded images */
185
+ rb_define_const(rb_module, "CV_LOAD_IMAGE_UNCHANGED", INT2FIX(CV_LOAD_IMAGE_UNCHANGED));
186
+ rb_define_const(rb_module, "CV_LOAD_IMAGE_GRAYSCALE", INT2FIX(CV_LOAD_IMAGE_GRAYSCALE));
187
+ rb_define_const(rb_module, "CV_LOAD_IMAGE_COLOR", INT2FIX(CV_LOAD_IMAGE_COLOR));
188
+ rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYDEPTH", INT2FIX(CV_LOAD_IMAGE_ANYDEPTH));
189
+ rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYCOLOR", INT2FIX(CV_LOAD_IMAGE_ANYCOLOR));
190
+
191
+ /* Format-specific save parameters */
192
+ rb_define_const(rb_module, "CV_IMWRITE_JPEG_QUALITY", INT2FIX(CV_IMWRITE_JPEG_QUALITY));
193
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_COMPRESSION", INT2FIX(CV_IMWRITE_PNG_COMPRESSION));
194
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY", INT2FIX(CV_IMWRITE_PNG_STRATEGY));
195
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_DEFAULT", INT2FIX(CV_IMWRITE_PNG_STRATEGY_DEFAULT));
196
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_FILTERED", INT2FIX(CV_IMWRITE_PNG_STRATEGY_FILTERED));
197
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY", INT2FIX(CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY));
198
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_RLE", INT2FIX(CV_IMWRITE_PNG_STRATEGY_RLE));
199
+ rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_FIXED", INT2FIX(CV_IMWRITE_PNG_STRATEGY_FIXED));
200
+ rb_define_const(rb_module, "CV_IMWRITE_PXM_BINARY", INT2FIX(CV_IMWRITE_PXM_BINARY));
201
+
202
+ /* Types of morphological operations */
203
+ rb_define_const(rb_module, "CV_MOP_OPEN", INT2FIX(CV_MOP_OPEN));
204
+ rb_define_const(rb_module, "CV_MOP_CLOSE", INT2FIX(CV_MOP_CLOSE));
205
+ rb_define_const(rb_module, "CV_MOP_GRADIENT", INT2FIX(CV_MOP_GRADIENT));
206
+ rb_define_const(rb_module, "CV_MOP_TOPHAT", INT2FIX(CV_MOP_TOPHAT));
207
+ rb_define_const(rb_module, "CV_MOP_BLACKHAT", INT2FIX(CV_MOP_BLACKHAT));
208
+
209
+ /* Shape of the structuring elements */
210
+ rb_define_const(rb_module, "CV_SHAPE_RECT", INT2FIX(CV_SHAPE_RECT));
211
+ rb_define_const(rb_module, "CV_SHAPE_CROSS", INT2FIX(CV_SHAPE_CROSS));
212
+ rb_define_const(rb_module, "CV_SHAPE_ELLIPSE", INT2FIX(CV_SHAPE_ELLIPSE));
213
+ rb_define_const(rb_module, "CV_SHAPE_CUSTOM", INT2FIX(CV_SHAPE_CUSTOM));
214
+
215
+ /* Types of the smoothing */
216
+ rb_define_const(rb_module, "CV_BLUR_NO_SCALE", INT2FIX(CV_BLUR_NO_SCALE));
217
+ rb_define_const(rb_module, "CV_BLUR", INT2FIX(CV_BLUR));
218
+ rb_define_const(rb_module, "CV_GAUSSIAN", INT2FIX(CV_GAUSSIAN));
219
+ rb_define_const(rb_module, "CV_MEDIAN", INT2FIX(CV_MEDIAN));
220
+ rb_define_const(rb_module, "CV_BILATERAL", INT2FIX(CV_BILATERAL));
221
+
222
+ /* Thresholding types */
223
+ rb_define_const(rb_module, "CV_THRESH_BINARY", INT2FIX(CV_THRESH_BINARY));
224
+ rb_define_const(rb_module, "CV_THRESH_BINARY_INV", INT2FIX(CV_THRESH_BINARY_INV));
225
+ rb_define_const(rb_module, "CV_THRESH_TRUNC", INT2FIX(CV_THRESH_TRUNC));
226
+ rb_define_const(rb_module, "CV_THRESH_TOZERO", INT2FIX(CV_THRESH_TOZERO));
227
+ rb_define_const(rb_module, "CV_THRESH_TOZERO_INV", INT2FIX(CV_THRESH_TOZERO_INV));
228
+ rb_define_const(rb_module, "CV_THRESH_OTSU", INT2FIX(CV_THRESH_OTSU));
229
+
230
+ /* Adaptive methods */
231
+ rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_MEAN_C", INT2FIX(CV_ADAPTIVE_THRESH_MEAN_C));
232
+ rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_GAUSSIAN_C", INT2FIX(CV_ADAPTIVE_THRESH_GAUSSIAN_C));
233
+
234
+ /* Border type */
235
+ rb_define_const(rb_module, "IPL_BORDER_CONSTANT", INT2FIX(IPL_BORDER_CONSTANT));
236
+ rb_define_const(rb_module, "IPL_BORDER_REPLICATE", INT2FIX(IPL_BORDER_REPLICATE));
237
+
238
+ /* Retrieval mode */
239
+ rb_define_const(rb_module, "CV_RETR_EXTERNAL", INT2FIX(CV_RETR_EXTERNAL));
240
+ rb_define_const(rb_module, "CV_RETR_LIST", INT2FIX(CV_RETR_LIST));
241
+ rb_define_const(rb_module, "CV_RETR_CCOMP", INT2FIX(CV_RETR_CCOMP));
242
+ rb_define_const(rb_module, "CV_RETR_TREE", INT2FIX(CV_RETR_TREE));
243
+
244
+ /* Approximation method */
245
+ rb_define_const(rb_module, "CV_CHAIN_CODE", INT2FIX(CV_CHAIN_CODE));
246
+ rb_define_const(rb_module, "CV_CHAIN_APPROX_NONE", INT2FIX(CV_CHAIN_APPROX_NONE));
247
+ rb_define_const(rb_module, "CV_CHAIN_APPROX_SIMPLE", INT2FIX(CV_CHAIN_APPROX_SIMPLE));
248
+ rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_L1", INT2FIX(CV_CHAIN_APPROX_TC89_L1));
249
+ rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_KCOS", INT2FIX(CV_CHAIN_APPROX_TC89_KCOS));
250
+ rb_define_const(rb_module, "CV_LINK_RUNS", INT2FIX(CV_LINK_RUNS));
251
+
252
+ /* Termination criteria for iterative algorithms */
253
+ rb_define_const(rb_module, "CV_TERMCRIT_ITER", INT2FIX(CV_TERMCRIT_ITER));
254
+ rb_define_const(rb_module, "CV_TERMCRIT_NUMBER", INT2FIX(CV_TERMCRIT_NUMBER));
255
+ rb_define_const(rb_module, "CV_TERMCRIT_EPS", INT2FIX(CV_TERMCRIT_EPS));
256
+
257
+ /* Hough transform method */
258
+ rb_define_const(rb_module, "CV_HOUGH_STANDARD", INT2FIX(CV_HOUGH_STANDARD));
259
+ rb_define_const(rb_module, "CV_HOUGH_PROBABILISTIC", INT2FIX(CV_HOUGH_PROBABILISTIC));
260
+ rb_define_const(rb_module, "CV_HOUGH_MULTI_SCALE", INT2FIX(CV_HOUGH_MULTI_SCALE));
261
+ rb_define_const(rb_module, "CV_HOUGH_GRADIENT", INT2FIX(CV_HOUGH_GRADIENT));
262
+
263
+ /* Inpaint method */
264
+ rb_define_const(rb_module, "CV_INPAINT_NS", INT2FIX(CV_INPAINT_NS));
265
+ rb_define_const(rb_module, "CV_INPAINT_TELEA", INT2FIX(CV_INPAINT_TELEA));
266
+
267
+ /* Match template method */
268
+ rb_define_const(rb_module, "CV_TM_SQDIFF", INT2FIX(CV_TM_SQDIFF));
269
+ rb_define_const(rb_module, "CV_TM_SQDIFF_NORMED", INT2FIX(CV_TM_SQDIFF_NORMED));
270
+ rb_define_const(rb_module, "CV_TM_CCORR", INT2FIX(CV_TM_CCORR));
271
+ rb_define_const(rb_module, "CV_TM_CCORR_NORMED", INT2FIX(CV_TM_CCORR_NORMED));
272
+ rb_define_const(rb_module, "CV_TM_CCOEFF", INT2FIX(CV_TM_CCOEFF));
273
+ rb_define_const(rb_module, "CV_TM_CCOEFF_NORMED", INT2FIX(CV_TM_CCOEFF_NORMED));
274
+
275
+ /* Comparison method */
276
+ rb_define_const(rb_module, "CV_CONTOURS_MATCH_I1", INT2FIX(CV_CONTOURS_MATCH_I1));
277
+ rb_define_const(rb_module, "CV_CONTOURS_MATCH_I2", INT2FIX(CV_CONTOURS_MATCH_I2));
278
+ rb_define_const(rb_module, "CV_CONTOURS_MATCH_I3", INT2FIX(CV_CONTOURS_MATCH_I3));
279
+
280
+ /* Fundamental matrix computing methods */
281
+ rb_define_const(rb_module, "CV_FM_7POINT", INT2FIX(CV_FM_7POINT));
282
+ rb_define_const(rb_module, "CV_FM_8POINT", INT2FIX(CV_FM_8POINT));
283
+ rb_define_const(rb_module, "CV_FM_RANSAC", INT2FIX(CV_FM_RANSAC));
284
+ rb_define_const(rb_module, "CV_FM_LMEDS", INT2FIX(CV_FM_LMEDS));
285
+
286
+ /* Flags of window */
287
+ rb_define_const(rb_module, "CV_WINDOW_AUTOSIZE", INT2FIX(CV_WINDOW_AUTOSIZE));
288
+
289
+ /* Object detection mode */
290
+ rb_define_const(rb_module, "CV_HAAR_DO_CANNY_PRUNING", INT2FIX(CV_HAAR_DO_CANNY_PRUNING));
291
+
292
+ /* Interpolation methods */
293
+ rb_define_const(rb_module, "CV_INTER_NN", INT2FIX(CV_INTER_NN));
294
+ rb_define_const(rb_module, "CV_INTER_LINEAR", INT2FIX(CV_INTER_LINEAR));
295
+ rb_define_const(rb_module, "CV_INTER_AREA", INT2FIX(CV_INTER_AREA));
296
+ rb_define_const(rb_module, "CV_INTER_CUBIC", INT2FIX(CV_INTER_CUBIC));
297
+ rb_define_const(rb_module, "CV_INTER_LANCZOS4", INT2FIX(CV_INTER_LANCZOS4));
298
+
299
+ /* Warp affine optional flags */
300
+ rb_define_const(rb_module, "CV_WARP_FILL_OUTLIERS", INT2FIX(CV_WARP_FILL_OUTLIERS));
301
+ rb_define_const(rb_module, "CV_WARP_INVERSE_MAP", INT2FIX(CV_WARP_INVERSE_MAP));
302
+
303
+ /* SVD optional flags */
304
+ rb_define_const(rb_module, "CV_SVD_MODIFY_A", INT2FIX(CV_SVD_MODIFY_A));
305
+ rb_define_const(rb_module, "CV_SVD_U_T", INT2FIX(CV_SVD_U_T));
306
+ rb_define_const(rb_module, "CV_SVD_V_T", INT2FIX(CV_SVD_V_T));
307
+
308
+ /* Norm types */
309
+ rb_define_const(rb_module, "CV_NORM_INF", INT2FIX(cv::NORM_INF));
310
+ rb_define_const(rb_module, "CV_NORM_L1", INT2FIX(cv::NORM_L1));
311
+ rb_define_const(rb_module, "CV_NORM_L2", INT2FIX(cv::NORM_L2));
312
+ rb_define_const(rb_module, "CV_NORM_MINMAX", INT2FIX(cv::NORM_MINMAX));
313
+
314
+ /* Histogram representation format */
315
+ rb_define_const(rb_module, "CV_HIST_ARRAY", INT2FIX(CV_HIST_ARRAY));
316
+ rb_define_const(rb_module, "CV_HIST_SPARSE", INT2FIX(CV_HIST_SPARSE));
317
+ rb_define_const(rb_module, "CV_HIST_TREE", INT2FIX(CV_HIST_TREE));
318
+ rb_define_const(rb_module, "CV_HIST_UNIFORM", INT2FIX(CV_HIST_UNIFORM));
319
+
320
+ /* Histogram comparison method */
321
+ rb_define_const(rb_module, "CV_COMP_CORREL", INT2FIX(CV_COMP_CORREL));
322
+ rb_define_const(rb_module, "CV_COMP_CHISQR", INT2FIX(CV_COMP_CHISQR));
323
+ rb_define_const(rb_module, "CV_COMP_INTERSECT", INT2FIX(CV_COMP_INTERSECT));
324
+ rb_define_const(rb_module, "CV_COMP_BHATTACHARYYA", INT2FIX(CV_COMP_BHATTACHARYYA));
325
+
326
+ /* DFT and DCT flags */
327
+ rb_define_const(rb_module, "CV_DXT_FORWARD", INT2FIX(CV_DXT_FORWARD));
328
+ rb_define_const(rb_module, "CV_DXT_INVERSE", INT2FIX(CV_DXT_INVERSE));
329
+ rb_define_const(rb_module, "CV_DXT_SCALE", INT2FIX(CV_DXT_SCALE));
330
+ rb_define_const(rb_module, "CV_DXT_INV_SCALE", INT2FIX(CV_DXT_INV_SCALE));
331
+ rb_define_const(rb_module, "CV_DXT_INVERSE_SCALE", INT2FIX(CV_DXT_INVERSE_SCALE));
332
+ rb_define_const(rb_module, "CV_DXT_ROWS", INT2FIX(CV_DXT_ROWS));
333
+
334
+ /* FindChessboardCorners flags */
335
+ rb_define_const(rb_module, "CV_CALIB_CB_ADAPTIVE_THRESH", INT2FIX(CV_CALIB_CB_ADAPTIVE_THRESH));
336
+ rb_define_const(rb_module, "CV_CALIB_CB_NORMALIZE_IMAGE", INT2FIX(CV_CALIB_CB_NORMALIZE_IMAGE));
337
+ rb_define_const(rb_module, "CV_CALIB_CB_FILTER_QUADS", INT2FIX(CV_CALIB_CB_FILTER_QUADS));
338
+ rb_define_const(rb_module, "CV_CALIB_CB_FAST_CHECK", INT2FIX(CV_CALIB_CB_FAST_CHECK));
339
+
340
+
341
+ VALUE inversion_method = rb_hash_new();
342
+ /* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
343
+ rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
344
+ REGISTER_HASH(inversion_method, "lu", CV_LU);
345
+ REGISTER_HASH(inversion_method, "svd", CV_SVD);
346
+ REGISTER_HASH(inversion_method, "svd_sym", CV_SVD_SYM);
347
+ REGISTER_HASH(inversion_method, "svd_symmetric", CV_SVD_SYM);
348
+
349
+ VALUE homography_calc_method = rb_hash_new();
350
+ /* {:all, :ransac, :lmeds}: Methods used to computed homography matrix */
351
+ rb_define_const(rb_module, "HOMOGRAPHY_CALC_METHOD", homography_calc_method);
352
+ REGISTER_HASH(homography_calc_method, "all", 0);
353
+ REGISTER_HASH(homography_calc_method, "ransac", CV_RANSAC);
354
+ REGISTER_HASH(homography_calc_method, "lmeds", CV_LMEDS);
355
+
356
+ VALUE depth = rb_hash_new();
357
+ /* {:cv8u, :cv8s, :cv16u, :cv16s, :cv32s, :cv32f, :cv64f}: Depth of each pixel. */
358
+ rb_define_const(rb_module, "DEPTH", depth);
359
+ REGISTER_HASH(depth, "cv8u", CV_8U);
360
+ REGISTER_HASH(depth, "cv8s", CV_8S);
361
+ REGISTER_HASH(depth, "cv16u", CV_16U);
362
+ REGISTER_HASH(depth, "cv16s", CV_16S);
363
+ REGISTER_HASH(depth, "cv32s", CV_32S);
364
+ REGISTER_HASH(depth, "cv32f", CV_32F);
365
+ REGISTER_HASH(depth, "cv64f", CV_64F);
366
+
367
+ VALUE connectivity = rb_hash_new();
368
+ /* {:aa(:anti_alias)}: Determined by the closeness of pixel values */
369
+ rb_define_const(rb_module, "CONNECTIVITY", connectivity);
370
+ REGISTER_HASH(connectivity, "aa", CV_AA);
371
+ REGISTER_HASH(connectivity, "anti_alias", CV_AA);
372
+
373
+ VALUE structuring_element_shape = rb_hash_new();
374
+ /* {:rect, :cross, :ellipse, :custom}: Shape of the structuring elements */
375
+ rb_define_const(rb_module, "STRUCTURING_ELEMENT_SHAPE", structuring_element_shape);
376
+ REGISTER_HASH(structuring_element_shape, "rect", CV_SHAPE_RECT);
377
+ REGISTER_HASH(structuring_element_shape, "cross", CV_SHAPE_CROSS);
378
+ REGISTER_HASH(structuring_element_shape, "ellipse", CV_SHAPE_ELLIPSE);
379
+ REGISTER_HASH(structuring_element_shape, "custom", CV_SHAPE_CUSTOM);
380
+
381
+ VALUE retrieval_mode = rb_hash_new();
382
+ /* {:external, :list, :ccomp, :tree}: Retrieval mode */
383
+ rb_define_const(rb_module, "RETRIEVAL_MODE", retrieval_mode);
384
+ REGISTER_HASH(retrieval_mode, "external", CV_RETR_EXTERNAL);
385
+ REGISTER_HASH(retrieval_mode, "list", CV_RETR_LIST);
386
+ REGISTER_HASH(retrieval_mode, "ccomp", CV_RETR_CCOMP);
387
+ REGISTER_HASH(retrieval_mode, "tree", CV_RETR_TREE);
388
+
389
+ VALUE approx_chain_method = rb_hash_new();
390
+ /* {:code, :approx_none, :approx_simple, :apporx_tc89_11, :approx_tc89_kcos}: Approximation method */
391
+ rb_define_const(rb_module, "APPROX_CHAIN_METHOD", approx_chain_method);
392
+ REGISTER_HASH(approx_chain_method, "code", CV_CHAIN_CODE);
393
+ REGISTER_HASH(approx_chain_method, "approx_none", CV_CHAIN_APPROX_NONE);
394
+ REGISTER_HASH(approx_chain_method, "approx_simple", CV_CHAIN_APPROX_SIMPLE);
395
+ REGISTER_HASH(approx_chain_method, "approx_tc89_l1", CV_CHAIN_APPROX_TC89_L1);
396
+ REGISTER_HASH(approx_chain_method, "approx_tc89_kcos", CV_CHAIN_APPROX_TC89_KCOS);
397
+
398
+ VALUE approx_poly_method = rb_hash_new();
399
+ /* {:dp}: Approximation method (polygon) */
400
+ rb_define_const(rb_module, "APPROX_POLY_METHOD", approx_poly_method);
401
+ REGISTER_HASH(approx_poly_method, "dp", CV_POLY_APPROX_DP);
402
+
403
+ VALUE match_template_method = rb_hash_new();
404
+ /* {:sqdiff, :sqdiff_normed, :ccorr, :ccorr_normed, :ccoeff, :ccoeff_normed}: Match template method */
405
+ rb_define_const(rb_module, "MATCH_TEMPLATE_METHOD", match_template_method);
406
+ REGISTER_HASH(match_template_method, "sqdiff", CV_TM_SQDIFF);
407
+ REGISTER_HASH(match_template_method, "sqdiff_normed", CV_TM_SQDIFF_NORMED);
408
+ REGISTER_HASH(match_template_method, "ccorr", CV_TM_CCORR);
409
+ REGISTER_HASH(match_template_method, "ccorr_normed", CV_TM_CCORR_NORMED);
410
+ REGISTER_HASH(match_template_method, "ccoeff", CV_TM_CCOEFF);
411
+ REGISTER_HASH(match_template_method, "ccoeff_normed", CV_TM_CCOEFF_NORMED);
412
+
413
+ VALUE morphological_operation = rb_hash_new();
414
+ /* {:open, :close, :gradient, :tophat, :blackhat}: Types of morphological operations */
415
+ rb_define_const(rb_module, "MORPHOLOGICAL_OPERATION", morphological_operation);
416
+ REGISTER_HASH(morphological_operation, "open", CV_MOP_OPEN);
417
+ REGISTER_HASH(morphological_operation, "close", CV_MOP_CLOSE);
418
+ REGISTER_HASH(morphological_operation, "gradient", CV_MOP_GRADIENT);
419
+ REGISTER_HASH(morphological_operation, "tophat", CV_MOP_TOPHAT);
420
+ REGISTER_HASH(morphological_operation, "blackhat", CV_MOP_BLACKHAT);
421
+
422
+ VALUE smoothing_type = rb_hash_new();
423
+ /* {:blur_no_scale, :blur, :gaussian, :median, :bilateral}: Types of smoothing */
424
+ rb_define_const(rb_module, "SMOOTHING_TYPE", smoothing_type);
425
+ REGISTER_HASH(smoothing_type, "blur_no_scale", CV_BLUR_NO_SCALE);
426
+ REGISTER_HASH(smoothing_type, "blur", CV_BLUR);
427
+ REGISTER_HASH(smoothing_type, "gaussian", CV_GAUSSIAN);
428
+ REGISTER_HASH(smoothing_type, "median", CV_MEDIAN);
429
+ REGISTER_HASH(smoothing_type, "bilateral", CV_BILATERAL);
430
+
431
+ VALUE adaptive_method = rb_hash_new();
432
+ /* {:mean_c, :gaussian_c}: Adaptive thresholding algorithm */
433
+ rb_define_const(rb_module, "ADAPTIVE_METHOD", adaptive_method);
434
+ REGISTER_HASH(adaptive_method, "mean_c", CV_ADAPTIVE_THRESH_MEAN_C);
435
+ REGISTER_HASH(adaptive_method, "gaussian_c", CV_ADAPTIVE_THRESH_GAUSSIAN_C);
436
+
437
+ VALUE threshold_type = rb_hash_new();
438
+ /* {:binary, :binary_inv, :trunc, :tozero, :tozero_inv, :otsu} : Thresholding types */
439
+ rb_define_const(rb_module, "THRESHOLD_TYPE", threshold_type);
440
+ REGISTER_HASH(threshold_type, "binary", CV_THRESH_BINARY);
441
+ REGISTER_HASH(threshold_type, "binary_inv", CV_THRESH_BINARY_INV);
442
+ REGISTER_HASH(threshold_type, "trunc", CV_THRESH_TRUNC);
443
+ REGISTER_HASH(threshold_type, "tozero", CV_THRESH_TOZERO);
444
+ REGISTER_HASH(threshold_type, "tozero_inv", CV_THRESH_TOZERO_INV);
445
+ REGISTER_HASH(threshold_type, "otsu", CV_THRESH_OTSU);
446
+
447
+ VALUE hough_transform_method = rb_hash_new();
448
+ /* {:standard, :probabilistic, :multi_scale} : Hough transform method */
449
+ rb_define_const(rb_module, "HOUGH_TRANSFORM_METHOD", hough_transform_method);
450
+ REGISTER_HASH(hough_transform_method, "standard", CV_HOUGH_STANDARD);
451
+ REGISTER_HASH(hough_transform_method, "probabilistic", CV_HOUGH_PROBABILISTIC);
452
+ REGISTER_HASH(hough_transform_method, "multi_scale", CV_HOUGH_MULTI_SCALE);
453
+ REGISTER_HASH(hough_transform_method, "gradient", CV_HOUGH_GRADIENT);
454
+
455
+ VALUE inpaint_method = rb_hash_new();
456
+ /* {:ns, :telea} : Inpaint method */
457
+ rb_define_const(rb_module, "INPAINT_METHOD", inpaint_method);
458
+ REGISTER_HASH(inpaint_method, "ns", CV_INPAINT_NS);
459
+ REGISTER_HASH(inpaint_method, "telea", CV_INPAINT_TELEA);
460
+
461
+ VALUE comparison_method = rb_hash_new();
462
+ /* Comparison method */
463
+ rb_define_const(rb_module, "COMPARISON_METHOD", comparison_method);
464
+ REGISTER_HASH(comparison_method, "i1", CV_CONTOURS_MATCH_I1);
465
+ REGISTER_HASH(comparison_method, "i2", CV_CONTOURS_MATCH_I2);
466
+ REGISTER_HASH(comparison_method, "i3", CV_CONTOURS_MATCH_I3);
467
+
468
+ /* color convert methods */
469
+ rb_define_module_function(rb_module, "BGR2BGRA", RUBY_METHOD_FUNC(rb_BGR2BGRA), 1);
470
+ rb_define_module_function(rb_module, "RGB2RGBA", RUBY_METHOD_FUNC(rb_RGB2RGBA), 1);
471
+ rb_define_module_function(rb_module, "BGRA2BGR", RUBY_METHOD_FUNC(rb_BGRA2BGR), 1);
472
+ rb_define_module_function(rb_module, "RGBA2RGB", RUBY_METHOD_FUNC(rb_RGBA2RGB), 1);
473
+ rb_define_module_function(rb_module, "BGR2RGBA", RUBY_METHOD_FUNC(rb_BGR2RGBA), 1);
474
+ rb_define_module_function(rb_module, "RGB2BGRA", RUBY_METHOD_FUNC(rb_RGB2BGRA), 1);
475
+ rb_define_module_function(rb_module, "RGBA2BGR", RUBY_METHOD_FUNC(rb_RGBA2BGR), 1);
476
+ rb_define_module_function(rb_module, "BGRA2RGB", RUBY_METHOD_FUNC(rb_BGRA2RGB), 1);
477
+ rb_define_module_function(rb_module, "BGR2RGB", RUBY_METHOD_FUNC(rb_BGR2RGB), 1);
478
+ rb_define_module_function(rb_module, "RGB2BGR", RUBY_METHOD_FUNC(rb_RGB2BGR), 1);
479
+ rb_define_module_function(rb_module, "BGRA2RGBA", RUBY_METHOD_FUNC(rb_BGRA2RGBA), 1);
480
+ rb_define_module_function(rb_module, "RGBA2BGRA", RUBY_METHOD_FUNC(rb_RGBA2BGRA), 1);
481
+ rb_define_module_function(rb_module, "BGR2GRAY", RUBY_METHOD_FUNC(rb_BGR2GRAY), 1);
482
+ rb_define_module_function(rb_module, "RGB2GRAY", RUBY_METHOD_FUNC(rb_RGB2GRAY), 1);
483
+ rb_define_module_function(rb_module, "GRAY2BGR", RUBY_METHOD_FUNC(rb_GRAY2BGR), 1);
484
+ rb_define_module_function(rb_module, "GRAY2RGB", RUBY_METHOD_FUNC(rb_GRAY2RGB), 1);
485
+ rb_define_module_function(rb_module, "GRAY2BGRA", RUBY_METHOD_FUNC(rb_GRAY2BGRA), 1);
486
+ rb_define_module_function(rb_module, "GRAY2RGBA", RUBY_METHOD_FUNC(rb_GRAY2RGBA), 1);
487
+ rb_define_module_function(rb_module, "BGRA2GRAY", RUBY_METHOD_FUNC(rb_BGRA2GRAY), 1);
488
+ rb_define_module_function(rb_module, "RGBA2GRAY", RUBY_METHOD_FUNC(rb_RGBA2GRAY), 1);
489
+ rb_define_module_function(rb_module, "BGR2BGR565", RUBY_METHOD_FUNC(rb_BGR2BGR565), 1);
490
+ rb_define_module_function(rb_module, "RGB2BGR565", RUBY_METHOD_FUNC(rb_RGB2BGR565), 1);
491
+ rb_define_module_function(rb_module, "BGR5652BGR", RUBY_METHOD_FUNC(rb_BGR5652BGR), 1);
492
+ rb_define_module_function(rb_module, "BGR5652RGB", RUBY_METHOD_FUNC(rb_BGR5652RGB), 1);
493
+ rb_define_module_function(rb_module, "BGRA2BGR565", RUBY_METHOD_FUNC(rb_BGRA2BGR565), 1);
494
+ rb_define_module_function(rb_module, "RGBA2BGR565", RUBY_METHOD_FUNC(rb_RGBA2BGR565), 1);
495
+ rb_define_module_function(rb_module, "BGR5652BGRA", RUBY_METHOD_FUNC(rb_BGR5652BGRA), 1);
496
+ rb_define_module_function(rb_module, "BGR5652RGBA", RUBY_METHOD_FUNC(rb_BGR5652RGBA), 1);
497
+ rb_define_module_function(rb_module, "GRAY2BGR565", RUBY_METHOD_FUNC(rb_GRAY2BGR565), 1);
498
+ rb_define_module_function(rb_module, "BGR5652GRAY", RUBY_METHOD_FUNC(rb_BGR5652GRAY), 1);
499
+ rb_define_module_function(rb_module, "BGR2BGR555", RUBY_METHOD_FUNC(rb_BGR2BGR555), 1);
500
+ rb_define_module_function(rb_module, "RGB2BGR555", RUBY_METHOD_FUNC(rb_RGB2BGR555), 1);
501
+ rb_define_module_function(rb_module, "BGR5552BGR", RUBY_METHOD_FUNC(rb_BGR5552BGR), 1);
502
+ rb_define_module_function(rb_module, "BGR5552RGB", RUBY_METHOD_FUNC(rb_BGR5552RGB), 1);
503
+ rb_define_module_function(rb_module, "BGRA2BGR555", RUBY_METHOD_FUNC(rb_BGRA2BGR555), 1);
504
+ rb_define_module_function(rb_module, "RGBA2BGR555", RUBY_METHOD_FUNC(rb_RGBA2BGR555), 1);
505
+ rb_define_module_function(rb_module, "BGR5552BGRA", RUBY_METHOD_FUNC(rb_BGR5552BGRA), 1);
506
+ rb_define_module_function(rb_module, "BGR5552RGBA", RUBY_METHOD_FUNC(rb_BGR5552RGBA), 1);
507
+ rb_define_module_function(rb_module, "GRAY2BGR555", RUBY_METHOD_FUNC(rb_GRAY2BGR555), 1);
508
+ rb_define_module_function(rb_module, "BGR5552GRAY", RUBY_METHOD_FUNC(rb_BGR5552GRAY), 1);
509
+ rb_define_module_function(rb_module, "BGR2XYZ", RUBY_METHOD_FUNC(rb_BGR2XYZ), 1);
510
+ rb_define_module_function(rb_module, "RGB2XYZ", RUBY_METHOD_FUNC(rb_RGB2XYZ), 1);
511
+ rb_define_module_function(rb_module, "XYZ2BGR", RUBY_METHOD_FUNC(rb_XYZ2BGR), 1);
512
+ rb_define_module_function(rb_module, "XYZ2RGB", RUBY_METHOD_FUNC(rb_XYZ2RGB), 1);
513
+ rb_define_module_function(rb_module, "BGR2YCrCb", RUBY_METHOD_FUNC(rb_BGR2YCrCb), 1);
514
+ rb_define_module_function(rb_module, "RGB2YCrCb", RUBY_METHOD_FUNC(rb_RGB2YCrCb), 1);
515
+ rb_define_module_function(rb_module, "YCrCb2BGR", RUBY_METHOD_FUNC(rb_YCrCb2BGR), 1);
516
+ rb_define_module_function(rb_module, "YCrCb2RGB", RUBY_METHOD_FUNC(rb_YCrCb2RGB), 1);
517
+ rb_define_module_function(rb_module, "BGR2HSV", RUBY_METHOD_FUNC(rb_BGR2HSV), 1);
518
+ rb_define_module_function(rb_module, "RGB2HSV", RUBY_METHOD_FUNC(rb_RGB2HSV), 1);
519
+ rb_define_module_function(rb_module, "BGR2Lab", RUBY_METHOD_FUNC(rb_BGR2Lab), 1);
520
+ rb_define_module_function(rb_module, "RGB2Lab", RUBY_METHOD_FUNC(rb_RGB2Lab), 1);
521
+ rb_define_module_function(rb_module, "BayerBG2BGR", RUBY_METHOD_FUNC(rb_BayerBG2BGR), 1);
522
+ rb_define_module_function(rb_module, "BayerGB2BGR", RUBY_METHOD_FUNC(rb_BayerGB2BGR), 1);
523
+ rb_define_module_function(rb_module, "BayerRG2BGR", RUBY_METHOD_FUNC(rb_BayerRG2BGR), 1);
524
+ rb_define_module_function(rb_module, "BayerGR2BGR", RUBY_METHOD_FUNC(rb_BayerGR2BGR), 1);
525
+ rb_define_module_function(rb_module, "BayerBG2RGB", RUBY_METHOD_FUNC(rb_BayerBG2RGB), 1);
526
+ rb_define_module_function(rb_module, "BayerGB2RGB", RUBY_METHOD_FUNC(rb_BayerGB2RGB), 1);
527
+ rb_define_module_function(rb_module, "BayerRG2RGB", RUBY_METHOD_FUNC(rb_BayerRG2RGB), 1);
528
+ rb_define_module_function(rb_module, "BayerGR2RGB", RUBY_METHOD_FUNC(rb_BayerGR2RGB), 1);
529
+ rb_define_module_function(rb_module, "BGR2Luv", RUBY_METHOD_FUNC(rb_BGR2Luv), 1);
530
+ rb_define_module_function(rb_module, "RGB2Luv", RUBY_METHOD_FUNC(rb_RGB2Luv), 1);
531
+ rb_define_module_function(rb_module, "BGR2HLS", RUBY_METHOD_FUNC(rb_BGR2HLS), 1);
532
+ rb_define_module_function(rb_module, "RGB2HLS", RUBY_METHOD_FUNC(rb_RGB2HLS), 1);
533
+ rb_define_module_function(rb_module, "HSV2BGR", RUBY_METHOD_FUNC(rb_HSV2BGR), 1);
534
+ rb_define_module_function(rb_module, "HSV2RGB", RUBY_METHOD_FUNC(rb_HSV2RGB), 1);
535
+ rb_define_module_function(rb_module, "Lab2BGR", RUBY_METHOD_FUNC(rb_Lab2BGR), 1);
536
+ rb_define_module_function(rb_module, "Lab2RGB", RUBY_METHOD_FUNC(rb_Lab2RGB), 1);
537
+ rb_define_module_function(rb_module, "Luv2BGR", RUBY_METHOD_FUNC(rb_Luv2BGR), 1);
538
+ rb_define_module_function(rb_module, "Luv2RGB", RUBY_METHOD_FUNC(rb_Luv2RGB), 1);
539
+ rb_define_module_function(rb_module, "HLS2BGR", RUBY_METHOD_FUNC(rb_HLS2BGR), 1);
540
+ rb_define_module_function(rb_module, "HLS2RGB", RUBY_METHOD_FUNC(rb_HLS2RGB), 1);
541
+
542
+ rb_define_module_function(rb_module, "build_information", RUBY_METHOD_FUNC(rb_build_information), 0);
543
+ }
544
+
545
+ #define CREATE_CVTCOLOR_FUNC(rb_func_name, c_const_name, src_cn, dest_cn) \
546
+ VALUE rb_func_name(VALUE klass, VALUE image) \
547
+ { \
548
+ VALUE dest = Qnil; \
549
+ CvArr* img_ptr = CVARR(image); \
550
+ try { \
551
+ int type = cvGetElemType(img_ptr); \
552
+ if (CV_MAT_CN(type) != src_cn) \
553
+ rb_raise(rb_eArgError, "argument 1 should be %d-channel.", src_cn); \
554
+ dest = cCvMat::new_mat_kind_object(cvGetSize(img_ptr), image, CV_MAT_DEPTH(type), dest_cn); \
555
+ cvCvtColor(img_ptr, CVARR(dest), c_const_name); \
556
+ } \
557
+ catch (cv::Exception& e) { \
558
+ raise_cverror(e); \
559
+ } \
560
+ return dest; \
561
+ }
562
+
563
+ CREATE_CVTCOLOR_FUNC(rb_BGR2BGRA, CV_BGR2BGRA, 3, 4);
564
+ CREATE_CVTCOLOR_FUNC(rb_RGB2RGBA, CV_RGB2RGBA, 3, 4);
565
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR, CV_BGRA2BGR, 4, 3);
566
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2RGB, CV_RGBA2RGB, 4, 3);
567
+ CREATE_CVTCOLOR_FUNC(rb_BGR2RGBA, CV_BGR2RGBA, 3, 4);
568
+ CREATE_CVTCOLOR_FUNC(rb_RGB2BGRA, CV_RGB2BGRA, 3, 4);
569
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR, CV_RGBA2BGR, 4, 3);
570
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2RGB, CV_BGRA2RGB, 4, 3);
571
+ CREATE_CVTCOLOR_FUNC(rb_BGR2RGB, CV_BGR2RGB, 3, 3);
572
+ CREATE_CVTCOLOR_FUNC(rb_RGB2BGR, CV_RGB2BGR, 3, 3);
573
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2RGBA, CV_BGRA2RGBA, 4, 4);
574
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2BGRA, CV_RGBA2BGRA, 4, 4);
575
+ CREATE_CVTCOLOR_FUNC(rb_BGR2GRAY, CV_BGR2GRAY, 3, 1);
576
+ CREATE_CVTCOLOR_FUNC(rb_RGB2GRAY, CV_RGB2GRAY, 3, 1);
577
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR, CV_GRAY2BGR, 1, 3);
578
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2RGB, CV_GRAY2RGB, 1, 3);
579
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2BGRA, CV_GRAY2BGRA, 1, 4);
580
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2RGBA, CV_GRAY2RGBA, 1, 4);
581
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2GRAY, CV_BGRA2GRAY, 4, 1);
582
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2GRAY, CV_RGBA2GRAY, 4, 1);
583
+ CREATE_CVTCOLOR_FUNC(rb_BGR2BGR565, CV_BGR2BGR565, 3, 3);
584
+ CREATE_CVTCOLOR_FUNC(rb_RGB2BGR565, CV_RGB2BGR565, 3, 3);
585
+ CREATE_CVTCOLOR_FUNC(rb_BGR5652BGR, CV_BGR5652BGR, 3, 3);
586
+ CREATE_CVTCOLOR_FUNC(rb_BGR5652RGB, CV_BGR5652RGB, 3, 3);
587
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR565, CV_BGRA2BGR565, 4, 3);
588
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR565, CV_RGBA2BGR565, 4, 3);
589
+ CREATE_CVTCOLOR_FUNC(rb_BGR5652BGRA, CV_BGR5652BGRA, 3, 4);
590
+ CREATE_CVTCOLOR_FUNC(rb_BGR5652RGBA, CV_BGR5652RGBA, 3, 4);
591
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR565, CV_GRAY2BGR565, 1, 3);
592
+ CREATE_CVTCOLOR_FUNC(rb_BGR5652GRAY, CV_BGR5652GRAY, 3, 1);
593
+ CREATE_CVTCOLOR_FUNC(rb_BGR2BGR555, CV_BGR2BGR555, 3, 3);
594
+ CREATE_CVTCOLOR_FUNC(rb_RGB2BGR555, CV_RGB2BGR555, 3, 3);
595
+ CREATE_CVTCOLOR_FUNC(rb_BGR5552BGR, CV_BGR5552BGR, 3, 3);
596
+ CREATE_CVTCOLOR_FUNC(rb_BGR5552RGB, CV_BGR5552RGB, 3, 3);
597
+ CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR555, CV_BGRA2BGR555, 4, 3);
598
+ CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR555, CV_RGBA2BGR555, 4, 3);
599
+ CREATE_CVTCOLOR_FUNC(rb_BGR5552BGRA, CV_BGR5552BGRA, 3, 4);
600
+ CREATE_CVTCOLOR_FUNC(rb_BGR5552RGBA, CV_BGR5552RGBA, 3, 4);
601
+ CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR555, CV_GRAY2BGR555, 1, 3);
602
+ CREATE_CVTCOLOR_FUNC(rb_BGR5552GRAY, CV_BGR5552GRAY, 3, 1);
603
+ CREATE_CVTCOLOR_FUNC(rb_BGR2XYZ, CV_BGR2XYZ, 3, 3);
604
+ CREATE_CVTCOLOR_FUNC(rb_RGB2XYZ, CV_RGB2XYZ, 3, 3);
605
+ CREATE_CVTCOLOR_FUNC(rb_XYZ2BGR, CV_XYZ2BGR, 3, 3);
606
+ CREATE_CVTCOLOR_FUNC(rb_XYZ2RGB, CV_XYZ2RGB, 3, 3);
607
+ CREATE_CVTCOLOR_FUNC(rb_BGR2YCrCb, CV_BGR2YCrCb, 3, 3);
608
+ CREATE_CVTCOLOR_FUNC(rb_RGB2YCrCb, CV_RGB2YCrCb, 3, 3);
609
+ CREATE_CVTCOLOR_FUNC(rb_YCrCb2BGR, CV_YCrCb2BGR, 3, 3);
610
+ CREATE_CVTCOLOR_FUNC(rb_YCrCb2RGB, CV_YCrCb2RGB, 0, 3);
611
+ CREATE_CVTCOLOR_FUNC(rb_BGR2HSV, CV_BGR2HSV, 3, 3);
612
+ CREATE_CVTCOLOR_FUNC(rb_RGB2HSV, CV_RGB2HSV, 3, 3);
613
+ CREATE_CVTCOLOR_FUNC(rb_BGR2Lab, CV_BGR2Lab, 3, 3);
614
+ CREATE_CVTCOLOR_FUNC(rb_RGB2Lab, CV_RGB2Lab, 3, 3);
615
+ CREATE_CVTCOLOR_FUNC(rb_BayerBG2BGR, CV_BayerBG2BGR, 3, 3);
616
+ CREATE_CVTCOLOR_FUNC(rb_BayerGB2BGR, CV_BayerGB2BGR, 3, 3);
617
+ CREATE_CVTCOLOR_FUNC(rb_BayerRG2BGR, CV_BayerRG2BGR, 3, 3);
618
+ CREATE_CVTCOLOR_FUNC(rb_BayerGR2BGR, CV_BayerGR2BGR, 3, 3);
619
+ CREATE_CVTCOLOR_FUNC(rb_BayerBG2RGB, CV_BayerBG2RGB, 3, 3);
620
+ CREATE_CVTCOLOR_FUNC(rb_BayerGB2RGB, CV_BayerGB2RGB, 3, 3);
621
+ CREATE_CVTCOLOR_FUNC(rb_BayerRG2RGB, CV_BayerRG2RGB, 3, 3);
622
+ CREATE_CVTCOLOR_FUNC(rb_BayerGR2RGB, CV_BayerGR2RGB, 3, 3);
623
+ CREATE_CVTCOLOR_FUNC(rb_BGR2Luv, CV_BGR2Luv, 3, 3);
624
+ CREATE_CVTCOLOR_FUNC(rb_RGB2Luv, CV_RGB2Luv, 3, 3);
625
+ CREATE_CVTCOLOR_FUNC(rb_BGR2HLS, CV_BGR2HLS, 3, 3);
626
+ CREATE_CVTCOLOR_FUNC(rb_RGB2HLS, CV_RGB2HLS, 3, 3);
627
+ CREATE_CVTCOLOR_FUNC(rb_HSV2BGR, CV_HSV2BGR, 3, 3);
628
+ CREATE_CVTCOLOR_FUNC(rb_HSV2RGB, CV_HSV2RGB, 3, 3);
629
+ CREATE_CVTCOLOR_FUNC(rb_Lab2BGR, CV_Lab2BGR, 3, 3);
630
+ CREATE_CVTCOLOR_FUNC(rb_Lab2RGB, CV_Lab2RGB, 3, 3);
631
+ CREATE_CVTCOLOR_FUNC(rb_Luv2BGR, CV_Luv2BGR, 3, 3);
632
+ CREATE_CVTCOLOR_FUNC(rb_Luv2RGB, CV_Luv2RGB, 3, 3);
633
+ CREATE_CVTCOLOR_FUNC(rb_HLS2BGR, CV_HLS2BGR, 3, 3);
634
+ CREATE_CVTCOLOR_FUNC(rb_HLS2RGB, CV_HLS2RGB, 3, 3);
635
+
636
+ VALUE
637
+ rb_build_information(VALUE klass)
638
+ {
639
+ const char* ptr = cv::getBuildInformation().c_str();
640
+ return rb_str_new(ptr, strlen(ptr));
641
+ }
642
+
643
+
644
+ int
645
+ error_callback(int status, const char *function_name, const char *error_message,
646
+ const char *file_name, int line, void *user_data)
647
+ {
648
+ // dummy
649
+ return 0;
650
+ }
651
+
652
+ __NAMESPACE_END_OPENCV
653
+
654
+ extern "C" {
655
+ void
656
+ Init_opencv()
657
+ {
658
+ cvRedirectError((CvErrorCallback)mOpenCV::error_callback);
659
+
660
+ mOpenCV::define_ruby_module();
661
+
662
+ mOpenCV::cCvError::define_ruby_class();
663
+ mOpenCV::cCvPoint::define_ruby_class();
664
+ mOpenCV::cCvPoint2D32f::define_ruby_class();
665
+ mOpenCV::cCvPoint3D32f::define_ruby_class();
666
+ mOpenCV::cCvSize::define_ruby_class();
667
+ mOpenCV::cCvSize2D32f::define_ruby_class();
668
+ mOpenCV::cCvRect::define_ruby_class();
669
+ mOpenCV::cCvScalar::define_ruby_class();
670
+ mOpenCV::cCvSlice::define_ruby_class();
671
+ mOpenCV::cCvTermCriteria::define_ruby_class();
672
+ mOpenCV::cCvBox2D::define_ruby_class();
673
+ mOpenCV::cCvFont::define_ruby_class();
674
+ mOpenCV::cIplConvKernel::define_ruby_class();
675
+ mOpenCV::cCvMoments::define_ruby_class();
676
+ mOpenCV::cCvHuMoments::define_ruby_class();
677
+ mOpenCV::cCvConvexityDefect::define_ruby_class();
678
+
679
+ mOpenCV::cCvSURFPoint::define_ruby_class();
680
+ mOpenCV::cCvSURFParams::define_ruby_class();
681
+
682
+ mOpenCV::cCvMemStorage::define_ruby_class();
683
+
684
+ mOpenCV::cCvSeq::define_ruby_class();
685
+ mOpenCV::mCurve::define_ruby_module();
686
+ mOpenCV::mPointSet::define_ruby_module();
687
+ mOpenCV::cCvChain::define_ruby_class();
688
+ mOpenCV::cCvContour::define_ruby_class();
689
+ mOpenCV::cCvContourTree::define_ruby_class();
690
+
691
+ mOpenCV::cCvMat::define_ruby_class();
692
+ mOpenCV::cIplImage::define_ruby_class();
693
+ mOpenCV::cCvMatND::define_ruby_class();
694
+ mOpenCV::cCvSparseMat::define_ruby_class();
695
+ mOpenCV::cCvHistogram::define_ruby_class();
696
+ mOpenCV::cCvCapture::define_ruby_class();
697
+ mOpenCV::cCvVideoWriter::define_ruby_class();
698
+
699
+ mOpenCV::cCvLine::define_ruby_class();
700
+ mOpenCV::cCvTwoPoints::define_ruby_class();
701
+ mOpenCV::cCvCircle32f::define_ruby_class();
702
+
703
+ mOpenCV::cCvConDensation::define_ruby_class();
704
+ mOpenCV::cCvFeatureTree::define_ruby_class();
705
+
706
+ mOpenCV::cCvConnectedComp::define_ruby_class();
707
+ mOpenCV::cCvAvgComp::define_ruby_class();
708
+ mOpenCV::cCvHaarClassifierCascade::define_ruby_class();
709
+ mOpenCV::mGUI::define_ruby_module();
710
+ mOpenCV::mGUI::cWindow::define_ruby_class();
711
+ mOpenCV::mGUI::cTrackbar::define_ruby_class();
712
+ mOpenCV::mGUI::cMouseEvent::define_ruby_class();
713
+
714
+ #ifdef HAVE_ML_H
715
+ /* feature support.
716
+ mOpenCV::mMachineLearning::define_ruby_module();
717
+ */
718
+ #endif
719
+
720
+ cv::initModule_nonfree();
721
+ }
722
+ }