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_CVCONVEXITYDEFECT
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_start(VALUE self);
26
26
  VALUE rb_end(VALUE self);
@@ -11,51 +11,7 @@
11
11
  /*
12
12
  * Document-class: OpenCV::CvError
13
13
  *
14
- * =Internal OpenCV errors
15
- *
16
- * This module collect OpenCV internal error wrapper classes.
17
- * * CvStatusBackTrace
18
- * * CvStatusError
19
- * * CvStatusInternal
20
- * * CvStatusNoMemory
21
- * * CvStatusBadArgument
22
- * * CvStatusNoConverge
23
- * * CvStatusAutoTrace
24
- *
25
- * * CvHeaderIsNull
26
- * * CvBadImageSize
27
- * * CvBadOffset
28
- * * CvBadDataPointer
29
- * * CvBadStep
30
- * * CvBadModelOrChannelSequence
31
- * * CvBadNumChannels
32
- * * CvBadAlphaChannel
33
- * * CvBadOrder
34
- * * CvBadOrigin
35
- * * CvBadAlign
36
- * * CvBadCallback
37
- * * CvBadTileSize
38
- * * CvBadCOI
39
- * * CvBadROISize
40
- *
41
- * * CvMaskIsTiled
42
- *
43
- * * CvStatusNullPointer
44
- * * CvStatusVectorLengthError
45
- * * CvStatusFilterStructContentError
46
- * * CvStatusKernelStructContentError
47
- * * CvStatusFilterOffsetError
48
- *
49
- * * CvStatusBadSize
50
- * * CvStatusDivByZero
51
- * * CvStatusInplaceNotSupported
52
- * * CvStatusObjectNotFound
53
- * * CvStatusUnmatchedFormant
54
- * * CvStatusUnsupportedFormats
55
- * * CvStatusOutOfRange
56
- * * CvStatusParseError
57
- * * CvStatusNotImplemented
58
- * * CvStsBadMemoryBlock
14
+ * OpenCV errors
59
15
  */
60
16
 
61
17
  __NAMESPACE_BEGIN_OPENCV
@@ -78,18 +34,32 @@ rb_class()
78
34
  return rb_klass;
79
35
  }
80
36
 
81
- void define_ruby_class()
37
+ VALUE
38
+ by_code(int error_code)
39
+ {
40
+ VALUE klass = 0;
41
+ st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
42
+ return klass ? klass : rb_eStandardError;
43
+ }
44
+
45
+ void
46
+ raise(cv::Exception e)
47
+ {
48
+ rb_raise(by_code(e.code), "%s", e.what());
49
+ }
50
+
51
+ void
52
+ init_ruby_class()
82
53
  {
54
+ #if 0
55
+ // For documentation using YARD
56
+ VALUE opencv = rb_define_module("OpenCV");
57
+ #endif
58
+
83
59
  if (rb_klass)
84
60
  return;
85
61
 
86
- /*
87
- * opencv = rb_define_module("OpenCV");
88
- *
89
- * note: this comment is used by rdoc.
90
- */
91
62
  VALUE opencv = rb_module_opencv();
92
-
93
63
  rb_klass = rb_define_class_under(opencv, "CvError", rb_eStandardError);
94
64
  REGISTER_CVERROR("CvStsBackTrace", CV_StsBackTrace);
95
65
  REGISTER_CVERROR("CvStsError", CV_StsError);
@@ -140,20 +110,6 @@ void define_ruby_class()
140
110
  REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported);
141
111
  REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError);
142
112
  }
143
-
144
- VALUE
145
- by_code(int error_code)
146
- {
147
- VALUE klass = 0;
148
- st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
149
- return klass ? klass : rb_eStandardError;
150
- }
151
-
152
- void
153
- raise(cv::Exception e)
154
- {
155
- rb_raise(by_code(e.code), "%s", e.what());
156
- }
157
113
 
158
114
  __NAMESPACE_END_CVERROR
159
115
  __NAMESPACE_END_OPENCV
@@ -18,7 +18,7 @@
18
18
  __NAMESPACE_BEGIN_OPENCV
19
19
  __NAMESPACE_BEGIN_CVERROR
20
20
 
21
- void define_ruby_class();
21
+ void init_ruby_class();
22
22
  VALUE by_code(int error_code);
23
23
  void raise(cv::Exception e);
24
24
 
@@ -48,30 +48,12 @@ rb_allocate(VALUE klass)
48
48
  rb_release_feature_tree, ptr);
