ruby-opencv 0.0.11 → 0.0.12.pre

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 (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.yardopts +3 -0
  4. data/Gemfile +1 -0
  5. data/Manifest.txt +2 -14
  6. data/README.md +1 -1
  7. data/Rakefile +10 -1
  8. data/examples/facerec/facerec_lbph.rb +1 -1
  9. data/ext/opencv/algorithm.cpp +6 -1
  10. data/ext/opencv/algorithm.h +1 -1
  11. data/ext/opencv/curve.cpp +48 -33
  12. data/ext/opencv/curve.h +1 -1
  13. data/ext/opencv/cvavgcomp.cpp +22 -25
  14. data/ext/opencv/cvavgcomp.h +1 -1
  15. data/ext/opencv/cvbox2d.cpp +56 -58
  16. data/ext/opencv/cvbox2d.h +1 -1
  17. data/ext/opencv/cvcapture.cpp +210 -109
  18. data/ext/opencv/cvcapture.h +1 -1
  19. data/ext/opencv/cvchain.cpp +71 -71
  20. data/ext/opencv/cvchain.h +1 -1
  21. data/ext/opencv/cvcircle32f.cpp +37 -27
  22. data/ext/opencv/cvcircle32f.h +1 -1
  23. data/ext/opencv/cvconnectedcomp.cpp +49 -36
  24. data/ext/opencv/cvconnectedcomp.h +1 -1
  25. data/ext/opencv/cvcontour.cpp +117 -81
  26. data/ext/opencv/cvcontour.h +1 -1
  27. data/ext/opencv/cvcontourtree.cpp +37 -32
  28. data/ext/opencv/cvcontourtree.h +1 -1
  29. data/ext/opencv/cvconvexitydefect.cpp +33 -44
  30. data/ext/opencv/cvconvexitydefect.h +1 -1
  31. data/ext/opencv/cverror.cpp +22 -66
  32. data/ext/opencv/cverror.h +1 -1
  33. data/ext/opencv/cvfeaturetree.cpp +31 -33
  34. data/ext/opencv/cvfeaturetree.h +1 -1
  35. data/ext/opencv/cvfont.cpp +98 -78
  36. data/ext/opencv/cvfont.h +1 -1
  37. data/ext/opencv/cvhaarclassifiercascade.cpp +39 -59
  38. data/ext/opencv/cvhaarclassifiercascade.h +1 -1
  39. data/ext/opencv/cvhistogram.cpp +259 -90
  40. data/ext/opencv/cvhistogram.h +1 -1
  41. data/ext/opencv/cvhumoments.cpp +99 -60
  42. data/ext/opencv/cvhumoments.h +1 -1
  43. data/ext/opencv/cvline.cpp +45 -40
  44. data/ext/opencv/cvline.h +1 -1
  45. data/ext/opencv/cvmat.cpp +1894 -1829
  46. data/ext/opencv/cvmat.h +2 -3
  47. data/ext/opencv/cvmemstorage.cpp +19 -14
  48. data/ext/opencv/cvmemstorage.h +1 -1
  49. data/ext/opencv/cvmoments.cpp +51 -45
  50. data/ext/opencv/cvmoments.h +1 -1
  51. data/ext/opencv/cvpoint.cpp +32 -26
  52. data/ext/opencv/cvpoint.h +1 -1
  53. data/ext/opencv/cvpoint2d32f.cpp +31 -26
  54. data/ext/opencv/cvpoint2d32f.h +1 -1
  55. data/ext/opencv/cvpoint3d32f.cpp +36 -29
  56. data/ext/opencv/cvpoint3d32f.h +1 -1
  57. data/ext/opencv/cvrect.cpp +38 -33
  58. data/ext/opencv/cvrect.h +1 -1
  59. data/ext/opencv/cvscalar.cpp +50 -45
  60. data/ext/opencv/cvscalar.h +1 -1
  61. data/ext/opencv/cvseq.cpp +53 -47
  62. data/ext/opencv/cvseq.h +1 -1
  63. data/ext/opencv/cvsize.cpp +32 -26
  64. data/ext/opencv/cvsize.h +1 -1
  65. data/ext/opencv/cvsize2d32f.cpp +31 -25
  66. data/ext/opencv/cvsize2d32f.h +1 -1
  67. data/ext/opencv/cvslice.cpp +28 -22
  68. data/ext/opencv/cvslice.h +1 -1
  69. data/ext/opencv/cvsurfparams.cpp +37 -28
  70. data/ext/opencv/cvsurfparams.h +1 -1
  71. data/ext/opencv/cvsurfpoint.cpp +76 -53
  72. data/ext/opencv/cvsurfpoint.h +1 -1
  73. data/ext/opencv/cvtermcriteria.cpp +32 -26
  74. data/ext/opencv/cvtermcriteria.h +1 -1
  75. data/ext/opencv/cvtwopoints.cpp +28 -22
  76. data/ext/opencv/cvtwopoints.h +1 -1
  77. data/ext/opencv/cvvideowriter.cpp +25 -20
  78. data/ext/opencv/cvvideowriter.h +1 -1
  79. data/ext/opencv/eigenfaces.cpp +10 -2
  80. data/ext/opencv/eigenfaces.h +1 -1
  81. data/ext/opencv/facerecognizer.cpp +15 -8
  82. data/ext/opencv/facerecognizer.h +2 -2
  83. data/ext/opencv/fisherfaces.cpp +10 -2
  84. data/ext/opencv/fisherfaces.h +1 -1
  85. data/ext/opencv/gui.cpp +26 -23
  86. data/ext/opencv/gui.h +1 -1
  87. data/ext/opencv/iplconvkernel.cpp +30 -24
  88. data/ext/opencv/iplconvkernel.h +1 -1
  89. data/ext/opencv/iplimage.cpp +49 -42
  90. data/ext/opencv/iplimage.h +1 -1
  91. data/ext/opencv/lbph.cpp +10 -2
  92. data/ext/opencv/lbph.h +1 -1
  93. data/ext/opencv/mouseevent.cpp +30 -25
  94. data/ext/opencv/mouseevent.h +1 -1
  95. data/ext/opencv/opencv.cpp +59 -60
  96. data/ext/opencv/opencv.h +1 -5
  97. data/ext/opencv/pointset.cpp +31 -25
  98. data/ext/opencv/pointset.h +1 -1
  99. data/ext/opencv/trackbar.cpp +27 -21
  100. data/ext/opencv/trackbar.h +1 -1
  101. data/ext/opencv/window.cpp +77 -57
  102. data/ext/opencv/window.h +1 -1
  103. data/lib/opencv/version.rb +2 -1
  104. data/ruby-opencv.gemspec +19 -18
  105. data/test/test_opencv.rb +5 -3
  106. data/yard_extension.rb +5 -0
  107. metadata +13 -27
  108. data/examples/matching_to_many_images/matching_to_many_images.rb +0 -16
  109. data/examples/matching_to_many_images/query.png +0 -0
  110. data/examples/matching_to_many_images/train/1.png +0 -0
  111. data/examples/matching_to_many_images/train/2.png +0 -0
  112. data/examples/matching_to_many_images/train/3.png +0 -0
  113. data/examples/matching_to_many_images/train/trainImages.txt +0 -3
  114. data/ext/opencv/cvcondensation.cpp +0 -282
  115. data/ext/opencv/cvcondensation.h +0 -49
  116. data/ext/opencv/cvmatnd.cpp +0 -44
  117. data/ext/opencv/cvmatnd.h +0 -28
  118. data/ext/opencv/cvsparsemat.cpp +0 -44
  119. data/ext/opencv/cvsparsemat.h +0 -28
  120. data/images/face_detect_from_lena.jpg +0 -0
  121. data/test/test_cvmat_matching.rb +0 -57
@@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVBOX2D
20
20
 
21
21
  VALUE rb_class();
22
22
 
23
- void define_ruby_class();
23
+ void init_ruby_class();
24
24
 
25
25
  VALUE rb_allocate(VALUE klass);
26
26
 
@@ -11,8 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvCapture
13
13
  *
14
- * Capture image from video stream.
15
- *
14
+ * Class for video capturing from video files or cameras
16
15
  */
17
16
  __NAMESPACE_BEGIN_OPENCV
18
17
  __NAMESPACE_BEGIN_CVCAPTURE
@@ -25,75 +24,6 @@ rb_class()
25
24
  return rb_klass;
26
25
  }
