ruby-opencv 0.0.11 → 0.0.12.pre

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f163ec9f4d2e2965c14628f3e4b1896313d6aab
4
- data.tar.gz: bb59169166d93df0586207a896e4a3c81c33b9de
3
+ metadata.gz: 5d02abda7096be25deaf28aa16aeee36f815ddef
4
+ data.tar.gz: b42f74d46051e42289131b2fd1b0922c4e1f762d
5
5
  SHA512:
6
- metadata.gz: 25b5e203c590af55fc5f1fe0fd6e62f2ca62e977306cd789cef78dbd0bf54bab6de192b9a60e8e6738b3c284eee1bb8b57256d70e3d96dcda1debda0ee3531e0
7
- data.tar.gz: 70fa2db7c5201ea00a60e8c7d9614fb6cd2c57e0841b908709967589a8e1e94eeb029cb2525a2032256edca36efe8e5c95e14ec3dbb776037f36bd52786add9a
6
+ metadata.gz: f92654da489e2c7444bb2f8934702cfd69f39f06b004336e423d81e0511ac55cb2ebb6fa67219b1cffdf799d3f63e4780e6de8856ad6c5376581e6299273e607
7
+ data.tar.gz: 8ca6223922b06bf6bb5f16be6be950f604a8e4e1962e774af44be30f0e2c02be67431751b17f1c8b6b24502c646fcd2eda31a23706fa5c8753ae2aaf5dfa366b
data/.gitignore CHANGED
@@ -21,6 +21,8 @@ log.txt
21
21
  videowriter_result.avi
22
22
  examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg
23
23
  Gemfile.lock
24
+ .yardoc
24
25
  .RUBYLIBDIR.*
25
26
  .RUBYARCHDIR.*
27
+ .bundle
26
28
 