49
49
  }
50
50
 
51
- void
52
- define_ruby_class()
53
- {
54
- if (rb_klass)
55
- return;
56
- /*
57
- * opencv = rb_define_module("OpenCV");
58
- *
59
- * note: this comment is used by rdoc.
60
- */
61
- VALUE opencv = rb_module_opencv();
62
-
63
- rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
64
- rb_define_alloc_func(rb_klass, rb_allocate);
65
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
66
-
67
- rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
68
- }
69
-
70
51
  /*
71
- * call-seq:
72
- * new(desc)
73
- *
74
52
  * Create a new kd-tree
53
+ * @overload new(desc)
54
+ * @param desc [CvMat] Descriptors
55
+ * @return [CvFeatureTree] self
56
+ * @opencv_func cvCreateKDTree
75
57
  */
76
58
  VALUE
77
59
  rb_initialize(VALUE self, VALUE desc)
@@ -91,18 +73,15 @@ rb_initialize(VALUE self, VALUE desc)
91
73
  }
92
74
 
93
75
  /*
94
- * call-seq:
95
- * find_features(desc, rows, cols, k, emax) -> array(results, dist)
96
- *
97
76
  * Find features from kd-tree
98
- *
99
- * desc: m x d matrix of (row-)vectors to find the nearest neighbors of.
100
- * k: The number of neighbors to find.
101
- * emax: The maximum number of leaves to visit.
102
- *
103
- * return
104
- * results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
105
- * dist: m x k matrix of distances to k nearest neighbors.
77
+ * @overload find_features(desc, k, emax)
78
+ * @param desc [CvMat] m x d matrix of (row-)vectors to find the nearest neighbors of.
79
+ * @param k [Integer] The number of neighbors to find.
80
+ * @param emax [Integer] The maximum number of leaves to visit.
81
+ * @return [Array] Array of [results, dist]
82
+ * - results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
83
+ * - dist: m x k matrix of distances to k nearest neighbors.
84
+ * @opencv_func cvFindFeatures
106
85
  */
107
86
  VALUE
108
87
  rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
@@ -120,6 +99,25 @@ rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
120
99
  return rb_assoc_new(results, dist);
121
100
  }
122
101
 
102
+ void
103
+ init_ruby_class()
104
+ {
105
+ #if 0
106
+ // For documentation using YARD
107
+ VALUE opencv = rb_define_module("OpenCV");
108
+ #endif
109
+
110
+ if (rb_klass)
111
+ return;
112
+
113
+ VALUE opencv = rb_module_opencv();
114
+ rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
115
+ rb_define_alloc_func(rb_klass, rb_allocate);
116
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
117
+
118
+ rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
119
+ }
120
+
123
121
  __NAMESPACE_END_OPENCV
124
122
  __NAMESPACE_END_CVFEATURETREE
125
123
 
@@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV
19
19
  __NAMESPACE_BEGIN_CVFEATURETREE
20
20
 
21
21
  VALUE rb_class();
22
- void define_ruby_class();
22
+ void init_ruby_class();
23
23
  VALUE rb_allocate(VALUE klass);
24
24
  VALUE rb_initialize(VALUE self, VALUE desc);
25
25
  VALUE rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax);
@@ -39,48 +39,6 @@ rb_class()
39
39
  return rb_klass;
40
40
  }
41
41
 
42
- void
43
- define_ruby_class()
44
- {
45
- if (rb_klass)
46
- return;
47
- /*
48
- * opencv = rb_define_module("OpenCV");
49
- *
50
- * note: this comment is used by rdoc.
51
- */
52
- VALUE opencv = rb_module_opencv();
53
-
54
- rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
55
- rb_define_alloc_func(rb_klass, rb_allocate);
56
- VALUE face = rb_hash_new();
57
- rb_define_const(rb_klass, "FACE", face);
58
- rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
59
- rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
60
- rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
61
- rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
62
- rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
63
- rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
64
- rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));
65
-
66
- VALUE default_option = rb_hash_new();
67
- rb_define_const(rb_klass, "FONT_OPTION", default_option);
68
- rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
69
- rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
70
- rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
71
- rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
72
- rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
73
-
74
- rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
75
- rb_define_method(rb_klass, "face", RUBY_METHOD_FUNC(rb_face), 0);
76
- rb_define_method(rb_klass, "hscale", RUBY_METHOD_FUNC(rb_hscale), 0);
77
- rb_define_method(rb_klass, "vscale", RUBY_METHOD_FUNC(rb_vscale), 0);
78
- rb_define_method(rb_klass, "shear", RUBY_METHOD_FUNC(rb_shear), 0);
79
- rb_define_method(rb_klass, "thickness", RUBY_METHOD_FUNC(rb_thickness), 0);
80
- rb_define_method(rb_klass, "line_type", RUBY_METHOD_FUNC(rb_line_type), 0);
81
- rb_define_method(rb_klass, "italic", RUBY_METHOD_FUNC(rb_italic), 0);
82
- }
83
-
84
42
  VALUE