27
26
 
28
- void
29
- define_ruby_class()
30
- {
31
- if (rb_klass)
32
- return;
33
- /*
34
- * opencv = rb_define_module("OpenCV");
35
- *
36
- * note: this comment is used by rdoc.
37
- */
38
- VALUE opencv = rb_module_opencv();
39
-
40
- rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
41
-
42
- VALUE video_interface = rb_hash_new();
43
- /* {:any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394, :stereo,
44
- :tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime}: video source */
45
- rb_define_const(rb_klass, "INTERFACE", video_interface);
46
- rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
47
- rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
48
- rb_hash_aset(video_interface, ID2SYM(rb_intern("vfw")), INT2FIX(CV_CAP_VFW));
49
- rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l")), INT2FIX(CV_CAP_V4L));
50
- rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l2")), INT2FIX(CV_CAP_V4L2));
51
- rb_hash_aset(video_interface, ID2SYM(rb_intern("fireware")), INT2FIX(CV_CAP_FIREWARE));
52
- rb_hash_aset(video_interface, ID2SYM(rb_intern("ieee1394")), INT2FIX(CV_CAP_IEEE1394));
53
- rb_hash_aset(video_interface, ID2SYM(rb_intern("dc1394")), INT2FIX(CV_CAP_DC1394));
54
- rb_hash_aset(video_interface, ID2SYM(rb_intern("cmu1394")), INT2FIX(CV_CAP_CMU1394));
55
- rb_hash_aset(video_interface, ID2SYM(rb_intern("stereo")), INT2FIX(CV_CAP_STEREO));
56
- rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx")), INT2FIX(CV_CAP_TYZX));
57
- rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_left")), INT2FIX(CV_TYZX_LEFT));
58
- rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_right")), INT2FIX(CV_TYZX_RIGHT));
59
- rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_color")), INT2FIX(CV_TYZX_COLOR));
60
- rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_z")), INT2FIX(CV_TYZX_Z));
61
- rb_hash_aset(video_interface, ID2SYM(rb_intern("qt")), INT2FIX(CV_CAP_QT));
62
- rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
63
-
64
- rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
65
-
66
- rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
67
- rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
68
- rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
69
- rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
70
- rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
71
- rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
72
- rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
73
- rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
74
- rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
75
- rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
76
- rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
77
- rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
78
- rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
79
- rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
80
- rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
81
- rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
82
- rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
83
- rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
84
- rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
85
- rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
86
- rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
87
- rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
88
- rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
89
- rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
90
- rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
91
- rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
92
- rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
93
- rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
94
- rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
95
- }
96
-
97
27
  void