@@ -0,0 +1,3 @@
1
+ --load yard_extension.rb
2
+ ext/opencv/*.cpp
3
+
data/Gemfile CHANGED
@@ -4,5 +4,6 @@ group :development do
4
4
  gem "hoe"
5
5
  gem "hoe-gemspec"
6
6
  gem "rake-compiler"
7
+ gem "yard"
7
8
  end
8
9
 
@@ -1,4 +1,5 @@
1
1
  .gitignore
2
+ .yardopts
2
3
  DEVELOPERS_NOTE.md
3
4
  Gemfile
4
5
  History.txt
@@ -34,12 +35,6 @@ examples/images/tiffany.jpg
34
35
  examples/inpaint.rb
35
36
  examples/match_kdtree.rb
36
37
  examples/match_template.rb
37
- examples/matching_to_many_images/matching_to_many_images.rb
38
- examples/matching_to_many_images/query.png
39
- examples/matching_to_many_images/train/1.png
40
- examples/matching_to_many_images/train/2.png
41
- examples/matching_to_many_images/train/3.png
42
- examples/matching_to_many_images/train/trainImages.txt
43
38
  examples/paint.rb
44
39
  examples/snake.rb
45
40
  ext/opencv/algorithm.cpp
@@ -56,8 +51,6 @@ ext/opencv/cvchain.cpp
56
51
  ext/opencv/cvchain.h
57
52
  ext/opencv/cvcircle32f.cpp
58
53
  ext/opencv/cvcircle32f.h
59
- ext/opencv/cvcondensation.cpp
60
- ext/opencv/cvcondensation.h
61
54
  ext/opencv/cvconnectedcomp.cpp
62
55
  ext/opencv/cvconnectedcomp.h
63
56
  ext/opencv/cvcontour.cpp
@@ -82,8 +75,6 @@ ext/opencv/cvline.cpp
82
75
  ext/opencv/cvline.h
83
76
  ext/opencv/cvmat.cpp
84
77
  ext/opencv/cvmat.h
85
- ext/opencv/cvmatnd.cpp
86
- ext/opencv/cvmatnd.h
87
78
  ext/opencv/cvmemstorage.cpp
88
79
  ext/opencv/cvmemstorage.h
89
80
  ext/opencv/cvmoments.cpp
@@ -106,8 +97,6 @@ ext/opencv/cvsize2d32f.cpp
106
97
  ext/opencv/cvsize2d32f.h
107
98
  ext/opencv/cvslice.cpp
108
99
  ext/opencv/cvslice.h
109
- ext/opencv/cvsparsemat.cpp
110
- ext/opencv/cvsparsemat.h
111
100
  ext/opencv/cvsurfparams.cpp
112
101
  ext/opencv/cvsurfparams.h
113
102
  ext/opencv/cvsurfpoint.cpp
@@ -148,7 +137,6 @@ ext/opencv/window.h
148
137
  images/CvMat_sobel.png
149
138
  images/CvMat_sub_rect.png
150
139
  images/CvSeq_relationmap.png
151
- images/face_detect_from_lena.jpg
152
140
  lib/opencv.rb
153
141
  lib/opencv/psyched_yaml.rb
154
142
  lib/opencv/version.rb
@@ -222,7 +210,6 @@ test/test_cvmat.rb
222
210
  test/test_cvmat_drawing.rb
223
211
  test/test_cvmat_dxt.rb
224
212
  test/test_cvmat_imageprocessing.rb
225
- test/test_cvmat_matching.rb
226
213
  test/test_cvmoments.rb
227
214
  test/test_cvpoint.rb
228
215
  test/test_cvpoint2d32f.rb
@@ -249,3 +236,4 @@ test/test_pointset.rb
249
236
  test/test_preliminary.rb
250
237
  test/test_trackbar.rb
251
238
  test/test_window.rb
239
+ yard_extension.rb
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  An OpenCV wrapper for Ruby.
4
4
 
5
5
  * Web site: <https://github.com/ruby-opencv/ruby-opencv>
6
- * Ruby 1.9.3, 2.0.0 and OpenCV 2.4.7 are supported.
6
+ * Ruby 1.9.3, 2.0.0, 2.1.0 and OpenCV 2.4.8 are supported.
7
7
 
8
8
  ## Requirement
9
9
 
data/Rakefile CHANGED
@@ -6,6 +6,9 @@ require 'hoe'
6
6
  require 'rake/extensiontask'
7
7
  require 'fileutils'
8
8
  require './lib/opencv/psyched_yaml'
9
+ require 'yard'
10
+ require 'yard/rake/yardoc_task'
11
+ require './yard_extension'
9
12
 
10
13
  SO_FILE = 'opencv.so'
11
14
 
@@ -27,7 +30,7 @@ hoespec = Hoe.spec 'ruby-opencv' do |s|
27
30
  s.test_globs = ['test/test_*.rb']
28
31
  s.urls = ['https://github.com/ruby-opencv/ruby-opencv/']
29
32
 
30
- s.extra_dev_deps << ['rake-compiler', '>= 0'] << ['hoe-gemspec']
33
+ s.extra_dev_deps << ['rake-compiler', '~> 0'] << ['hoe-gemspec', '~> 0']
31
34
 
32
35
  Rake::ExtensionTask.new('opencv', spec) do |ext|
33
36
  ext.lib_dir = 'lib'
@@ -87,4 +90,10 @@ task 'gem:precompile' => ['gem'] do
87
90
  FileUtils.rm_rf tmp_dir
88
91
  end
89
92
 
93
+ # yard
94
+ YARD::Rake::YardocTask.new do |t|
95
+ t.files = ['lib/**/*.rb', 'ext/**/*.cpp']
96
+ end
97
+
90
98
  # vim: syntax=ruby
99
+
@@ -97,7 +97,7 @@ model.set_double('threshold', 0.0);
97
97
 
98
98
  # Now the threshold of this model is set to 0.0. A prediction
99
99
  # now returns -1, as it's impossible to have a distance below it
100
- predicted_label = model.predict(test_sample)
100
+ predicted_label, predicted_confidence = model.predict(test_sample)
101
101
  puts "Predicted class = #{predicted_label}"
102
102
 
103
103
  # Show some informations about the model, as there's no cool
@@ -252,8 +252,13 @@ rb_name(VALUE self)
252
252
  }
253
253
 
254
254
  void
255
- define_ruby_class()
255
+ init_ruby_class()
256
256
  {
257
+ #if 0
258
+ // For documentation using YARD
259
+ VALUE opencv = rb_define_module("OpenCV");
260
+ #endif
261
+
257
262
  if (rb_klass)
258
263
  return;
259
264
  /*
@@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_ALGORITHM
20
20
 
21
21
  VALUE rb_class();
22
22
 
23
- void define_ruby_class();
23
+ void init_ruby_class();
24
24
 
25
25
  __NAMESPACE_END_ALGORITM
26
26
 
@@ -11,7 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::Curve
13
13
  *
14
- * Curve sequence.
14
+ * Curve sequence
15
15
  */
16
16
  __NAMESPACE_BEGIN_OPENCV
17
17
  __NAMESPACE_BEGIN_CURVE
@@ -24,27 +24,11 @@ rb_module()
24
24
  return module;
25
25
  }