85
43
  rb_allocate(VALUE klass)
86
44
  {
@@ -88,46 +46,32 @@ rb_allocate(VALUE klass)
88
46
  return Data_Make_Struct(klass, CvFont, 0, -1, ptr);
89
47
  }
90
48
 
91
-
92
49
  /*
93
- * call-seq:
94
- * CvFont.new(<i>face[,font_option]</i>) -> font
95
- *
96
- * Create font object.
97
- * <i>face</i> is font name identifier.
98
- *
99
- * Only a subset of Hershey fonts (http://sources.isc.org/utils/misc/hershey-font.txt) are supported now:
100
- * * :simplex - normal size sans-serif font
101
- * * :plain - small size sans-serif font
102
- * * :duplex - normal size sans-serif font (more complex than :simplex)
103
- * * :complex - normal size serif font
104
- * * :triplex - normal size serif font (more complex than :complex)
105
- * * :complex_small - smaller version of :complex
106
- * * :script_simplex - hand-writing style font
107
- * * :script_complex - more complex variant of :script_simplex
50
+ * Create font object
51
+ * @overload new(face, font_option = nil)
52
+ * @param face [Symbol] Font name identifier. Only a subset of Hershey fonts (http://sources.isc.org/utils/misc/hershey-font.txt) are supported now:
53
+ * - :simplex - normal size sans-serif font
54
+ * - :plain - small size sans-serif font
55
+ * - :duplex - normal size sans-serif font (more complex than :simplex)
56
+ * - :complex - normal size serif font
57
+ * - :triplex - normal size serif font (more complex than :complex)
58
+ * - :complex_small - smaller version of :complex
59
+ * - :script_simplex - hand-writing style font
60
+ * - :script_complex - more complex variant of :script_simplex
108
61
  *
109
- * <i>font_option</i> should be Hash include these keys.
110
- * :hscale
111
- * Horizontal scale. If equal to 1.0, the characters have the original width depending on the font type.
112
- * If equal to 0.5, the characters are of half the original width.
113
- * :vscale
114
- * Vertical scale. If equal to 1.0, the characters have the original height depending on the font type.
115
- * If equal to 0.5, the characters are of half the original height.
116
- * :shear
117
- * Approximate tangent of the character slope relative to the vertical line.
118
- * Zero value means a non-italic font, 1.0f means ~45degree slope, etc.
119
- * :thickness
120
- * Thickness of the text strokes.
121
- * :line_type
122
- * Type of the strokes, see CvMat#Line description.
123
- * :italic
124
- * If value is not nil or false that means italic or oblique font.
62
+ * @param font_option [Hash] should be Hash include these keys.
63
+ * @option font_option [Number] :hscale Horizontal scale. If equal to 1.0, the characters have the original width depending on the font type. If equal to 0.5, the characters are of half the original width.
64
+ * @option font_option [Number] :vscale Vertical scale. If equal to 1.0, the characters have the original height depending on the font type. If equal to 0.5, the characters are of half the original height.
65
+ * @option font_option [Number] :shear Approximate tangent of the character slope relative to the vertical line. Zero value means a non-italic font, 1.0f means ~45 degree slope, etc.
66
+ * @option font_option [Number] :thickness Thickness of the text strokes.
67
+ * @option font_option [Number] :line_type Type of the strokes, see CvMat#Line description.
68
+ * @option font_option [Number] :italic If value is not nil or false that means italic or oblique font.
125
69
  *
126
- * note: <i>font_option</i>'s default value is CvFont::FONT_OPTION.
127
- *
128
- * e.g. Create Font
70
+ * @example Create Font
129
71
  * OpenCV::CvFont.new(:simplex, :hscale => 2, :vslace => 2, :italic => true)
130
72
  * # create 2x bigger than normal, italic type font.
73
+ *
74
+ * @opencv_func cvInitFont
131
75
  */