98
28
  cvcapture_free(void *ptr)
99
29
  {
@@ -102,20 +32,16 @@ cvcapture_free(void *ptr)
102
32
  }
103
33
 
104
34
  /*
105
- * call-seq:
106
- * CvCapture.open(<i>[dev = -1]</i>)
107
- *
108
- * Reading video stream from the specified file or camera device.
109
- * If <i>dev</i> is string (i.e "stream.avi"), reading video stream from file.
110
- * If <i>dev</i> is number or symbol(include CvCapture::INTERFACE),
111
- * reading video stream from camera.
112
- * Currently two camera interfaces can be used on Windows:
113
- * * Video for Windows(VFW)
114
- * * Matrox Imaging Library(MIL)
115
- * and two on Linux
116
- * * V4L
117
- * * FireWire(IEEE1394).
118
- * If there is only one camera or it does not matter what camera to use <i>nil</i> may be passed.
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
119
45
  */
120
46
  VALUE
121
47
  rb_open(int argc, VALUE *argv, VALUE self)
@@ -151,18 +77,11 @@ rb_open(int argc, VALUE *argv, VALUE self)
151
77
  return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, capture);
152
78
  }
153
79
 
154
-
155
80
  /*
156
- * call-seq:
157
- * grab -> true or false
158
- *
159
- * Grabbed frame is stored internally. To grab frame
160
- * <i>fast</i> that is important for syncronization in case of reading from
161
- * several cameras simultaneously. The grabbed frames are not exposed because
162
- * they may be stored in compressed format (as defined by camera/driver).
163
- * To retrieve the grabbed frame, retrieve should be used.
164
- *
165
- * If grabbed frame was success, return true. Otherwise return false.
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
166
85
  */
167
86
  VALUE
168
87
  rb_grab(VALUE self)
@@ -178,10 +97,11 @@ rb_grab(VALUE self)
178
97
  }
