bonanza-ruby-opencv 0.0.13.20140330211753
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.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.yardopts +3 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +9 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +239 -0
- data/README.md +98 -0
- data/Rakefile +99 -0
- data/config.yml +7 -0
- data/examples/alpha_blend.rb +21 -0
- data/examples/contours/bitmap-contours-with-labels.png +0 -0
- data/examples/contours/bitmap-contours.png +0 -0
- data/examples/contours/bounding-box-detect-canny.rb +62 -0
- data/examples/contours/contour_retrieval_modes.rb +139 -0
- data/examples/contours/rotated-boxes.jpg +0 -0
- data/examples/convexhull.rb +47 -0
- data/examples/face_detect.rb +20 -0
- data/examples/facerec/create_csv.rb +43 -0
- data/examples/facerec/facerec_eigenfaces.rb +132 -0
- data/examples/facerec/facerec_fisherfaces.rb +131 -0
- data/examples/facerec/facerec_lbph.rb +116 -0
- data/examples/facerec/readme.md +111 -0
- data/examples/find_obj.rb +169 -0
- data/examples/houghcircle.rb +22 -0
- data/examples/images/box.png +0 -0
- data/examples/images/box_in_scene.png +0 -0
- data/examples/images/inpaint.png +0 -0
- data/examples/images/lena-256x256.jpg +0 -0
- data/examples/images/lena-eyes.jpg +0 -0
- data/examples/images/lenna-rotated.jpg +0 -0
- data/examples/images/lenna.jpg +0 -0
- data/examples/images/stuff.jpg +0 -0
- data/examples/images/tiffany.jpg +0 -0
- data/examples/inpaint.rb +57 -0
- data/examples/match_kdtree.rb +88 -0
- data/examples/match_template.rb +26 -0
- data/examples/paint.rb +70 -0
- data/examples/snake.rb +43 -0
- data/ext/opencv/algorithm.cpp +291 -0
- data/ext/opencv/algorithm.h +38 -0
- data/ext/opencv/curve.cpp +127 -0
- data/ext/opencv/curve.h +34 -0
- data/ext/opencv/cvavgcomp.cpp +64 -0
- data/ext/opencv/cvavgcomp.h +39 -0
- data/ext/opencv/cvbox2d.cpp +195 -0
- data/ext/opencv/cvbox2d.h +61 -0
- data/ext/opencv/cvcapture.cpp +607 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +233 -0
- data/ext/opencv/cvchain.h +46 -0
- data/ext/opencv/cvcircle32f.cpp +126 -0
- data/ext/opencv/cvcircle32f.h +52 -0
- data/ext/opencv/cvconnectedcomp.cpp +156 -0
- data/ext/opencv/cvconnectedcomp.h +49 -0
- data/ext/opencv/cvcontour.cpp +332 -0
- data/ext/opencv/cvcontour.h +48 -0
- data/ext/opencv/cvcontourtree.cpp +96 -0
- data/ext/opencv/cvcontourtree.h +41 -0
- data/ext/opencv/cvconvexitydefect.cpp +92 -0
- data/ext/opencv/cvconvexitydefect.h +42 -0
- data/ext/opencv/cverror.cpp +115 -0
- data/ext/opencv/cverror.h +28 -0
- data/ext/opencv/cvfeaturetree.cpp +123 -0
- data/ext/opencv/cvfeaturetree.h +55 -0
- data/ext/opencv/cvfont.cpp +228 -0
- data/ext/opencv/cvfont.h +64 -0
- data/ext/opencv/cvhaarclassifiercascade.cpp +148 -0
- data/ext/opencv/cvhaarclassifiercascade.h +39 -0
- data/ext/opencv/cvhistogram.cpp +715 -0
- data/ext/opencv/cvhistogram.h +73 -0
- data/ext/opencv/cvhumoments.cpp +178 -0
- data/ext/opencv/cvhumoments.h +51 -0
- data/ext/opencv/cvline.cpp +159 -0
- data/ext/opencv/cvline.h +54 -0
- data/ext/opencv/cvmat.cpp +6829 -0
- data/ext/opencv/cvmat.h +323 -0
- data/ext/opencv/cvmemstorage.cpp +73 -0
- data/ext/opencv/cvmemstorage.h +53 -0
- data/ext/opencv/cvmoments.cpp +293 -0
- data/ext/opencv/cvmoments.h +75 -0
- data/ext/opencv/cvpoint.cpp +265 -0
- data/ext/opencv/cvpoint.h +67 -0
- data/ext/opencv/cvpoint2d32f.cpp +216 -0
- data/ext/opencv/cvpoint2d32f.h +63 -0
- data/ext/opencv/cvpoint3d32f.cpp +252 -0
- data/ext/opencv/cvpoint3d32f.h +66 -0
- data/ext/opencv/cvrect.cpp +441 -0
- data/ext/opencv/cvrect.h +88 -0
- data/ext/opencv/cvscalar.cpp +301 -0
- data/ext/opencv/cvscalar.h +76 -0
- data/ext/opencv/cvseq.cpp +605 -0
- data/ext/opencv/cvseq.h +74 -0
- data/ext/opencv/cvsize.cpp +227 -0
- data/ext/opencv/cvsize.h +65 -0
- data/ext/opencv/cvsize2d32f.cpp +215 -0
- data/ext/opencv/cvsize2d32f.h +64 -0
- data/ext/opencv/cvslice.cpp +126 -0
- data/ext/opencv/cvslice.h +61 -0
- data/ext/opencv/cvsurfparams.cpp +208 -0
- data/ext/opencv/cvsurfparams.h +58 -0
- data/ext/opencv/cvsurfpoint.cpp +279 -0
- data/ext/opencv/cvsurfpoint.h +54 -0
- data/ext/opencv/cvtermcriteria.cpp +198 -0
- data/ext/opencv/cvtermcriteria.h +71 -0
- data/ext/opencv/cvtwopoints.cpp +122 -0
- data/ext/opencv/cvtwopoints.h +51 -0
- data/ext/opencv/cvutils.cpp +221 -0
- data/ext/opencv/cvutils.h +31 -0
- data/ext/opencv/cvvideowriter.cpp +142 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/eigenfaces.cpp +75 -0
- data/ext/opencv/eigenfaces.h +30 -0
- data/ext/opencv/extconf.rb +82 -0
- data/ext/opencv/facerecognizer.cpp +181 -0
- data/ext/opencv/facerecognizer.h +46 -0
- data/ext/opencv/fisherfaces.cpp +75 -0
- data/ext/opencv/fisherfaces.h +30 -0
- data/ext/opencv/gui.cpp +71 -0
- data/ext/opencv/gui.h +30 -0
- data/ext/opencv/iplconvkernel.cpp +198 -0
- data/ext/opencv/iplconvkernel.h +71 -0
- data/ext/opencv/iplimage.cpp +666 -0
- data/ext/opencv/iplimage.h +75 -0
- data/ext/opencv/lbph.cpp +78 -0
- data/ext/opencv/lbph.h +30 -0
- data/ext/opencv/mouseevent.cpp +186 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +833 -0
- data/ext/opencv/opencv.h +405 -0
- data/ext/opencv/pointset.cpp +280 -0
- data/ext/opencv/pointset.h +68 -0
- data/ext/opencv/trackbar.cpp +127 -0
- data/ext/opencv/trackbar.h +69 -0
- data/ext/opencv/window.cpp +377 -0
- data/ext/opencv/window.h +66 -0
- data/images/CvMat_sobel.png +0 -0
- data/images/CvMat_sub_rect.png +0 -0
- data/images/CvSeq_relationmap.png +0 -0
- data/lib/opencv.rb +12 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +4 -0
- data/test/eigenfaces_save.xml +7524 -0
- data/test/fisherfaces_save.xml +7530 -0
- data/test/helper.rb +166 -0
- data/test/lbph_save.xml +4304 -0
- data/test/runner.rb +30 -0
- data/test/samples/airplane.jpg +0 -0
- data/test/samples/baboon.jpg +0 -0
- data/test/samples/baboon200.jpg +0 -0
- data/test/samples/baboon200_rotated.jpg +0 -0
- data/test/samples/blank0.jpg +0 -0
- data/test/samples/blank1.jpg +0 -0
- data/test/samples/blank2.jpg +0 -0
- data/test/samples/blank3.jpg +0 -0
- data/test/samples/blank4.jpg +0 -0
- data/test/samples/blank5.jpg +0 -0
- data/test/samples/blank6.jpg +0 -0
- data/test/samples/blank7.jpg +0 -0
- data/test/samples/blank8.jpg +0 -0
- data/test/samples/blank9.jpg +0 -0
- data/test/samples/cat.jpg +0 -0
- data/test/samples/chessboard.jpg +0 -0
- data/test/samples/contours.jpg +0 -0
- data/test/samples/fruits.jpg +0 -0
- data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
- data/test/samples/inpaint-mask.bmp +0 -0
- data/test/samples/lena-256x256.jpg +0 -0
- data/test/samples/lena-32x32.jpg +0 -0
- data/test/samples/lena-eyes.jpg +0 -0
- data/test/samples/lena-inpaint.jpg +0 -0
- data/test/samples/lena.jpg +0 -0
- data/test/samples/lines.jpg +0 -0
- data/test/samples/messy0.jpg +0 -0
- data/test/samples/messy1.jpg +0 -0
- data/test/samples/movie_sample.avi +0 -0
- data/test/samples/one_way_train_0000.jpg +0 -0
- data/test/samples/one_way_train_0001.jpg +0 -0
- data/test/samples/partially_blank0.jpg +0 -0
- data/test/samples/partially_blank1.jpg +0 -0
- data/test/samples/smooth0.jpg +0 -0
- data/test/samples/smooth1.jpg +0 -0
- data/test/samples/smooth2.jpg +0 -0
- data/test/samples/smooth3.jpg +0 -0
- data/test/samples/smooth4.jpg +0 -0
- data/test/samples/smooth5.jpg +0 -0
- data/test/samples/smooth6.jpg +0 -0
- data/test/samples/str-cv-rotated.jpg +0 -0
- data/test/samples/str-cv.jpg +0 -0
- data/test/samples/str-ov.jpg +0 -0
- data/test/samples/stuff.jpg +0 -0
- data/test/test_curve.rb +43 -0
- data/test/test_cvavgcomp.rb +24 -0
- data/test/test_cvbox2d.rb +76 -0
- data/test/test_cvcapture.rb +183 -0
- data/test/test_cvchain.rb +108 -0
- data/test/test_cvcircle32f.rb +41 -0
- data/test/test_cvconnectedcomp.rb +61 -0
- data/test/test_cvcontour.rb +150 -0
- data/test/test_cvcontourtree.rb +43 -0
- data/test/test_cverror.rb +50 -0
- data/test/test_cvfeaturetree.rb +65 -0
- data/test/test_cvfont.rb +58 -0
- data/test/test_cvhaarclassifiercascade.rb +63 -0
- data/test/test_cvhistogram.rb +271 -0
- data/test/test_cvhumoments.rb +83 -0
- data/test/test_cvline.rb +50 -0
- data/test/test_cvmat.rb +3003 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2085 -0
- data/test/test_cvmoments.rb +180 -0
- data/test/test_cvpoint.rb +75 -0
- data/test/test_cvpoint2d32f.rb +75 -0
- data/test/test_cvpoint3d32f.rb +93 -0
- data/test/test_cvrect.rb +144 -0
- data/test/test_cvscalar.rb +113 -0
- data/test/test_cvseq.rb +295 -0
- data/test/test_cvsize.rb +75 -0
- data/test/test_cvsize2d32f.rb +75 -0
- data/test/test_cvslice.rb +31 -0
- data/test/test_cvsurfparams.rb +57 -0
- data/test/test_cvsurfpoint.rb +66 -0
- data/test/test_cvtermcriteria.rb +56 -0
- data/test/test_cvtwopoints.rb +40 -0
- data/test/test_cvvideowriter.rb +58 -0
- data/test/test_eigenfaces.rb +93 -0
- data/test/test_fisherfaces.rb +93 -0
- data/test/test_iplconvkernel.rb +54 -0
- data/test/test_iplimage.rb +232 -0
- data/test/test_lbph.rb +152 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +360 -0
- data/test/test_pointset.rb +128 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- data/yard_extension.rb +5 -0
- metadata +399 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvpoint.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVPOINT_H
|
11
|
+
#define RUBY_OPENCV_CVPOINT_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVPOINT namespace cCvPoint {
|
16
|
+
#define __NAMESPACE_END_CVPOINT }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVPOINT
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void init_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
26
|
+
|
27
|
+
VALUE rb_allocate(VALUE klass);
|
28
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
29
|
+
VALUE rb_x(VALUE self);
|
30
|
+
VALUE rb_set_x(VALUE self, VALUE x);
|
31
|
+
VALUE rb_y(VALUE self);
|
32
|
+
VALUE rb_set_y(VALUE self, VALUE y);
|
33
|
+
VALUE rb_check_equality(VALUE self, VALUE compare_to);
|
34
|
+
VALUE rb_check_inequality(VALUE self, VALUE compare_to);
|
35
|
+
VALUE rb_hash(VALUE self);
|
36
|
+
|
37
|
+
VALUE rb_to_s(VALUE self);
|
38
|
+
VALUE rb_to_ary(VALUE self);
|
39
|
+
|
40
|
+
VALUE new_object();
|
41
|
+
VALUE new_object(CvPoint point);
|
42
|
+
|
43
|
+
__NAMESPACE_END_CVPOINT
|
44
|
+
|
45
|
+
inline CvPoint*
|
46
|
+
CVPOINT(VALUE object){
|
47
|
+
CvPoint *ptr;
|
48
|
+
Data_Get_Struct(object, CvPoint, ptr);
|
49
|
+
return ptr;
|
50
|
+
}
|
51
|
+
|
52
|
+
inline CvPoint
|
53
|
+
VALUE_TO_CVPOINT(VALUE object)
|
54
|
+
{
|
55
|
+
if (cCvPoint::rb_compatible_q(cCvPoint::rb_class(), object)) {
|
56
|
+
return cvPoint(NUM2INT(rb_funcall(object, rb_intern("x"), 0)),
|
57
|
+
NUM2INT(rb_funcall(object, rb_intern("y"), 0)));
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
raise_compatible_typeerror(object, cCvPoint::rb_class());
|
61
|
+
}
|
62
|
+
throw "Should never reach here";
|
63
|
+
}
|
64
|
+
|
65
|
+
__NAMESPACE_END_OPENCV
|
66
|
+
|
67
|
+
#endif // RUBY_OPENCV_CVPOINT_H
|
@@ -0,0 +1,216 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvpoint2d32f.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvpoint2d32f.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvPoint2D32f
|
13
|
+
*
|
14
|
+
* This class means one point on X axis Y axis.
|
15
|
+
* X and Y takes the value of the Float. see also CvPoint
|
16
|
+
*
|
17
|
+
* C structure is here, very simple.
|
18
|
+
* typdef struct CvPoint2D32f {
|
19
|
+
* float x;
|
20
|
+
* float y;
|
21
|
+
* }
|
22
|
+
*/
|
23
|
+
__NAMESPACE_BEGIN_OPENCV
|
24
|
+
__NAMESPACE_BEGIN_CVPOINT2D32F
|
25
|
+
|
26
|
+
VALUE rb_klass;
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
rb_class()
|
30
|
+
{
|
31
|
+
return rb_klass;
|
32
|
+
}
|
33
|
+
|
34
|
+
/*
|
35
|
+
* call-seq:
|
36
|
+
* combatible?(obj)
|
37
|
+
*
|
38
|
+
* Return compatibility to CvPoint2D32f. Return true if object have method #x and #y.
|
39
|
+
*
|
40
|
+
* For example.
|
41
|
+
* class MyPoint2D32f
|
42
|
+
* def x
|
43
|
+
* 95.7
|
44
|
+
* end
|
45
|
+
* def y
|
46
|
+
* 70.2
|
47
|
+
* end
|
48
|
+
* end
|
49
|
+
* mp = MyPoint2D32f.new
|
50
|
+
* CvPoint2D32f.compatible?(mp) #=> true
|
51
|
+
* CvPoint2D32f.new(mp) #=> same as CvPoint2D32f(95.7, 70.2)
|
52
|
+
*/
|
53
|
+
VALUE
|
54
|
+
rb_compatible_q(VALUE klass, VALUE object)
|
55
|
+
{
|
56
|
+
return (rb_respond_to(object, rb_intern("x")) && rb_respond_to(object, rb_intern("y"))) ? Qtrue : Qfalse;
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE
|
60
|
+
rb_allocate(VALUE klass)
|
61
|
+
{
|
62
|
+
CvPoint2D32f *ptr;
|
63
|
+
return Data_Make_Struct(klass, CvPoint2D32f, 0, -1, ptr);
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* new
|
69
|
+
* new(obj)
|
70
|
+
* new(x, y)
|
71
|
+
*
|
72
|
+
* Create new 2D-coordinate, (x, y).
|
73
|
+
*
|
74
|
+
* new() is same as new(0.0, 0.0)
|
75
|
+
*
|
76
|
+
* new(obj) is same as new(obj.x.to_f, obj.y.to_f)
|
77
|
+
*/
|
78
|
+
VALUE
|
79
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
80
|
+
{
|
81
|
+
CvPoint2D32f *self_ptr = CVPOINT2D32F(self);
|
82
|
+
switch (argc) {
|
83
|
+
case 0:
|
84
|
+
break;
|
85
|
+
case 1: {
|
86
|
+
CvPoint2D32f point = VALUE_TO_CVPOINT2D32F(argv[0]);
|
87
|
+
self_ptr->x = point.x;
|
88
|
+
self_ptr->y = point.y;
|
89
|
+
break;
|
90
|
+
}
|
91
|
+
case 2:
|
92
|
+
self_ptr->x = NUM2DBL(argv[0]);
|
93
|
+
self_ptr->y = NUM2DBL(argv[1]);
|
94
|
+
break;
|
95
|
+
default:
|
96
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
return self;
|
100
|
+
}
|
101
|
+
|
102
|
+
/*
|
103
|
+
* Return parameter on x-axis.
|
104
|
+
*/
|
105
|
+
VALUE
|
106
|
+
rb_x(VALUE self)
|
107
|
+
{
|
108
|
+
return rb_float_new(CVPOINT2D32F(self)->x);
|
109
|
+
}
|
110
|
+
|
111
|
+
/*
|
112
|
+
* call-seq:
|
113
|
+
* x = val
|
114
|
+
*
|
115
|
+
* Set x-axis parameter, return self.
|
116
|
+
*/
|
117
|
+
VALUE
|
118
|
+
rb_set_x(VALUE self, VALUE x)
|
119
|
+
{
|
120
|
+
CVPOINT2D32F(self)->x = NUM2DBL(x);
|
121
|
+
return self;
|
122
|
+
}
|
123
|
+
|
124
|
+
/*
|
125
|
+
* Return parameter on y-axis.
|
126
|
+
*/
|
127
|
+
VALUE
|
128
|
+
rb_y(VALUE self)
|
129
|
+
{
|
130
|
+
return rb_float_new(CVPOINT2D32F(self)->y);
|
131
|
+
}
|
132
|
+
|
133
|
+
/*
|
134
|
+
* call-seq:
|
135
|
+
* y = val
|
136
|
+
*
|
137
|
+
* Set y-axis parameter, return self.
|
138
|
+
*/
|
139
|
+
VALUE
|
140
|
+
rb_set_y(VALUE self, VALUE y)
|
141
|
+
{
|
142
|
+
CVPOINT2D32F(self)->y = NUM2DBL(y);
|
143
|
+
return self;
|
144
|
+
}
|
145
|
+
|
146
|
+
/*
|
147
|
+
* call-seq:
|
148
|
+
* to_s -> "<OpenCV::CvSize2D32f:(self.x,self.y)>"
|
149
|
+
*
|
150
|
+
* Return x and y by String.
|
151
|
+
*/
|
152
|
+
VALUE
|
153
|
+
rb_to_s(VALUE self)
|
154
|
+
{
|
155
|
+
const int i = 4;
|
156
|
+
VALUE str[i];
|
157
|
+
str[0] = rb_str_new2("<%s:(%g,%g)>");
|
158
|
+
str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
|
159
|
+
str[2] = rb_x(self);
|
160
|
+
str[3] = rb_y(self);
|
161
|
+
return rb_f_sprintf(i, str);
|
162
|
+
}
|
163
|
+
|
164
|
+
/*
|
165
|
+
* call-seq:
|
166
|
+
* to_ary -> [x, y]
|
167
|
+
*
|
168
|
+
* Return x and y by Array.
|
169
|
+
*/
|
170
|
+
VALUE
|
171
|
+
rb_to_ary(VALUE self)
|
172
|
+
{
|
173
|
+
return rb_ary_new3(2, rb_x(self), rb_y(self));
|
174
|
+
}
|
175
|
+
|
176
|
+
VALUE
|
177
|
+
new_object(CvPoint2D32f point)
|
178
|
+
{
|
179
|
+
VALUE object = rb_allocate(rb_klass);
|
180
|
+
*CVPOINT2D32F(object) = point;
|
181
|
+
return object;
|
182
|
+
}
|
183
|
+
|
184
|
+
void
|
185
|
+
init_ruby_class()
|
186
|
+
{
|
187
|
+
#if 0
|
188
|
+
// For documentation using YARD
|
189
|
+
VALUE opencv = rb_define_module("OpenCV");
|
190
|
+
#endif
|
191
|
+
|
192
|
+
if (rb_klass)
|
193
|
+
return;
|
194
|
+
/*
|
195
|
+
* opencv = rb_define_module("OpenCV");
|
196
|
+
*
|
197
|
+
* note: this comment is used by rdoc.
|
198
|
+
*/
|
199
|
+
VALUE opencv = rb_module_opencv();
|
200
|
+
|
201
|
+
rb_klass = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
202
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
203
|
+
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
204
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
205
|
+
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
206
|
+
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
207
|
+
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
208
|
+
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
209
|
+
|
210
|
+
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
211
|
+
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
212
|
+
rb_define_alias(rb_klass, "to_a", "to_ary");
|
213
|
+
}
|
214
|
+
|
215
|
+
__NAMESPACE_END_CVPOINT2D32F
|
216
|
+
__NAMESPACE_END_OPENCV
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvpoint2d32f.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVPOINT2D32F_H
|
11
|
+
#define RUBY_OPENCV_CVPOINT2D32F_H
|
12
|
+
|
13
|
+
#define __NAMESPACE_BEGIN_CVPOINT2D32F namespace cCvPoint2D32f {
|
14
|
+
#define __NAMESPACE_END_CVPOINT2D32F }
|
15
|
+
|
16
|
+
#include "opencv.h"
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVPOINT2D32F
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void init_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
26
|
+
|
27
|
+
VALUE rb_allocate(VALUE klass);
|
28
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
29
|
+
VALUE rb_x(VALUE self);
|
30
|
+
VALUE rb_set_x(VALUE self, VALUE x);
|
31
|
+
VALUE rb_y(VALUE self);
|
32
|
+
VALUE rb_set_y(VALUE self, VALUE y);
|
33
|
+
|
34
|
+
VALUE rb_to_s(VALUE self);
|
35
|
+
VALUE rb_to_ary(VALUE self);
|
36
|
+
|
37
|
+
VALUE new_object(CvPoint2D32f point);
|
38
|
+
|
39
|
+
__NAMESPACE_END_CVPOINT2D32F
|
40
|
+
|
41
|
+
inline CvPoint2D32f*
|
42
|
+
CVPOINT2D32F(VALUE object)
|
43
|
+
{
|
44
|
+
CvPoint2D32f *ptr;
|
45
|
+
Data_Get_Struct(object, CvPoint2D32f, ptr);
|
46
|
+
return ptr;
|
47
|
+
}
|
48
|
+
|
49
|
+
inline CvPoint2D32f
|
50
|
+
VALUE_TO_CVPOINT2D32F(VALUE object)
|
51
|
+
{
|
52
|
+
if (cCvPoint2D32f::rb_compatible_q(cCvPoint2D32f::rb_class(), object)) {
|
53
|
+
return cvPoint2D32f(NUM2DBL(rb_funcall(object, rb_intern("x"), 0)),
|
54
|
+
NUM2DBL(rb_funcall(object, rb_intern("y"), 0)));
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
raise_compatible_typeerror(object, cCvPoint2D32f::rb_class());
|
58
|
+
}
|
59
|
+
throw "Should never reach here";
|
60
|
+
}
|
61
|
+
|
62
|
+
__NAMESPACE_END_OPENCV
|
63
|
+
#endif // RUBY_OPENCV_CVPOINT2D32F_H
|
@@ -0,0 +1,252 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvpoint3d32f.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2008 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvpoint3d32f.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvPoint3D32f
|
13
|
+
*
|
14
|
+
* This class means one point on X axis Y axis.
|
15
|
+
* X and Y takes the value of the Float. see also CvPoint
|
16
|
+
*
|
17
|
+
* C structure is here, very simple.
|
18
|
+
* typdef struct CvPoint3D32f {
|
19
|
+
* float x;
|
20
|
+
* float y;
|
21
|
+
* float z;
|
22
|
+
* }
|
23
|
+
*/
|
24
|
+
__NAMESPACE_BEGIN_OPENCV
|
25
|
+
__NAMESPACE_BEGIN_CVPOINT3D32F
|
26
|
+
|
27
|
+
VALUE rb_klass;
|
28
|
+
|
29
|
+
VALUE
|
30
|
+
rb_class()
|
31
|
+
{
|
32
|
+
return rb_klass;
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq:
|
37
|
+
* combatible?(obj)
|
38
|
+
*
|
39
|
+
* Return compatibility to CvPoint3D32f. Return true if object have method #x and #y and #z.
|
40
|
+
*
|
41
|
+
* For example.
|
42
|
+
* class MyPoint3D32f
|
43
|
+
* def x
|
44
|
+
* 95.7
|
45
|
+
* end
|
46
|
+
* def y
|
47
|
+
* 70.2
|
48
|
+
* end
|
49
|
+
* def z
|
50
|
+
* 10.0
|
51
|
+
* end
|
52
|
+
* end
|
53
|
+
* mp = MyPoint3D32f.new
|
54
|
+
* CvPoint3D32f.compatible?(mp) #=> true
|
55
|
+
* CvPoint3D32f.new(mp) #=> same as CvPoint3D32f(95.7, 70.2)
|
56
|
+
*/
|
57
|
+
VALUE
|
58
|
+
rb_compatible_q(VALUE klass, VALUE object)
|
59
|
+
{
|
60
|
+
return (rb_respond_to(object, rb_intern("x")) &&
|
61
|
+
rb_respond_to(object, rb_intern("y")) &&
|
62
|
+
rb_respond_to(object, rb_intern("z"))) ? Qtrue : Qfalse;
|
63
|
+
}
|
64
|
+
|
65
|
+
VALUE
|
66
|
+
rb_allocate(VALUE klass)
|
67
|
+
{
|
68
|
+
CvPoint3D32f *ptr;
|
69
|
+
return Data_Make_Struct(klass, CvPoint3D32f, 0, -1, ptr);
|
70
|
+
}
|
71
|
+
|
72
|
+
/*
|
73
|
+
* call-seq:
|
74
|
+
* new
|
75
|
+
* new(obj)
|
76
|
+
* new(x, y, z)
|
77
|
+
*
|
78
|
+
* Create new 3D-coordinate, (x, y, z).
|
79
|
+
*
|
80
|
+
* new() is same as new(0.0, 0.0, 0.0)
|
81
|
+
*
|
82
|
+
* new(obj) is same as new(obj.x.to_f, obj.y.to_f, obj.z.to_f)
|
83
|
+
*/
|
84
|
+
VALUE
|
85
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
86
|
+
{
|
87
|
+
CvPoint3D32f *self_ptr = CVPOINT3D32F(self);
|
88
|
+
switch (argc) {
|
89
|
+
case 0:
|
90
|
+
break;
|
91
|
+
case 1: {
|
92
|
+
CvPoint3D32f point = VALUE_TO_CVPOINT3D32F(argv[0]);
|
93
|
+
self_ptr->x = point.x;
|
94
|
+
self_ptr->y = point.y;
|
95
|
+
self_ptr->z = point.z;
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
case 3:
|
99
|
+
self_ptr->x = NUM2DBL(argv[0]);
|
100
|
+
self_ptr->y = NUM2DBL(argv[1]);
|
101
|
+
self_ptr->z = NUM2DBL(argv[2]);
|
102
|
+
break;
|
103
|
+
default:
|
104
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
return self;
|
108
|
+
}
|
109
|
+
|
110
|
+
/*
|
111
|
+
* Return parameter on x-axis.
|
112
|
+
*/
|
113
|
+
VALUE
|
114
|
+
rb_x(VALUE self)
|
115
|
+
{
|
116
|
+
return rb_float_new(CVPOINT2D32F(self)->x);
|
117
|
+
}
|
118
|
+
|
119
|
+
/*
|
120
|
+
* call-seq:
|
121
|
+
* x = val
|
122
|
+
*
|
123
|
+
* Set x-axis parameter, return self.
|
124
|
+
*/
|
125
|
+
VALUE
|
126
|
+
rb_set_x(VALUE self, VALUE x)
|
127
|
+
{
|
128
|
+
CVPOINT2D32F(self)->x = NUM2DBL(x);
|
129
|
+
return self;
|
130
|
+
}
|
131
|
+
|
132
|
+
/*
|
133
|
+
* Return parameter on y-axis.
|
134
|
+
*/
|
135
|
+
VALUE
|
136
|
+
rb_y(VALUE self)
|
137
|
+
{
|
138
|
+
return rb_float_new(CVPOINT2D32F(self)->y);
|
139
|
+
}
|
140
|
+
|
141
|
+
/*
|
142
|
+
* call-seq:
|
143
|
+
* y = val
|
144
|
+
*
|
145
|
+
* Set y-axis parameter, return self.
|
146
|
+
*/
|
147
|
+
VALUE
|
148
|
+
rb_set_y(VALUE self, VALUE y)
|
149
|
+
{
|
150
|
+
CVPOINT2D32F(self)->y = NUM2DBL(y);
|
151
|
+
return self;
|
152
|
+
}
|
153
|
+
|
154
|
+
/*
|
155
|
+
* Return parameter on z-axis.
|
156
|
+
*/
|
157
|
+
VALUE
|
158
|
+
rb_z(VALUE self)
|
159
|
+
{
|
160
|
+
return rb_float_new(CVPOINT3D32F(self)->z);
|
161
|
+
}
|
162
|
+
|
163
|
+
/*
|
164
|
+
* call-seq:
|
165
|
+
* z = val
|
166
|
+
*
|
167
|
+
* Set z-axis parameter, return self.
|
168
|
+
*/
|
169
|
+
VALUE
|
170
|
+
rb_set_z(VALUE self, VALUE z)
|
171
|
+
{
|
172
|
+
CVPOINT3D32F(self)->z = NUM2DBL(z);
|
173
|
+
return self;
|
174
|
+
}
|
175
|
+
|
176
|
+
/*
|
177
|
+
* call-seq:
|
178
|
+
* to_s -> "<OpenCV::CvSize3D32f:(self.x,self.y,self.z)>"
|
179
|
+
*
|
180
|
+
* Return x and y by String.
|
181
|
+
*/
|
182
|
+
VALUE
|
183
|
+
rb_to_s(VALUE self)
|
184
|
+
{
|
185
|
+
const int i = 5;
|
186
|
+
VALUE str[i];
|
187
|
+
str[0] = rb_str_new2("<%s:(%g,%g,%g)>");
|
188
|
+
str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
|
189
|
+
str[2] = rb_x(self);
|
190
|
+
str[3] = rb_y(self);
|
191
|
+
str[4] = rb_z(self);
|
192
|
+
return rb_f_sprintf(i, str);
|
193
|
+
}
|
194
|
+
|
195
|
+
/*
|
196
|
+
* call-seq:
|
197
|
+
* to_ary -> [x, y, z]
|
198
|
+
*
|
199
|
+
* Return x and y by Array.
|
200
|
+
*/
|
201
|
+
VALUE
|
202
|
+
rb_to_ary(VALUE self)
|
203
|
+
{
|
204
|
+
return rb_ary_new3(3, rb_x(self), rb_y(self), rb_z(self));
|
205
|
+
}
|
206
|
+
|
207
|
+
VALUE
|
208
|
+
new_object(CvPoint3D32f point)
|
209
|
+
{
|
210
|
+
VALUE object = rb_allocate(rb_klass);
|
211
|
+
*CVPOINT3D32F(object) = point;
|
212
|
+
return object;
|
213
|
+
}
|
214
|
+
|
215
|
+
void
|
216
|
+
init_ruby_class()
|
217
|
+
{
|
218
|
+
#if 0
|
219
|
+
// For documentation using YARD
|
220
|
+
VALUE opencv = rb_define_module("OpenCV");
|
221
|
+
VALUE cvpoint2d32f = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
222
|
+
#endif
|
223
|
+
|
224
|
+
if (rb_klass)
|
225
|
+
return;
|
226
|
+
/*
|
227
|
+
* opencv = rb_define_module("OpenCV");
|
228
|
+
* cvpoint2d32f = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
229
|
+
*
|
230
|
+
* note: this comment is used by rdoc.
|
231
|
+
*/
|
232
|
+
VALUE opencv = rb_module_opencv();
|
233
|
+
VALUE cvpoint2d32f = cCvPoint2D32f::rb_class();
|
234
|
+
rb_klass = rb_define_class_under(opencv, "CvPoint3D32f", cvpoint2d32f);
|
235
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
236
|
+
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
237
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
238
|
+
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
239
|
+
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
240
|
+
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
241
|
+
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
242
|
+
rb_define_method(rb_klass, "z", RUBY_METHOD_FUNC(rb_z), 0);
|
243
|
+
rb_define_method(rb_klass, "z=", RUBY_METHOD_FUNC(rb_set_z), 1);
|
244
|
+
|
245
|
+
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
246
|
+
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
247
|
+
rb_define_alias(rb_klass, "to_a", "to_ary");
|
248
|
+
}
|
249
|
+
|
250
|
+
__NAMESPACE_END_CVPOINT3D32F
|
251
|
+
__NAMESPACE_END_OPENCV
|
252
|
+
|