26
26
 
27
- void
28
- define_ruby_module()
29
- {
30
- if (module)
31
- return;
32
- /*
33
- * opencv = rb_define_module("OpenCV");
34
- *
35
- * note: this comment is used by rdoc.
36
- */
37
- VALUE opencv = rb_module_opencv();
38
- module = rb_define_module_under(opencv, "Curve");
39
- rb_define_method(module, "closed?", RUBY_METHOD_FUNC(rb_closed_q), 0);
40
- rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
41
- rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
42
- rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
43
- rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
44
- }
45
-
46
27
  /*
47
- * If curve is closed, return true. Otherwise return false.
28
+ * If the curve is closed, return true. Otherwise return false.
29
+ * @overload closed?
30
+ * @return [Boolean] Closed or not
31
+ * @opencv_func CV_IS_SEQ_CLOSED
48
32
  */
49
33
  VALUE
50
34
  rb_closed_q(VALUE self)
@@ -53,7 +37,10 @@ rb_closed_q(VALUE self)
53
37
  }
54
38
 
55
39
  /*
56
- * If curve is convex, return true. Otherwise return false.
40
+ * If the curve is convex, return true. Otherwise return false.
41
+ * @overload convex?
42
+ * @return [Boolean] Convex or not
43
+ * @opencv_func CV_IS_SEQ_CONVEX
57
44
  */
58
45
  VALUE
59
46
  rb_convex_q(VALUE self)
@@ -62,7 +49,10 @@ rb_convex_q(VALUE self)
62
49
  }
63
50
 
64
51
  /*
65
- * If curve is hole(inner contour), return true. Otherwise return false.
52
+ * If the curve is hole(inner contour), return true. Otherwise return false.
53
+ * @overload hole?
54
+ * @return [Boolean] Hole or not
55
+ * @opencv_func CV_IS_SEQ_HOLE
66
56
  */
67
57
  VALUE
68
58
  rb_hole_q(VALUE self)
@@ -71,7 +61,10 @@ rb_hole_q(VALUE self)
71
61
  }
72
62
 
73
63
  /*
74
- * no idia.
64
+ * If the curve is simple, return true. Otherwise return false.
65
+ * @overload simple?
66
+ * @return [Boolean] Simple or not
67
+ * @opencv_func CV_IS_SEQ_SIMPLE
75
68
  */
76
69
  VALUE
77
70
  rb_simple_q(VALUE self)
@@ -80,15 +73,17 @@ rb_simple_q(VALUE self)
80
73
  }
81
74
 
82
75
  /*
83
- * call-seq:
84
- * arc_length(<i>[slice = nil][,is_closed = nil]</i>) -> float
85
- *
86
- * Calculates contour perimeter or curve length.
87
- * <i>slice</i> is starting and ending points of the curve.
88
- * <i>is_closed</i> is indicates whether the curve is closed or not. There are 3 cases:
89
- * * is_closed = true - the curve is assumed to be unclosed.
90
- * * is_closed = false - the curve is assumed to be closed.
91
- * * is_closed = nil (default) use self#close?
76
+ * Calculates length of a curve
77
+ * @overload arc_length(slice = nil, is_closed = nil)
78
+ * @param slice [Range,CvSlice,nil] Starting and ending points of the curve.
79
+ * By default, the whole curve length is calculated.
80
+ * @param is_closed [Boolean,nil] Indicates whether the curve is closed or not.
81
+ * There are 3 cases:
82
+ * * is_closed = true - the curve is assumed to be unclosed.
83
+ * * is_closed = false - the curve is assumed to be closed.
84
+ * * is_closed = nil (default) use self#closed?
85
+ * @return [Number] Length of the curve
86
+ * @opencv_func cvArcLength
92
87
  */
93
88
  VALUE
94
89
  rb_arc_length(int argc, VALUE *argv, VALUE self)
@@ -107,6 +102,26 @@ rb_arc_length(int argc, VALUE *argv, VALUE self)
107
102
  return rb_float_new(length);
108
103
  }
109
104
 