179
98
 
180
99
  /*
181
- * call-seq:
182
- * retrieve -> IplImage or nil
183
- *
184
- * Gets the image grabbed with grab.
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
185
105
  */
186
106
  VALUE
187
107
  rb_retrieve(VALUE self)
@@ -209,10 +129,11 @@ rb_retrieve(VALUE self)
209
129
  }
210
130
 
211
131
  /*
212
- * call-seq:
213
- * query -> IplImage or nil
214
- *
215
- * Grabs and returns a frame camera or file. Just a combination of grab and retrieve in one call.
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
216
137
  */
217
138
  VALUE
218
139
  rb_query(VALUE self)
@@ -266,30 +187,47 @@ rb_set_capture_property(VALUE self, int id, VALUE value)
266
187
 
267
188
  /*
268
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)
269
193
  */
270
194
  VALUE
271
195
  rb_get_millisecond(VALUE self)
272
196
  {
273
197
  return rb_get_capture_property(self, CV_CAP_PROP_POS_MSEC);
274
198
  }
199
+
275
200
  /*
276
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)
277
206
  */
278
207
  VALUE
279
208
  rb_set_millisecond(VALUE self, VALUE value)
280
209
  {
281
210
  return rb_set_capture_property(self, CV_CAP_PROP_POS_MSEC, value);
282
211
  }
212
+
283
213
  /*
284
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)
285
218
  */
286
219
  VALUE
287
220
  rb_get_frames(VALUE self)
288
221
  {
289
222
  return rb_get_capture_property(self, CV_CAP_PROP_POS_FRAMES);
290
223
  }
224
+
291
225
  /*
292
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)
293
231
  */
294
232
  VALUE
295
233
  rb_set_frames(VALUE self, VALUE value)
@@ -297,7 +235,10 @@ rb_set_frames(VALUE self, VALUE value)
297
235
  return rb_set_capture_property(self, CV_CAP_PROP_POS_FRAMES, value);
298
236
  }
299
237
  /*
300
- * Get relative position of video file (0 - start of the film, 1 - end of the film)
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)
301
242
  */
302
243
  VALUE
303
244
  rb_get_avi_ratio(VALUE self)
@@ -305,15 +246,23 @@ rb_get_avi_ratio(VALUE self)
305
246
  return rb_get_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO);
306
247
  }
307
248
  /*
308
- * Set relative position of video file (0 - start of the film, 1 - end of the film)
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)
309
254
  */
310
255
  VALUE
311
256
  rb_set_avi_ratio(VALUE self, VALUE value)
312
257
  {
313
258
  return rb_set_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO, value);
314
259
  }
260
+
315
261
  /*
316
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)
317
266
  */
318
267
  VALUE
319
268
  rb_get_size(VALUE self)
@@ -329,8 +278,13 @@ rb_get_size(VALUE self)
329
278
  }
330
279
  return cCvSize::new_object(size);
331
280
  }
281
+
332
282
  /*
333
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)
334
288
  */
335
289
  VALUE
336
290
  rb_set_size(VALUE self, VALUE value)
@@ -347,56 +301,87 @@ rb_set_size(VALUE self, VALUE value)
347
301
  }
348
302
  return DBL2NUM(result);
349
303
  }
304
+
350
305
  /*
351
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)
352
310
  */
353
311
  VALUE
354
312
  rb_get_width(VALUE self)
355
313
  {
356
314
  return rb_get_capture_property(self, CV_CAP_PROP_FRAME_WIDTH);
357
315
  }
316
+
358
317
  /*
359
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)
360
323
  */
361
324
  VALUE
362
325
  rb_set_width(VALUE self, VALUE value)
363
326
  {
364
327
  return rb_set_capture_property(self, CV_CAP_PROP_FRAME_WIDTH, value);
365
328
  }
329
+
366
330
  /*
367
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)
368
335
  */
369
336
  VALUE
370
337
  rb_get_height(VALUE self)
371
338
  {
372
339
  return rb_get_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT);
373
340
  }
341
+
374
342
  /*
375
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)
376
348
  */
377
349
  VALUE
378
350
  rb_set_height(VALUE self, VALUE value)
379
351
  {
380
352
  return rb_set_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT, value);
381
353
  }
354
+
382
355
  /*
383
356
  * Get frame rate
357
+ * @overload fps
358
+ * @return [Number] Frame rate
359
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FPS)
384
360
  */
