ruby-opencv 0.0.9.pre2-mingw32
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 +25 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +227 -0
- data/README.md +98 -0
- data/Rakefile +90 -0
- data/config.yml +7 -0
- data/examples/alpha_blend.rb +21 -0
- data/examples/box.png +0 -0
- data/examples/box_in_scene.png +0 -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/find_obj.rb +169 -0
- data/examples/houghcircle.rb +22 -0
- data/examples/inpaint.png +0 -0
- data/examples/inpaint.rb +57 -0
- data/examples/lenna-rotated.jpg +0 -0
- data/examples/lenna.jpg +0 -0
- data/examples/match_kdtree.rb +88 -0
- data/examples/matching_to_many_images.rb +16 -0
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +3 -0
- data/examples/paint.rb +70 -0
- data/examples/snake.rb +43 -0
- data/examples/stuff.jpg +0 -0
- data/examples/tiffany.jpg +0 -0
- data/ext/opencv/curve.cpp +112 -0
- data/ext/opencv/curve.h +34 -0
- data/ext/opencv/cvavgcomp.cpp +67 -0
- data/ext/opencv/cvavgcomp.h +39 -0
- data/ext/opencv/cvbox2d.cpp +197 -0
- data/ext/opencv/cvbox2d.h +61 -0
- data/ext/opencv/cvcapture.cpp +506 -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 +116 -0
- data/ext/opencv/cvcircle32f.h +52 -0
- data/ext/opencv/cvcondensation.cpp +282 -0
- data/ext/opencv/cvcondensation.h +49 -0
- data/ext/opencv/cvconnectedcomp.cpp +143 -0
- data/ext/opencv/cvconnectedcomp.h +49 -0
- data/ext/opencv/cvcontour.cpp +296 -0
- data/ext/opencv/cvcontour.h +48 -0
- data/ext/opencv/cvcontourtree.cpp +91 -0
- data/ext/opencv/cvcontourtree.h +41 -0
- data/ext/opencv/cvconvexitydefect.cpp +103 -0
- data/ext/opencv/cvconvexitydefect.h +42 -0
- data/ext/opencv/cverror.cpp +159 -0
- data/ext/opencv/cverror.h +28 -0
- data/ext/opencv/cvfeaturetree.cpp +125 -0
- data/ext/opencv/cvfeaturetree.h +55 -0
- data/ext/opencv/cvfont.cpp +208 -0
- data/ext/opencv/cvfont.h +64 -0
- data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
- data/ext/opencv/cvhaarclassifiercascade.h +39 -0
- data/ext/opencv/cvhistogram.cpp +546 -0
- data/ext/opencv/cvhistogram.h +73 -0
- data/ext/opencv/cvhumoments.cpp +139 -0
- data/ext/opencv/cvhumoments.h +51 -0
- data/ext/opencv/cvline.cpp +154 -0
- data/ext/opencv/cvline.h +54 -0
- data/ext/opencv/cvmat.cpp +5848 -0
- data/ext/opencv/cvmat.h +284 -0
- data/ext/opencv/cvmatnd.cpp +44 -0
- data/ext/opencv/cvmatnd.h +28 -0
- data/ext/opencv/cvmemstorage.cpp +68 -0
- data/ext/opencv/cvmemstorage.h +53 -0
- data/ext/opencv/cvmoments.cpp +287 -0
- data/ext/opencv/cvmoments.h +75 -0
- data/ext/opencv/cvpoint.cpp +228 -0
- data/ext/opencv/cvpoint.h +64 -0
- data/ext/opencv/cvpoint2d32f.cpp +211 -0
- data/ext/opencv/cvpoint2d32f.h +63 -0
- data/ext/opencv/cvpoint3d32f.cpp +245 -0
- data/ext/opencv/cvpoint3d32f.h +66 -0
- data/ext/opencv/cvrect.cpp +333 -0
- data/ext/opencv/cvrect.h +79 -0
- data/ext/opencv/cvscalar.cpp +236 -0
- data/ext/opencv/cvscalar.h +71 -0
- data/ext/opencv/cvseq.cpp +599 -0
- data/ext/opencv/cvseq.h +74 -0
- data/ext/opencv/cvsize.cpp +221 -0
- data/ext/opencv/cvsize.h +65 -0
- data/ext/opencv/cvsize2d32f.cpp +209 -0
- data/ext/opencv/cvsize2d32f.h +64 -0
- data/ext/opencv/cvslice.cpp +120 -0
- data/ext/opencv/cvslice.h +61 -0
- data/ext/opencv/cvsparsemat.cpp +44 -0
- data/ext/opencv/cvsparsemat.h +28 -0
- data/ext/opencv/cvsurfparams.cpp +199 -0
- data/ext/opencv/cvsurfparams.h +58 -0
- data/ext/opencv/cvsurfpoint.cpp +223 -0
- data/ext/opencv/cvsurfpoint.h +52 -0
- data/ext/opencv/cvtermcriteria.cpp +192 -0
- data/ext/opencv/cvtermcriteria.h +71 -0
- data/ext/opencv/cvtwopoints.cpp +116 -0
- data/ext/opencv/cvtwopoints.h +51 -0
- data/ext/opencv/cvutils.cpp +192 -0
- data/ext/opencv/cvutils.h +30 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/extconf.rb +83 -0
- data/ext/opencv/gui.cpp +68 -0
- data/ext/opencv/gui.h +30 -0
- data/ext/opencv/iplconvkernel.cpp +192 -0
- data/ext/opencv/iplconvkernel.h +71 -0
- data/ext/opencv/iplimage.cpp +644 -0
- data/ext/opencv/iplimage.h +73 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +722 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +274 -0
- data/ext/opencv/pointset.h +68 -0
- data/ext/opencv/trackbar.cpp +121 -0
- data/ext/opencv/trackbar.h +69 -0
- data/ext/opencv/window.cpp +357 -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/images/face_detect_from_lena.jpg +0 -0
- data/lib/opencv.rb +12 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +44 -0
- data/test/helper.rb +166 -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 +2947 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2025 -0
- data/test/test_cvmat_matching.rb +57 -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_iplconvkernel.rb +54 -0
- data/test/test_iplimage.rb +236 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +324 -0
- data/test/test_pointset.rb +126 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +386 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvpoint3d32f.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2008 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVPOINT3D32F_H
|
11
|
+
#define RUBY_OPENCV_CVPOINT3D32F_H
|
12
|
+
|
13
|
+
#define __NAMESPACE_BEGIN_CVPOINT3D32F namespace cCvPoint3D32f {
|
14
|
+
#define __NAMESPACE_END_CVPOINT3D32F }
|
15
|
+
|
16
|
+
#include "opencv.h"
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVPOINT3D32F
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void define_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_z(VALUE self);
|
34
|
+
VALUE rb_set_z(VALUE self, VALUE z);
|
35
|
+
|
36
|
+
VALUE rb_to_s(VALUE self);
|
37
|
+
VALUE rb_to_ary(VALUE self);
|
38
|
+
|
39
|
+
VALUE new_object(CvPoint3D32f point);
|
40
|
+
|
41
|
+
__NAMESPACE_END_CVPOINT3D32F
|
42
|
+
|
43
|
+
inline CvPoint3D32f*
|
44
|
+
CVPOINT3D32F(VALUE object)
|
45
|
+
{
|
46
|
+
CvPoint3D32f *ptr;
|
47
|
+
Data_Get_Struct(object, CvPoint3D32f, ptr);
|
48
|
+
return ptr;
|
49
|
+
}
|
50
|
+
|
51
|
+
inline CvPoint3D32f
|
52
|
+
VALUE_TO_CVPOINT3D32F(VALUE object)
|
53
|
+
{
|
54
|
+
if (cCvPoint3D32f::rb_compatible_q(cCvPoint3D32f::rb_class(), object)) {
|
55
|
+
return cvPoint3D32f(NUM2DBL(rb_funcall(object, rb_intern("x"), 0)),
|
56
|
+
NUM2DBL(rb_funcall(object, rb_intern("y"), 0)),
|
57
|
+
NUM2DBL(rb_funcall(object, rb_intern("z"), 0)));
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
raise_compatible_typeerror(object, cCvPoint3D32f::rb_class());
|
61
|
+
}
|
62
|
+
throw "Should never reach here";
|
63
|
+
}
|
64
|
+
|
65
|
+
__NAMESPACE_END_OPENCV
|
66
|
+
#endif // RUBY_OPENCV_CVPOINT3D32F_H
|
@@ -0,0 +1,333 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvrect.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvrect.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvRect
|
13
|
+
*
|
14
|
+
* This class have coordinate of top-left point(x, y) and size, width and height.
|
15
|
+
*
|
16
|
+
*
|
17
|
+
* C stracture is here, very simple.
|
18
|
+
* typdef struct CvRect {
|
19
|
+
* int x;
|
20
|
+
* int y;
|
21
|
+
* int width;
|
22
|
+
* int height;
|
23
|
+
* }
|
24
|
+
*
|
25
|
+
*/
|
26
|
+
__NAMESPACE_BEGIN_OPENCV
|
27
|
+
__NAMESPACE_BEGIN_CVRECT
|
28
|
+
|
29
|
+
VALUE rb_klass;
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
rb_class()
|
33
|
+
{
|
34
|
+
return rb_klass;
|
35
|
+
}
|
36
|
+
|
37
|
+
void
|
38
|
+
define_ruby_class()
|
39
|
+
{
|
40
|
+
if (rb_klass)
|
41
|
+
return;
|
42
|
+
/*
|
43
|
+
* opencv = rb_define_module("OpenCV");
|
44
|
+
*
|
45
|
+
* note: this comment is used by rdoc.
|
46
|
+
*/
|
47
|
+
VALUE opencv = rb_module_opencv();
|
48
|
+
rb_klass = rb_define_class_under(opencv, "CvRect", rb_cObject);
|
49
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
50
|
+
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
51
|
+
rb_define_singleton_method(rb_klass, "max_rect", RUBY_METHOD_FUNC(rb_max_rect), 2);
|
52
|
+
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
53
|
+
|
54
|
+
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
55
|
+
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
56
|
+
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
57
|
+
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
58
|
+
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
59
|
+
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
60
|
+
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
61
|
+
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
62
|
+
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
63
|
+
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
64
|
+
rb_define_method(rb_klass, "top_left", RUBY_METHOD_FUNC(rb_top_left), 0);
|
65
|
+
rb_define_method(rb_klass, "top_right", RUBY_METHOD_FUNC(rb_top_right), 0);
|
66
|
+
rb_define_method(rb_klass, "bottom_left", RUBY_METHOD_FUNC(rb_bottom_left), 0);
|
67
|
+
rb_define_method(rb_klass, "bottom_right", RUBY_METHOD_FUNC(rb_bottom_right), 0);
|
68
|
+
}
|
69
|
+
|
70
|
+
/*
|
71
|
+
* call-seq:
|
72
|
+
* combatible?(obj)
|
73
|
+
*
|
74
|
+
* Return compatibility to CvRect. Return true if object have method #x and #y and #width and #height.
|
75
|
+
*
|
76
|
+
* For example.
|
77
|
+
* class MyRect
|
78
|
+
* def x
|
79
|
+
* 1
|
80
|
+
* end
|
81
|
+
* def y
|
82
|
+
* 2
|
83
|
+
* end
|
84
|
+
* def width
|
85
|
+
* 10
|
86
|
+
* end
|
87
|
+
* def height
|
88
|
+
* 20
|
89
|
+
* end
|
90
|
+
* end
|
91
|
+
* mr = MyRect.new
|
92
|
+
* CvRect.compatible?(mp) #=> true
|
93
|
+
* CvRect.new(mp) #=> same as CvRect(1, 2, 10, 20)
|
94
|
+
*/
|
95
|
+
VALUE
|
96
|
+
rb_compatible_q(VALUE klass, VALUE object)
|
97
|
+
{
|
98
|
+
return (rb_respond_to(object, rb_intern("x")) &&
|
99
|
+
rb_respond_to(object, rb_intern("y")) &&
|
100
|
+
rb_respond_to(object, rb_intern("width")) &&
|
101
|
+
rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
|
102
|
+
}
|
103
|
+
|
104
|
+
/*
|
105
|
+
* call-seq:
|
106
|
+
* max_rect(rect1, rect2) -> cvrect
|
107
|
+
*
|
108
|
+
* Finds bounding rectangle for given rectangles.
|
109
|
+
*/
|
110
|
+
VALUE
|
111
|
+
rb_max_rect(VALUE klass, VALUE rect1, VALUE rect2)
|
112
|
+
{
|
113
|
+
return cCvRect::new_object(cvMaxRect(CVRECT(rect1), CVRECT(rect2)));
|
114
|
+
}
|
115
|
+
|
116
|
+
VALUE
|
117
|
+
rb_allocate(VALUE klass)
|
118
|
+
{
|
119
|
+
CvRect *ptr;
|
120
|
+
return Data_Make_Struct(klass, CvRect, 0, -1, ptr);
|
121
|
+
}
|
122
|
+
|
123
|
+
/*
|
124
|
+
* call-seq:
|
125
|
+
* new -> CvRect.new(0, 0, 0, 0)
|
126
|
+
* new(obj) -> CvRect.new(obj.x.to_i, obj.y.to_i, obj.width.to_i, obj.height.to_i)
|
127
|
+
* new(x, y, width, height)
|
128
|
+
*
|
129
|
+
* Create new rectangle area. (x, y) is top-left point, and width, height is size of area.
|
130
|
+
* It is dropped below the decimal point.
|
131
|
+
*
|
132
|
+
* new() is same as new(0, 0, 0, 0)
|
133
|
+
*
|
134
|
+
* new(obj) is same as new(obj.x.to_i, obj.y.to_i, obj.width.to_i, obj.height.to_i)
|
135
|
+
*/
|
136
|
+
VALUE
|
137
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
138
|
+
{
|
139
|
+
CvRect *self_ptr = CVRECT(self);
|
140
|
+
switch (argc) {
|
141
|
+
case 0:
|
142
|
+
break;
|
143
|
+
case 1: {
|
144
|
+
CvRect rect = VALUE_TO_CVRECT(argv[0]);
|
145
|
+
self_ptr->x = rect.x;
|
146
|
+
self_ptr->y = rect.y;
|
147
|
+
self_ptr->width = rect.width;
|
148
|
+
self_ptr->height = rect.height;
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
case 4:
|
152
|
+
self_ptr->x = NUM2INT(argv[0]);
|
153
|
+
self_ptr->y = NUM2INT(argv[1]);
|
154
|
+
self_ptr->width = NUM2INT(argv[2]);
|
155
|
+
self_ptr->height = NUM2INT(argv[3]);
|
156
|
+
break;
|
157
|
+
default:
|
158
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
return self;
|
162
|
+
}
|
163
|
+
|
164
|
+
/*
|
165
|
+
* Return parameter on x-axis of top-left point.
|
166
|
+
*/
|
167
|
+
VALUE
|
168
|
+
rb_x(VALUE self)
|
169
|
+
{
|
170
|
+
return INT2NUM(CVRECT(self)->x);
|
171
|
+
}
|
172
|
+
|
173
|
+
/*
|
174
|
+
* call-seq:
|
175
|
+
* x = val
|
176
|
+
*
|
177
|
+
* Set x-axis parameter of top-left point, return self.
|
178
|
+
* It is dropped below the decimal point.
|
179
|
+
*/
|
180
|
+
VALUE
|
181
|
+
rb_set_x(VALUE self, VALUE x)
|
182
|
+
{
|
183
|
+
CVRECT(self)->x = NUM2INT(x);
|
184
|
+
return self;
|
185
|
+
}
|
186
|
+
|
187
|
+
/*
|
188
|
+
* Return parameter on y-axis of top-left point.
|
189
|
+
*/
|
190
|
+
VALUE
|
191
|
+
rb_y(VALUE self)
|
192
|
+
{
|
193
|
+
return INT2NUM(CVRECT(self)->y);
|
194
|
+
}
|
195
|
+
|
196
|
+
/*
|
197
|
+
* call-seq:
|
198
|
+
* y = val
|
199
|
+
*
|
200
|
+
* Set y-axis parameter of top-left point, return self.
|
201
|
+
* It is dropped below the decimal point.
|
202
|
+
*/
|
203
|
+
VALUE
|
204
|
+
rb_set_y(VALUE self, VALUE y)
|
205
|
+
{
|
206
|
+
CVRECT(self)->y = NUM2INT(y);
|
207
|
+
return self;
|
208
|
+
}
|
209
|
+
|
210
|
+
/*
|
211
|
+
* Return size of x-axis.
|
212
|
+
*/
|
213
|
+
VALUE
|
214
|
+
rb_width(VALUE self)
|
215
|
+
{
|
216
|
+
return INT2NUM(CVRECT(self)->width);
|
217
|
+
}
|
218
|
+
|
219
|
+
/*
|
220
|
+
* call-seq:
|
221
|
+
* width = val
|
222
|
+
*
|
223
|
+
* Set x-axis size, return self.
|
224
|
+
* It is dropped below the decimal point.
|
225
|
+
*/
|
226
|
+
VALUE
|
227
|
+
rb_set_width(VALUE self, VALUE x)
|
228
|
+
{
|
229
|
+
CVRECT(self)->width = NUM2INT(x);
|
230
|
+
return self;
|
231
|
+
}
|
232
|
+
|
233
|
+
/*
|
234
|
+
* Return size of y-axis.
|
235
|
+
*/
|
236
|
+
VALUE
|
237
|
+
rb_height(VALUE self)
|
238
|
+
{
|
239
|
+
return INT2NUM(CVRECT(self)->height);
|
240
|
+
}
|
241
|
+
|
242
|
+
/*
|
243
|
+
* call-seq:
|
244
|
+
* height = val
|
245
|
+
*
|
246
|
+
* Set y-axis size, return self.
|
247
|
+
* It is dropped below the decimal point.
|
248
|
+
*/
|
249
|
+
VALUE
|
250
|
+
rb_set_height(VALUE self, VALUE y)
|
251
|
+
{
|
252
|
+
CVRECT(self)->height = NUM2INT(y);
|
253
|
+
return self;
|
254
|
+
}
|
255
|
+
|
256
|
+
/*
|
257
|
+
* Return center point of rectangle.
|
258
|
+
*/
|
259
|
+
VALUE
|
260
|
+
rb_center(VALUE self)
|
261
|
+
{
|
262
|
+
CvRect *rect = CVRECT(self);
|
263
|
+
return cCvPoint2D32f::new_object(cvPoint2D32f((float)rect->x + (float)rect->width / 2.0,
|
264
|
+
(float)rect->y + (float)rect->height / 2.0));
|
265
|
+
}
|
266
|
+
|
267
|
+
/*
|
268
|
+
* Return 4 points (top-left, bottom-left, bottom-right, top-right)
|
269
|
+
*/
|
270
|
+
VALUE
|
271
|
+
rb_points(VALUE self)
|
272
|
+
{
|
273
|
+
CvRect *rect = CVRECT(self);
|
274
|
+
return rb_ary_new3(4,
|
275
|
+
cCvPoint::new_object(cvPoint(rect->x, rect->y)),
|
276
|
+
cCvPoint::new_object(cvPoint(rect->x, rect->y + rect->height)),
|
277
|
+
cCvPoint::new_object(cvPoint(rect->x + rect->width, rect->y + rect->height)),
|
278
|
+
cCvPoint::new_object(cvPoint(rect->x + rect->width, rect->y))
|
279
|
+
);
|
280
|
+
}
|
281
|
+
|
282
|
+
/*
|
283
|
+
* Return top-left point of rectangle.
|
284
|
+
*/
|
285
|
+
VALUE
|
286
|
+
rb_top_left(VALUE self)
|
287
|
+
{
|
288
|
+
CvRect* rect = CVRECT(self);
|
289
|
+
return cCvPoint::new_object(cvPoint(rect->x, rect->y));
|
290
|
+
}
|
291
|
+
|
292
|
+
/*
|
293
|
+
* Return top-right point of rectangle.
|
294
|
+
*/
|
295
|
+
VALUE
|
296
|
+
rb_top_right(VALUE self)
|
297
|
+
{
|
298
|
+
CvRect* rect = CVRECT(self);
|
299
|
+
return cCvPoint::new_object(cvPoint(rect->x + rect->width, rect->y));
|
300
|
+
}
|
301
|
+
|
302
|
+
/*
|
303
|
+
* Return bottom-left point of rectangle.
|
304
|
+
*/
|
305
|
+
VALUE
|
306
|
+
rb_bottom_left(VALUE self)
|
307
|
+
{
|
308
|
+
CvRect* rect = CVRECT(self);
|
309
|
+
return cCvPoint::new_object(cvPoint(rect->x,
|
310
|
+
rect->y + rect->height));
|
311
|
+
}
|
312
|
+
|
313
|
+
/*
|
314
|
+
* Return bottom-right point of rectangle.
|
315
|
+
*/
|
316
|
+
VALUE
|
317
|
+
rb_bottom_right(VALUE self)
|
318
|
+
{
|
319
|
+
CvRect* rect = CVRECT(self);
|
320
|
+
return cCvPoint::new_object(cvPoint(rect->x + rect->width,
|
321
|
+
rect->y + rect->height));
|
322
|
+
}
|
323
|
+
|
324
|
+
VALUE
|
325
|
+
new_object(CvRect rect)
|
326
|
+
{
|
327
|
+
VALUE object = rb_allocate(rb_klass);
|
328
|
+
*CVRECT(object) = rect;
|
329
|
+
return object;
|
330
|
+
}
|
331
|
+
|
332
|
+
__NAMESPACE_END_CVRECT
|
333
|
+
__NAMESPACE_END_OPENCV
|
data/ext/opencv/cvrect.h
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvrect.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVRECT_H
|
11
|
+
#define RUBY_OPENCV_CVRECT_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVRECT namespace cCvRect {
|
16
|
+
#define __NAMESPACE_END_CVRECT }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVRECT
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void define_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
26
|
+
VALUE rb_max_rect(VALUE klass, VALUE rect1, VALUE rect2);
|
27
|
+
|
28
|
+
VALUE rb_allocate(VALUE klass);
|
29
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
30
|
+
VALUE rb_x(VALUE self);
|
31
|
+
VALUE rb_set_x(VALUE self, VALUE x);
|
32
|
+
VALUE rb_y(VALUE self);
|
33
|
+
VALUE rb_set_y(VALUE self, VALUE y);
|
34
|
+
VALUE rb_width(VALUE self);
|
35
|
+
VALUE rb_set_width(VALUE self, VALUE width);
|
36
|
+
VALUE rb_height(VALUE self);
|
37
|
+
VALUE rb_set_height(VALUE self, VALUE height);
|
38
|
+
|
39
|
+
VALUE rb_center(VALUE self);
|
40
|
+
VALUE rb_points(VALUE self);
|
41
|
+
VALUE rb_top_left(VALUE self);
|
42
|
+
VALUE rb_set_top_left(VALUE self, VALUE point);
|
43
|
+
VALUE rb_top_right(VALUE self);
|
44
|
+
VALUE rb_set_top_right(VALUE self, VALUE point);
|
45
|
+
VALUE rb_bottom_left(VALUE self);
|
46
|
+
VALUE rb_set_bottom_left(VALUE self, VALUE point);
|
47
|
+
VALUE rb_bottom_right(VALUE self);
|
48
|
+
VALUE rb_set_bottom_right(VALUE self, VALUE point);
|
49
|
+
|
50
|
+
VALUE new_object(CvRect rect);
|
51
|
+
|
52
|
+
__NAMESPACE_END_CVRECT
|
53
|
+
|
54
|
+
inline CvRect*
|
55
|
+
CVRECT(VALUE object)
|
56
|
+
{
|
57
|
+
CvRect *ptr;
|
58
|
+
Data_Get_Struct(object, CvRect, ptr);
|
59
|
+
return ptr;
|
60
|
+
}
|
61
|
+
|
62
|
+
inline CvRect
|
63
|
+
VALUE_TO_CVRECT(VALUE object)
|
64
|
+
{
|
65
|
+
if (cCvRect::rb_compatible_q(cCvRect::rb_class(), object)) {
|
66
|
+
return cvRect(NUM2INT(rb_funcall(object, rb_intern("x"), 0)),
|
67
|
+
NUM2INT(rb_funcall(object, rb_intern("y"), 0)),
|
68
|
+
NUM2INT(rb_funcall(object, rb_intern("width"), 0)),
|
69
|
+
NUM2INT(rb_funcall(object, rb_intern("height"), 0)));
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
raise_compatible_typeerror(object, cCvRect::rb_class());
|
73
|
+
}
|
74
|
+
throw "Should never reach here";
|
75
|
+
}
|
76
|
+
|
77
|
+
__NAMESPACE_END_OPENCV
|
78
|
+
|
79
|
+
#endif // RUBY_OPENCV_CVRECT_H
|