105
+ void
106
+ init_ruby_module()
107
+ {
108
+ #if 0
109
+ // For documentation using YARD
110
+ VALUE opencv = rb_define_module("OpenCV");
111
+ #endif
112
+
113
+ if (module)
114
+ return;
115
+
116
+ VALUE opencv = rb_module_opencv();
117
+ module = rb_define_module_under(opencv, "Curve");
118
+ rb_define_method(module, "closed?", RUBY_METHOD_FUNC(rb_closed_q), 0);
119
+ rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
120
+ rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
121
+ rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
122
+ rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
123
+ }
124
+
110
125
  __NAMESPACE_END_CURVE
111
126
  __NAMESPACE_END_OPENCV
112
127
 
@@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CURVE
20
20
 
21
21
  VALUE rb_module();
22
22
 
23
- void define_ruby_module();
23
+ void init_ruby_module();
24
24
 
25
25
  VALUE rb_closed_q(VALUE self);
26
26
  VALUE rb_convex_q(VALUE self);
@@ -11,13 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvAvgComp
13
13
  *
14
- * CvRect with parameter "neighbors".
15
- * CvHaarClassifierCascade#detect_object.
16
- *
17
- * typedef struct CvAvgComp {
18
- * CvRect rect;
19
- * int neighbors;
20
- * }
14
+ * CvRect with parameter "neighbors"
21
15
  */
22
16
  __NAMESPACE_BEGIN_OPENCV
23
17
  __NAMESPACE_BEGIN_AVGCOMP
@@ -30,23 +24,6 @@ rb_class()
30
24
  return rb_klass;
31
25
  }
32
26
 
33
- void
34
- define_ruby_class()
35
- {
36
- if (rb_klass)
37
- return;
38
- /*
39
- * opencv = rb_define_module("OpenCV");
40
- * cvrect = rb_define_class_under(opencv, "CvRect", rb_cObject);
41
- *
42
- * note: this comment is used by rdoc.
43
- */
44
- VALUE opencv = rb_module_opencv(), cvrect = cCvRect::rb_class();
45
- rb_klass = rb_define_class_under(opencv, "CvAvgComp", cvrect);
46
- rb_define_alloc_func(rb_klass, rb_allocate);
47
- rb_define_method(rb_klass, "neighbors", RUBY_METHOD_FUNC(rb_neighbors), 0);
48
- }
49
-
50
27
  VALUE
51
28
  rb_allocate(VALUE klass)
52
29
  {
@@ -55,7 +32,9 @@ rb_allocate(VALUE klass)
55
32
  }
56
33
 
57
34
  /*
58
- * Return neighbors.
35
+ * Return neighbors
36
+ * @overload neighbors
37
+ * @return [Integer] neighbors
59
38
  */
60
39
  VALUE
61
40
  rb_neighbors(VALUE self)
@@ -63,5 +42,23 @@ rb_neighbors(VALUE self)
63
42
  return INT2NUM(CVAVGCOMP(self)->neighbors);
64
43
  }
65
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
+
66
63
  __NAMESPACE_END_AVGCOMP
67
64
  __NAMESPACE_END_OPENCV
@@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_AVGCOMP
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
  VALUE rb_neighbors(VALUE self);
@@ -11,12 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvBox2D
13
13
  *
14
- * C structure is here.
15
- * typdef struct CvBox2D {
16
- * CvPoint2D32f center; // center of the box.
17
- * CvSize2D32f size; // box width and length
18
- * float angle; // angle between the horizonal axis and the first side (i.e length) in radians
19
- * } CvBox2D;
14
+ * Stores coordinates of a rotated rectangle.
20
15
  */
21
16
  __NAMESPACE_BEGIN_OPENCV
22
17
  __NAMESPACE_BEGIN_CVBOX2D
@@ -29,29 +24,6 @@ rb_class()
29
24
  return rb_klass;
30
25
  }
31
26
 
32
- void
33
- define_ruby_class()
34
- {
35
- if (rb_klass)
36
- return;
37
- /*
38
- * opencv = rb_define_module("OpenCV");
39
- *
40
- * note: this comment is used by rdoc.
41
- */
42
- VALUE opencv = rb_module_opencv();
43
- rb_klass = rb_define_class_under(opencv, "CvBox2D", rb_cObject);
44
- rb_define_alloc_func(rb_klass, rb_allocate);
45
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
46
- rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
47
- rb_define_method(rb_klass, "center=", RUBY_METHOD_FUNC(rb_set_center), 1);
48
- rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
49
- rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
50
- rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
51
- rb_define_method(rb_klass, "angle=", RUBY_METHOD_FUNC(rb_set_angle), 1);
52
- rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
53
- }
54
-
55
27
  VALUE