385
361
  VALUE
386
362
  rb_get_fps(VALUE self)
387
363
  {
388
364
  return rb_get_capture_property(self, CV_CAP_PROP_FPS);
389
365
  }
366
+
390
367
  /*
391
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)
392
373
  */
393
374
  VALUE
394
375
  rb_set_fps(VALUE self, VALUE value)
395
376
  {
396
377
  return rb_set_capture_property(self, CV_CAP_PROP_FPS, value);
397
378
  }
379
+
398
380
  /*
399
- * Get 4character code of codec. see http://www.fourcc.org/
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)
400
385
  */
401
386
  VALUE
402
387
  rb_get_fourcc(VALUE self)
@@ -406,48 +391,72 @@ rb_get_fourcc(VALUE self)
406
391
  sprintf(str, "%s", (char*)&fourcc);
407
392
  return rb_str_new2(str);
408
393
  }
394
+
409
395
  /*
410
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)
411
400
  */
412
401
  VALUE
413
402
  rb_get_frame_count(VALUE self)
414
403
  {
415
404
  return rb_get_capture_property(self, CV_CAP_PROP_FRAME_COUNT);
416
405
  }
406
+
417
407
  /*
418
- * Get the format of the Mat objects returned by CvCapture#retrieve
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)
419
412
  */
420
413
  VALUE
421
414
  rb_get_format(VALUE self)
422
415
  {
423
416
  return rb_get_capture_property(self, CV_CAP_PROP_FORMAT);
424
417
  }
418
+
425
419
  /*
426
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)
427
424
  */
428
425
  VALUE
429
426
  rb_get_mode(VALUE self)
430
427
  {
431
428
  return rb_get_capture_property(self, CV_CAP_PROP_MODE);
432
429
  }
430
+
433
431
  /*
434
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)
435
436
  */
436
437
  VALUE
437
438
  rb_get_brightness(VALUE self)
438
439
  {
439
440
  return rb_get_capture_property(self, CV_CAP_PROP_BRIGHTNESS);
440
441
  }
442
+
441
443
  /*
442
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)
443
448
  */
444
449
  VALUE
445
450
  rb_get_contrast(VALUE self)
446
451
  {
447
452
  return rb_get_capture_property(self, CV_CAP_PROP_CONTRAST);
448
453
  }
454
+
449
455
  /*
450
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)
451
460
  */
452
461
  VALUE
453
462
  rb_get_saturation(VALUE self)
@@ -456,30 +465,45 @@ rb_get_saturation(VALUE self)
456
465
  }
457
466
  /*
458
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)
459
471
  */
460
472
  VALUE
461
473
  rb_get_hue(VALUE self)
462
474
  {
463
475
  return rb_get_capture_property(self, CV_CAP_PROP_HUE);
464
476
  }
477
+
465
478
  /*
466
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)
467
483
  */
468
484
  VALUE
469
485
  rb_get_gain(VALUE self)
470
486
  {
471
487
  return rb_get_capture_property(self, CV_CAP_PROP_GAIN);
472
488
  }
489
+
473
490
  /*
474
491
  * Get exposure (only for cameras)
492
+ * @overload exposure
493
+ * @return [Number] Exposure
494
+ * @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_EXPOSURE)
475
495
  */
476
496
  VALUE
477
497
  rb_get_exposure(VALUE self)
478
498
  {
479
499
  return rb_get_capture_property(self, CV_CAP_PROP_EXPOSURE);
480
500
  }
501
+
481
502
  /*
482
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)
483
507
  */
484
508
  VALUE
485
509
  rb_get_convert_rgb(VALUE self)
@@ -493,14 +517,91 @@ rb_get_convert_rgb(VALUE self)
493
517
  }
494
518
  return flag ? Qtrue : Qfalse;
495
519
  }
520
+
496
521
  /*
497
- * Get TOWRITE (note: only supported by DC1394 v 2.x backend currently)
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)
498
526
  */
499
527
  VALUE
500
528
  rb_get_rectification(VALUE self)
501
529
  {
502
530
  return rb_get_capture_property(self, CV_CAP_PROP_RECTIFICATION);
503
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
+
504
605
  __NAMESPACE_END_CVCAPTURE
505
606
  __NAMESPACE_END_OPENCV
506
607