132
76
  VALUE
133
77
  rb_initialize(int argc, VALUE *argv, VALUE self)
@@ -161,48 +105,124 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
161
105
  return self;
162
106
  }
163
107
 
164
-
108
+ /*
109
+ * Returns font face
110
+ * @overload face
111
+ * @return [Fixnum] Font face
112
+ */
165
113
  VALUE
166
114
  rb_face(VALUE self)
167
115
  {
168
116
  return INT2FIX(CVFONT(self)->font_face);
169
117
  }
170
118
 
119
+ /*
120
+ * Returns hscale
121
+ * @overload hscale
122
+ * @return [Number] hscale
123
+ */
171
124
  VALUE
172
125
  rb_hscale(VALUE self)
173
126
  {
174
127
  return rb_float_new(CVFONT(self)->hscale);
175
128
  }
176
129
 
130
+ /*
131
+ * Returns vscale
132
+ * @overload vscale
133
+ * @return [Number] vscale
134
+ */
177
135
  VALUE
178
136
  rb_vscale(VALUE self)
179
137
  {
180
138
  return rb_float_new(CVFONT(self)->vscale);
181
139
  }
182
140
 
141
+ /*
142
+ * Returns shear
143
+ * @overload shear
144
+ * @return [Number] shear
145
+ */
183
146
  VALUE
184
147
  rb_shear(VALUE self)
185
148
  {
186
149
  return rb_float_new(CVFONT(self)->shear);
187
150
  }
188
151
 
152
+ /*
153
+ * Returns thickness
154
+ * @overload thickness
155
+ * @return [Fixnum] thickness
156
+ */
189
157
  VALUE
190
158
  rb_thickness(VALUE self)
191
159
  {
192
160
  return INT2FIX(CVFONT(self)->thickness);
193
161
  }
194
162
 
163
+ /*
164
+ * Returns line type
165
+ * @overload line_type
166
+ * @return [Fixnum] line_type
167
+ */
195
168
  VALUE
196
169
  rb_line_type(VALUE self)
197
170
  {
198
171
  return INT2FIX(CVFONT(self)->line_type);
199
172
  }
200
173
 
174
+ /*
175
+ * Returns italic or not
176
+ * @overload italic
177
+ * @return [Boolean] self is italic or not
178
+ */
201
179
  VALUE
202
180
  rb_italic(VALUE self)
203
181
  {
204
182
  return ((CVFONT(self)->font_face & CV_FONT_ITALIC) > 0) ? Qtrue : Qfalse;
205
183
  }
206
184
 
185
+ void
186
+ init_ruby_class()
187
+ {
188
+ #if 0
189
+ // For documentation using YARD
190
+ VALUE opencv = rb_define_module("OpenCV");
191
+ #endif
192
+
193
+ if (rb_klass)
194
+ return;
195
+
196
+ VALUE opencv = rb_module_opencv();
197
+ rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
198
+ rb_define_alloc_func(rb_klass, rb_allocate);
199
+ VALUE face = rb_hash_new();
200
+ rb_define_const(rb_klass, "FACE", face);
201
+ rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
202
+ rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
203
+ rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
204
+ rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
205
+ rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
206
+ rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
207
+ rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));
208
+
209
+ VALUE default_option = rb_hash_new();
210
+ rb_define_const(rb_klass, "FONT_OPTION", default_option);
211
+ rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
212
+ rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
213
+ rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
214
+ rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
215
+ rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
216
+
217
+ rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
218
+ rb_define_method(rb_klass, "face", RUBY_METHOD_FUNC(rb_face), 0);
219
+ rb_define_method(rb_klass, "hscale", RUBY_METHOD_FUNC(rb_hscale), 0);
220
+ rb_define_method(rb_klass, "vscale", RUBY_METHOD_FUNC(rb_vscale), 0);
221
+ rb_define_method(rb_klass, "shear", RUBY_METHOD_FUNC(rb_shear), 0);
222
+ rb_define_method(rb_klass, "thickness", RUBY_METHOD_FUNC(rb_thickness), 0);
223
+ rb_define_method(rb_klass, "line_type", RUBY_METHOD_FUNC(rb_line_type), 0);
224
+ rb_define_method(rb_klass, "italic", RUBY_METHOD_FUNC(rb_italic), 0);
225
+ }
226
+
207
227
  __NAMESPACE_END_CVFONT
208
228
  __NAMESPACE_END_OPENCV