56
28
  rb_allocate(VALUE klass)
57
29
  {
@@ -59,11 +31,13 @@ rb_allocate(VALUE klass)
59
31
  return Data_Make_Struct(klass, CvBox2D, 0, -1, ptr);
60
32
  }
61
33
 
62
- /*
63
- * call-seq:
64
- * CvBox2D.new(<i>[center][, size][, angle]</i>) -> cvbox2d
65
- *
34
+ /*
66
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
67
41
  */
68
42
  VALUE
69
43
  rb_initialize(int argc, VALUE *argv, VALUE self)
@@ -84,9 +58,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
84
58
  }
85
59
 
86
60
  /*
87
- * call-seq:
88
- * center -> cvpoint2d32f
89
- * Return center point of box as CvPoint2D32f.
61
+ * Returns center point of the box
62
+ * @overload center
63
+ * @return [CvPoint2D32f] Center of the box
90
64
  */
91
65
  VALUE
92
66
  rb_center(VALUE self)
@@ -95,10 +69,10 @@ rb_center(VALUE self)
95
69
  }
96
70
 
97
71
  /*
98
- * call-seq:
99
- * center = <i>value</i>
100
- *
101
- * Set center to <i>value</i>
72
+ * Set center point of the box
73
+ * @overload center=value
74
+ * @param value [CvPoint2D32f] Center of the box
75
+ * @return [CvBox2D] self
102
76
  */
103
77
  VALUE
104
78
  rb_set_center(VALUE self, VALUE value)
@@ -108,9 +82,9 @@ rb_set_center(VALUE self, VALUE value)
108
82
  }
109
83
 
110
84
  /*
111
- * call-seq:
112
- * size -> cvsize2d32f
113
- * Return size of box as CvSize2D32f.
85
+ * Returns size of the box
86
+ * @overload size
87
+ * @return [CvSize2D32f] Size of the box
114
88
  */
115
89
  VALUE
116
90
  rb_size(VALUE self)
@@ -119,10 +93,10 @@ rb_size(VALUE self)
119
93
  }
120
94
 
121
95
  /*
122
- * call-seq:
123
- * size = <i>value</i>
124
- *
125
- * Set size to <i>value</i>
96
+ * Set size of the box
97
+ * @overload size=value
98
+ * @param value [CvSize2D32f] Size of the box
99
+ * @return [CvBox2D] self
126
100
  */
127
101
  VALUE
128
102
  rb_set_size(VALUE self, VALUE value)
@@ -132,10 +106,9 @@ rb_set_size(VALUE self, VALUE value)
132
106
  }
133
107
 
134
108
  /*
135
- * call-seq:
136
- * angle -> float
137
- *
138
- * Return angle of box as Float.
109
+ * Returns angle of the box
110
+ * @overload angle
111
+ * @return [Float] Angle of the box
139
112
  */
140
113
  VALUE
141
114
  rb_angle(VALUE self)
@@ -144,10 +117,10 @@ rb_angle(VALUE self)
144
117
  }
145
118
 
146
119
  /*
147
- * call-seq:
148
- * angle = <i>value</i>
149
- *
150
- * Set angle to <i>value</i>
120
+ * Set angle of the box
121
+ * @overload angle=value
122
+ * @param value [Number] Angle of the box
123
+ * @return [CvBox2D] self
151
124
  */
152
125
  VALUE
153
126
  rb_set_angle(VALUE self, VALUE value)
@@ -157,9 +130,10 @@ rb_set_angle(VALUE self, VALUE value)
157
130
  }
158
131
 
159
132
  /*
160
- * call-seq:
161
- * points -> array(include cvpoint2d32f)
162
- * Find box vertices. Return Array contain 4 CvPoint2D32f.
133
+ * Find box vertices
134
+ * @overload points
135
+ * @return [Array<CvPoint2D32f>] Vertices of the box
136
+ * @opencv_func cvBoxPoints
163
137
  */
164
138
  VALUE
165
139
  rb_points(VALUE self)
@@ -193,5 +167,29 @@ new_object(CvBox2D box)
193
167
  return object;
194
168
  }
195
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
+
196
194
  __NAMESPACE_END_CVBOX2D
197
195
  __NAMESPACE_END_OPENCV