bantic-ruby-opencv 0.0.8

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 (118) hide show
  1. data/CHANGELOG +2 -0
  2. data/License.txt +30 -0
  3. data/README.rdoc +90 -0
  4. data/Rakefile +15 -0
  5. data/examples/convexhull.rb +47 -0
  6. data/examples/face_detect.rb +24 -0
  7. data/examples/houghcircle.rb +23 -0
  8. data/examples/inpaint.png +0 -0
  9. data/examples/inpaint.rb +42 -0
  10. data/examples/paint.rb +71 -0
  11. data/examples/snake.rb +42 -0
  12. data/examples/stuff.jpg +0 -0
  13. data/ext/curve.cpp +103 -0
  14. data/ext/curve.h +34 -0
  15. data/ext/cvavgcomp.cpp +67 -0
  16. data/ext/cvavgcomp.h +39 -0
  17. data/ext/cvbox2d.cpp +114 -0
  18. data/ext/cvbox2d.h +53 -0
  19. data/ext/cvcapture.cpp +276 -0
  20. data/ext/cvcapture.h +54 -0
  21. data/ext/cvchain.cpp +184 -0
  22. data/ext/cvchain.h +43 -0
  23. data/ext/cvchaincode.cpp +49 -0
  24. data/ext/cvchaincode.h +43 -0
  25. data/ext/cvcircle32f.cpp +90 -0
  26. data/ext/cvcircle32f.h +53 -0
  27. data/ext/cvcondensation.cpp +230 -0
  28. data/ext/cvcondensation.h +49 -0
  29. data/ext/cvconnectedcomp.cpp +115 -0
  30. data/ext/cvconnectedcomp.h +46 -0
  31. data/ext/cvcontour.cpp +217 -0
  32. data/ext/cvcontour.h +47 -0
  33. data/ext/cvcontourtree.cpp +86 -0
  34. data/ext/cvcontourtree.h +41 -0
  35. data/ext/cvconvexitydefect.cpp +103 -0
  36. data/ext/cvconvexitydefect.h +42 -0
  37. data/ext/cverror.cpp +140 -0
  38. data/ext/cverror.h +79 -0
  39. data/ext/cvfont.cpp +173 -0
  40. data/ext/cvfont.h +56 -0
  41. data/ext/cvhaarclassifiercascade.cpp +159 -0
  42. data/ext/cvhaarclassifiercascade.h +41 -0
  43. data/ext/cvhistogram.cpp +200 -0
  44. data/ext/cvhistogram.h +51 -0
  45. data/ext/cvindex.cpp +73 -0
  46. data/ext/cvindex.h +40 -0
  47. data/ext/cvline.cpp +106 -0
  48. data/ext/cvline.h +52 -0
  49. data/ext/cvmat.cpp +4809 -0
  50. data/ext/cvmat.h +286 -0
  51. data/ext/cvmatnd.cpp +44 -0
  52. data/ext/cvmatnd.h +28 -0
  53. data/ext/cvmemstorage.cpp +64 -0
  54. data/ext/cvmemstorage.h +53 -0
  55. data/ext/cvmoments.cpp +204 -0
  56. data/ext/cvmoments.h +48 -0
  57. data/ext/cvpoint.cpp +229 -0
  58. data/ext/cvpoint.h +59 -0
  59. data/ext/cvpoint2d32f.cpp +213 -0
  60. data/ext/cvpoint2d32f.h +61 -0
  61. data/ext/cvpoint3d32f.cpp +245 -0
  62. data/ext/cvpoint3d32f.h +64 -0
  63. data/ext/cvrect.cpp +340 -0
  64. data/ext/cvrect.h +79 -0
  65. data/ext/cvscalar.cpp +227 -0
  66. data/ext/cvscalar.h +63 -0
  67. data/ext/cvseq.cpp +583 -0
  68. data/ext/cvseq.h +71 -0
  69. data/ext/cvset.cpp +63 -0
  70. data/ext/cvset.h +39 -0
  71. data/ext/cvsize.cpp +223 -0
  72. data/ext/cvsize.h +63 -0
  73. data/ext/cvsize2d32f.cpp +180 -0
  74. data/ext/cvsize2d32f.h +59 -0
  75. data/ext/cvslice.cpp +82 -0
  76. data/ext/cvslice.h +53 -0
  77. data/ext/cvsparsemat.cpp +44 -0
  78. data/ext/cvsparsemat.h +28 -0
  79. data/ext/cvtermcriteria.cpp +183 -0
  80. data/ext/cvtermcriteria.h +71 -0
  81. data/ext/cvtwopoints.cpp +98 -0
  82. data/ext/cvtwopoints.h +50 -0
  83. data/ext/cvvector.cpp +206 -0
  84. data/ext/cvvector.h +54 -0
  85. data/ext/cvvideowriter.cpp +116 -0
  86. data/ext/cvvideowriter.h +41 -0
  87. data/ext/extconf.rb +58 -0
  88. data/ext/gui.cpp +65 -0
  89. data/ext/gui.h +33 -0
  90. data/ext/iplconvkernel.cpp +177 -0
  91. data/ext/iplconvkernel.h +52 -0
  92. data/ext/iplimage.cpp +238 -0
  93. data/ext/iplimage.h +54 -0
  94. data/ext/mouseevent.cpp +184 -0
  95. data/ext/mouseevent.h +59 -0
  96. data/ext/opencv.cpp +481 -0
  97. data/ext/opencv.h +356 -0
  98. data/ext/point3dset.cpp +41 -0
  99. data/ext/point3dset.h +31 -0
  100. data/ext/pointset.cpp +238 -0
  101. data/ext/pointset.h +69 -0
  102. data/ext/trackbar.cpp +122 -0
  103. data/ext/trackbar.h +65 -0
  104. data/ext/window.cpp +368 -0
  105. data/ext/window.h +56 -0
  106. data/images/CvMat_sobel.png +0 -0
  107. data/images/CvMat_sub_rect.png +0 -0
  108. data/images/CvSeq_relationmap.png +0 -0
  109. data/images/face_detect_from_lena.jpg +0 -0
  110. data/lib/opencv.rb +3 -0
  111. data/lib/version.rb +3 -0
  112. data/metadata +191 -0
  113. data/ruby-opencv.gemspec +33 -0
  114. data/setup/setup.cygwin.rb +120 -0
  115. data/setup/setup.mingw.rb +99 -0
  116. data/setup/setup.mswin32.rb +103 -0
  117. data/test/test_opencv.rb +6 -0
  118. metadata +272 -0
@@ -0,0 +1,42 @@
1
+ /************************************************************
2
+
3
+ cvconvexitydefect.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVCONVEXITYDEFECT_H
11
+ #define RUBY_OPENCV_CVCONVEXITYDEFECT_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVCONVEXITYDEFECT namespace cCvConvexityDefect{
16
+ #define __NAMESPACE_END_CVCONVEXITYDEFECT }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ VALUE rb_start(VALUE self);
26
+ VALUE rb_end(VALUE self);
27
+ VALUE rb_depth_point(VALUE self);
28
+ VALUE rb_depth(VALUE self);
29
+
30
+ __NAMESPACE_END_CVCONVEXITYDEFECT
31
+
32
+ inline CvConvexityDefect*
33
+ CVCONVEXITYDEFECT(VALUE object)
34
+ {
35
+ CvConvexityDefect *ptr;
36
+ Data_Get_Struct(object, CvConvexityDefect, ptr);
37
+ return ptr;
38
+ }
39
+
40
+ __NAMESPACE_END_OPENCV
41
+
42
+ #endif // RUBY_OPENCV_CVCONVEXITYDEFECT_H
@@ -0,0 +1,140 @@
1
+ /************************************************************
2
+
3
+ cverror.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cverror.h"
11
+ /*
12
+ * Document-module: OpenCV::CvError
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
59
+ */
60
+ #define RESIST_CVERROR(object_name, error_code, parent) st_insert(cv_error, (st_data_t)error_code, (st_data_t)rb_define_class_under(rb_module_opencv(), object_name, parent))
61
+
62
+ __NAMESPACE_BEGIN_OPENCV
63
+ __NAMESPACE_BEGIN_CVERROR
64
+
65
+ st_table *cv_error = st_init_numtable();
66
+
67
+ VALUE module;
68
+
69
+ void
70
+ define_ruby_module()
71
+ {
72
+ /*
73
+ * opencv = rb_define_module("OpenCV");
74
+ *
75
+ * note: this comment is used by rdoc.
76
+ */
77
+ VALUE opencv = rb_module_opencv();
78
+
79
+ module = rb_define_module_under(opencv, "CvError");
80
+ RESIST_CVERROR("CvStatusBackTrace", CV_StsBackTrace, rb_eStandardError);
81
+ RESIST_CVERROR("CvStatusError", CV_StsError, rb_eStandardError);
82
+ RESIST_CVERROR("CvStatusInternal", CV_StsInternal, rb_eStandardError);
83
+ RESIST_CVERROR("CvStatusNoMemory", CV_StsNoMem, rb_eNoMemError);
84
+ RESIST_CVERROR("CvStatusBadArgument", CV_StsBadArg, rb_eArgError);
85
+ RESIST_CVERROR("CvStatusBadFunction", CV_StsBadFunc, rb_eStandardError);
86
+ RESIST_CVERROR("CvStatusNoConverge", CV_StsNoConv, rb_eStandardError);
87
+ RESIST_CVERROR("CvStatusAutoTrace", CV_StsAutoTrace, rb_eStandardError);
88
+
89
+ RESIST_CVERROR("CvHeaderIsNull", CV_HeaderIsNull, rb_eStandardError);
90
+ RESIST_CVERROR("CvBadImageSize", CV_BadImageSize, rb_eRangeError);
91
+ RESIST_CVERROR("CvBadOffset", CV_BadOffset, rb_eStandardError);
92
+ RESIST_CVERROR("CvBadDataPointer", CV_BadDataPtr, rb_eStandardError);
93
+ RESIST_CVERROR("CvBadStep", CV_BadStep, rb_eStandardError);
94
+ RESIST_CVERROR("CvBadModelOrChannelSequence", CV_BadModelOrChSeq, rb_eStandardError);
95
+ RESIST_CVERROR("CvBadNumChannels", CV_BadNumChannels, rb_eStandardError);
96
+ RESIST_CVERROR("CvBadNumChannel1U", CV_BadNumChannel1U, rb_eStandardError);
97
+ RESIST_CVERROR("CvNBadDepth", CV_BadDepth, rb_eStandardError);
98
+ RESIST_CVERROR("CvBadAlphaChannel", CV_BadAlphaChannel, rb_eStandardError);
99
+ RESIST_CVERROR("CvBadOrder", CV_BadOrder, rb_eStandardError);
100
+ RESIST_CVERROR("CvBadOrigin", CV_BadOrigin, rb_eStandardError);
101
+ RESIST_CVERROR("CvBadAlign", CV_BadAlign, rb_eStandardError);
102
+ RESIST_CVERROR("CvBadCallBack", CV_BadCallBack, rb_eStandardError);
103
+ RESIST_CVERROR("CvBadTileSize", CV_BadTileSize, rb_eStandardError);
104
+ RESIST_CVERROR("CvBadCOI", CV_BadCOI, rb_eStandardError);
105
+ RESIST_CVERROR("CvBadROISize", CV_BadROISize, rb_eStandardError);
106
+
107
+ RESIST_CVERROR("CvMaskIsTiled", CV_MaskIsTiled, rb_eStandardError);
108
+
109
+ RESIST_CVERROR("CvStatusNullPointer", CV_StsNullPtr, rb_eStandardError);
110
+ RESIST_CVERROR("CvStatusVectorLengthError", CV_StsVecLengthErr, rb_eStandardError);
111
+ RESIST_CVERROR("CvStatusFilterStructContentError", CV_StsFilterStructContentErr, rb_eStandardError);
112
+ RESIST_CVERROR("CvStatusKernelStructContentError", CV_StsKernelStructContentErr, rb_eStandardError);
113
+ RESIST_CVERROR("CvStatusFilterOffsetError", CV_StsFilterOffsetErr, rb_eStandardError);
114
+
115
+ RESIST_CVERROR("CvStatusBadSize", CV_StsBadSize, rb_eStandardError);
116
+ RESIST_CVERROR("CvStatusDivByZero", CV_StsDivByZero, rb_eStandardError);
117
+ RESIST_CVERROR("CvStatusInplaceNotSupported", CV_StsInplaceNotSupported, rb_eStandardError);
118
+ RESIST_CVERROR("CvStatusObjectNotFound", CV_StsObjectNotFound, rb_eStandardError);
119
+ RESIST_CVERROR("CvStatusUnmatchedFormats", CV_StsUnmatchedFormats, rb_eStandardError);
120
+ RESIST_CVERROR("CvStatusBadFlag", CV_StsBadFlag, rb_eStandardError);
121
+ RESIST_CVERROR("CvStatusBadPoint", CV_StsBadPoint, rb_eStandardError);
122
+ RESIST_CVERROR("CvStatusBadMask", CV_StsBadMask, rb_eStandardError);
123
+ RESIST_CVERROR("CvStatusUnmatchedSizes", CV_StsUnmatchedSizes, rb_eStandardError);
124
+ RESIST_CVERROR("CvStatusUnsupportedFormat", CV_StsUnsupportedFormat, rb_eStandardError);
125
+ RESIST_CVERROR("CvStatusOutOfRange", CV_StsOutOfRange, rb_eStandardError);
126
+ RESIST_CVERROR("CvStatusParseError", CV_StsParseError, rb_eStandardError);
127
+ RESIST_CVERROR("CvStatusNotImplemented", CV_StsNotImplemented, rb_eNotImpError);
128
+ RESIST_CVERROR("CvStsBadMemoryBlock", CV_StsBadMemBlock,rb_eStandardError);
129
+ }
130
+
131
+ VALUE
132
+ by_code(int error_code)
133
+ {
134
+ VALUE klass = 0;
135
+ st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
136
+ return klass ? klass : rb_eStandardError;
137
+ }
138
+
139
+ __NAMESPACE_END_CVERROR
140
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,79 @@
1
+ /************************************************************
2
+
3
+ cverror.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVERROR_H
11
+ #define RUBY_OPENCV_CVERROR_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVERROR namespace mCvError{
16
+ #define __NAMESPACE_END_CVERROR }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVERROR
20
+
21
+ /*
22
+ VALUE
23
+ status_back_trace,
24
+ status_error,
25
+ status_internal,
26
+ status_no_memory,
27
+ status_bad_argument,
28
+ status_bad_function,
29
+ status_no_converge,
30
+ status_auto_trace,
31
+
32
+ header_is_null,
33
+ bad_image_size,
34
+ bad_offset,
35
+ bad_data_pointer,
36
+ bad_step,
37
+ bad_model_or_channel_seqence,
38
+ bad_num_channels,
39
+ bad_num_channel1U,
40
+ bad_depth,
41
+ bad_alpha_channel,
42
+ bad_order,
43
+ bad_origin,
44
+ bad_align,
45
+ bad_callback,
46
+ bad_tile_size,
47
+ bad_COI,
48
+ bad_ROI_size,
49
+
50
+ mask_is_tiled,
51
+
52
+ status_null_pointer,
53
+ status_vector_length_error,
54
+ status_filter_struct_content_error,
55
+ status_kernel_struct_content_error,
56
+ status_filter_offset_error,
57
+
58
+ status_bad_size,
59
+ status_div_by_zero,
60
+ status_inplace_not_supported,
61
+ status_object_not_found,
62
+ status_unmatched_formats,
63
+ status_bad_flags,
64
+ status_bad_point,
65
+ status_bad_mask,
66
+ status_unmatched_sizes,
67
+ status_unsupported_format,
68
+ status_out_of_range,
69
+ status_parse_error,
70
+ status_not_implemented,
71
+ status_bad_memory_block;
72
+ */
73
+ void define_ruby_module();
74
+ VALUE by_code(int error_code);
75
+
76
+ __NAMESPACE_END_CVERROR
77
+ __NAMESPACE_END_OPENCV
78
+
79
+ #endif // RUBY_OPENCV_CVERROR_H
@@ -0,0 +1,173 @@
1
+ /************************************************************
2
+
3
+ cvfont.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvfont.h"
11
+ /*
12
+ * Document-class: OpenCV::CvFont
13
+ *
14
+ * Font structure that can be passed to text rendering functions.
15
+ * see CvMat#put_text, CvMat#put_text!
16
+ */
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVFONT
20
+
21
+ VALUE rb_klass;
22
+
23
+ VALUE
24
+ rb_class()
25
+ {
26
+ return rb_klass;
27
+ }
28
+
29
+ void
30
+ define_ruby_class()
31
+ {
32
+ if (rb_klass)
33
+ return;
34
+ /*
35
+ * opencv = rb_define_module("OpenCV");
36
+ *
37
+ * note: this comment is used by rdoc.
38
+ */
39
+ VALUE opencv = rb_module_opencv();
40
+
41
+ rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
42
+ rb_define_alloc_func(rb_klass, rb_allocate);
43
+ VALUE face = rb_hash_new();
44
+ rb_define_const(rb_klass, "FACE", face);
45
+ rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
46
+ rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
47
+ rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
48
+ rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
49
+ rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
50
+ rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
51
+ rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));
52
+
53
+ VALUE default_option = rb_hash_new();
54
+ rb_define_const(rb_klass, "FONT_OPTION", default_option);
55
+ rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
56
+ rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
57
+ rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
58
+ rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
59
+ rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
60
+
61
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
62
+ }
63
+
64
+ VALUE
65
+ rb_allocate(VALUE klass)
66
+ {
67
+ CvFont *ptr;
68
+ return Data_Make_Struct(klass, CvFont, 0, -1, ptr);
69
+ }
70
+
71
+
72
+ /*
73
+ * call-seq:
74
+ * CvFont.new(<i>face[,font_option]</i>) -> font
75
+ *
76
+ * Create font object.
77
+ * <i>face</i> is font name identifier.
78
+ *
79
+ * Only a subset of Hershey fonts (http://sources.isc.org/utils/misc/hershey-font.txt) are supported now:
80
+ * * :simplex - normal size sans-serif font
81
+ * * :plain - small size sans-serif font
82
+ * * :duplex - normal size sans-serif font (more complex than :simplex)
83
+ * * :complex - normal size serif font
84
+ * * :triplex - normal size serif font (more complex than :complex)
85
+ * * :complex_small - smaller version of :complex
86
+ * * :script_simplex - hand-writing style font
87
+ * * :script_complex - more complex variant of :script_simplex
88
+ *
89
+ * <i>font_option</i> should be Hash include these keys.
90
+ * :hscale
91
+ * Horizontal scale. If equal to 1.0, the characters have the original width depending on the font type.
92
+ * If equal to 0.5, the characters are of half the original width.
93
+ * :vscale
94
+ * Vertical scale. If equal to 1.0, the characters have the original height depending on the font type.
95
+ * If equal to 0.5, the characters are of half the original height.
96
+ * :shear
97
+ * Approximate tangent of the character slope relative to the vertical line.
98
+ * Zero value means a non-italic font, 1.0f means ~45degree slope, etc.
99
+ * :thickness
100
+ * Thickness of the text strokes.
101
+ * :line_type
102
+ * Type of the strokes, see CvMat#Line description.
103
+ * :italic
104
+ * If value is not nil or false that means italic or oblique font.
105
+ *
106
+ * note: <i>font_option</i>'s default value is CvFont::FONT_OPTION.
107
+ *
108
+ * e.g. Create Font
109
+ * OpenCV::CvFont.new(:simplex, :hscale => 2, :vslace => 2, :italic => true)
110
+ * # create 2x bigger than normal, italic type font.
111
+ */
112
+ VALUE
113
+ rb_initialize(int argc, VALUE *argv, VALUE self)
114
+ {
115
+ VALUE face, font_option;
116
+ rb_scan_args(argc, argv, "11", &face, &font_option);
117
+ Check_Type(face, T_SYMBOL);
118
+ face = rb_hash_aref(rb_const_get(cCvFont::rb_class(), rb_intern("FACE")), face);
119
+ if (NIL_P(face)) {
120
+ rb_raise(rb_eArgError, "undefined face.");
121
+ }
122
+ font_option = FONT_OPTION(font_option);
123
+ /*
124
+ cvInitFont(CVFONT(self),
125
+ (FIX2INT(face) | FO_ITALIC(font_option)),
126
+ FO_HSCALE(font_option),
127
+ FO_VSCALE(font_option),
128
+ FO_SHEAR(font_option),
129
+ FO_THICKNESS(font_option),
130
+ FO_LINE_TYPE(font_option));
131
+ */
132
+ return self;
133
+ }
134
+
135
+
136
+ VALUE
137
+ rb_face(VALUE self)
138
+ {
139
+ return FIX2INT(CVFONT(self)->font_face);
140
+ }
141
+
142
+ VALUE
143
+ rb_hscale(VALUE self)
144
+ {
145
+ return rb_float_new(CVFONT(self)->hscale);
146
+ }
147
+
148
+ VALUE
149
+ rb_vscale(VALUE self)
150
+ {
151
+ return rb_float_new(CVFONT(self)->vscale);
152
+ }
153
+
154
+ VALUE
155
+ rb_shear(VALUE self)
156
+ {
157
+ return rb_float_new(CVFONT(self)->shear);
158
+ }
159
+
160
+ VALUE
161
+ rb_thickness(VALUE self)
162
+ {
163
+ return FIX2INT(CVFONT(self)->thickness);
164
+ }
165
+
166
+ VALUE
167
+ rb_line_type(VALUE self)
168
+ {
169
+ return FIX2INT(CVFONT(self)->line_type);
170
+ }
171
+
172
+ __NAMESPACE_END_CVFONT
173
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,56 @@
1
+ /************************************************************
2
+
3
+ cvfont.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVFONT_H
11
+ #define RUBY_OPENCV_CVFONT_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVFONT namespace cCvFont{
16
+ #define __NAMESPACE_END_CVFONT }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVFONT
20
+
21
+ #define FONT_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("FONT_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("FONT_OPTION")), rb_intern("merge"), 1, font_option)
22
+ #define FO_ITALIC(op) ({VALUE _italic = rb_hash_aref(op, ID2SYM(rb_intern("italic"))); NIL_P(_italic) ? 0 : _italic == Qfalse ? 0 : 1;})
23
+ #define FO_HSCALE(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("hscale"))))
24
+ #define FO_VSCALE(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("vscale"))))
25
+ #define FO_SHEAR(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("shear"))))
26
+ #define FO_THICKNESS(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("thickness"))))
27
+ #define FO_LINE_TYPE(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("line_type"))) == ID2SYM("aa") ? INT2FIX(CV_AA) : rb_hash_aref(op, ID2SYM(rb_intern("line_type"))))
28
+
29
+
30
+ VALUE rb_class();
31
+
32
+ void define_ruby_class();
33
+
34
+ VALUE rb_allocate(VALUE klass);
35
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
36
+
37
+ VALUE rb_face(VALUE self);
38
+ VALUE rb_hscale(VALUE self);
39
+ VALUE rb_vscale(VALUE self);
40
+ VALUE rb_shear(VALUE self);
41
+ VALUE rb_thickness(VALUE self);
42
+ VALUE rb_line_type(VALUE self);
43
+
44
+ __NAMESPACE_END_CVFONT
45
+
46
+ inline CvFont*
47
+ CVFONT(VALUE object)
48
+ {
49
+ CvFont *ptr;
50
+ Data_Get_Struct(object, CvFont, ptr);
51
+ return ptr;
52
+ }
53
+
54
+ __NAMESPACE_END_OPENCV
55
+
56
+ #endif // RUBY_OPENCV_CVFONT_H