ruby-opencv 0.0.8-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/DEVELOPERS_NOTE.md +120 -0
- data/Gemfile +9 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +226 -0
- data/README.md +98 -0
- data/Rakefile +32 -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 +499 -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 +194 -0
- data/ext/opencv/cvutils.h +29 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -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/lib/opencv.rb +3 -0
- data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
- data/ext/opencv/lib/opencv/version.rb +3 -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/extconf.rb +75 -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 +3 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +43 -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 +414 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvsurfparams.h -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVSURFPARAMS_H
|
11
|
+
#define RUBY_OPENCV_CVSURFPARAMS_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVSURFPARAMS namespace cCvSURFParams {
|
16
|
+
#define __NAMESPACE_END_CVSURFPARAMS }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVSURFPARAMS
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void define_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_allocate(VALUE klass);
|
26
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
27
|
+
VALUE rb_get_hessian_threshold(VALUE self);
|
28
|
+
VALUE rb_set_hessian_threshold(VALUE self, VALUE value);
|
29
|
+
VALUE rb_get_extended(VALUE self);
|
30
|
+
VALUE rb_set_extended(VALUE self, VALUE value);
|
31
|
+
VALUE rb_get_n_octaves(VALUE self);
|
32
|
+
VALUE rb_set_n_octaves(VALUE self, VALUE value);
|
33
|
+
VALUE rb_get_n_octave_layers(VALUE self);
|
34
|
+
VALUE rb_set_n_octave_layers(VALUE self, VALUE value);
|
35
|
+
|
36
|
+
VALUE new_object(CvSURFPoint *cvsurfparams);
|
37
|
+
|
38
|
+
__NAMESPACE_END_CVSURFPARAMS
|
39
|
+
|
40
|
+
inline CvSURFParams*
|
41
|
+
CVSURFPARAMS(VALUE object)
|
42
|
+
{
|
43
|
+
CvSURFParams* ptr;
|
44
|
+
Data_Get_Struct(object, CvSURFParams, ptr);
|
45
|
+
return ptr;
|
46
|
+
}
|
47
|
+
|
48
|
+
inline CvSURFParams*
|
49
|
+
CVSURFPARAMS_WITH_CHECK(VALUE object)
|
50
|
+
{
|
51
|
+
if (!rb_obj_is_kind_of(object, cCvSURFParams::rb_class()))
|
52
|
+
raise_typeerror(object, cCvSURFParams::rb_class());
|
53
|
+
return CVSURFPARAMS(object);
|
54
|
+
}
|
55
|
+
|
56
|
+
__NAMESPACE_END_OPENCV
|
57
|
+
|
58
|
+
#endif // RUBY_OPENCV_CVSURFPARAMS_H
|
@@ -0,0 +1,223 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvsurfpoint.cpp -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvsurfpoint.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvSURFPoint
|
13
|
+
*
|
14
|
+
* C structure is here.
|
15
|
+
* typedef struct CvSURFPoint {
|
16
|
+
* CvPoint2D32f pt; // position of the feature within the image
|
17
|
+
* int laplacian; // -1, 0 or +1. sign of the laplacian at the point.
|
18
|
+
* // can be used to speedup feature comparison
|
19
|
+
* // (normally features with laplacians of different
|
20
|
+
* // signs can not match)
|
21
|
+
* int size; // size of the feature
|
22
|
+
* float dir; // orientation of the feature: 0..360 degrees
|
23
|
+
* float hessian; // value of the hessian (can be used to
|
24
|
+
* // approximately estimate the feature strengths)
|
25
|
+
* } CvSURFPoint;
|
26
|
+
*/
|
27
|
+
__NAMESPACE_BEGIN_OPENCV
|
28
|
+
__NAMESPACE_BEGIN_CVSURFPOINT
|
29
|
+
|
30
|
+
VALUE rb_klass;
|
31
|
+
|
32
|
+
VALUE
|
33
|
+
rb_class()
|
34
|
+
{
|
35
|
+
return rb_klass;
|
36
|
+
}
|
37
|
+
|
38
|
+
void
|
39
|
+
define_ruby_class()
|
40
|
+
{
|
41
|
+
if (rb_klass)
|
42
|
+
return;
|
43
|
+
/*
|
44
|
+
* opencv = rb_define_module("OpenCV");
|
45
|
+
*
|
46
|
+
* note: this comment is used by rdoc.
|
47
|
+
*/
|
48
|
+
VALUE opencv = rb_module_opencv();
|
49
|
+
rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
|
50
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
51
|
+
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
|
52
|
+
rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
|
53
|
+
rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
|
54
|
+
rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
|
55
|
+
rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
|
56
|
+
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
57
|
+
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
58
|
+
rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
|
59
|
+
rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
|
60
|
+
rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
|
61
|
+
rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
|
62
|
+
}
|
63
|
+
|
64
|
+
VALUE
|
65
|
+
rb_allocate(VALUE klass)
|
66
|
+
{
|
67
|
+
CvSURFPoint *ptr;
|
68
|
+
return Data_Make_Struct(klass, CvSURFPoint, 0, -1, ptr);
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
* call-seq:
|
73
|
+
* CvSURFPoint.new(<i>pt,laplacian,size,dir,hessian</i>) -> cvsurfpoint
|
74
|
+
*
|
75
|
+
* Create a CvSURFPoint
|
76
|
+
*/
|
77
|
+
VALUE
|
78
|
+
rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian)
|
79
|
+
{
|
80
|
+
CvSURFPoint *self_ptr = CVSURFPOINT(self);
|
81
|
+
self_ptr->pt = VALUE_TO_CVPOINT2D32F(pt);
|
82
|
+
self_ptr->laplacian = NUM2INT(laplacian);
|
83
|
+
self_ptr->size = NUM2INT(size);
|
84
|
+
self_ptr->dir = (float)NUM2DBL(dir);
|
85
|
+
self_ptr->hessian = (float)NUM2DBL(hessian);
|
86
|
+
|
87
|
+
return self;
|
88
|
+
}
|
89
|
+
|
90
|
+
/*
|
91
|
+
* call-seq:
|
92
|
+
* pt -> cvpoint2d32f
|
93
|
+
* Return position of the feature as CvPoint2D32f.
|
94
|
+
*/
|
95
|
+
VALUE
|
96
|
+
rb_get_pt(VALUE self)
|
97
|
+
{
|
98
|
+
return REFER_OBJECT(cCvPoint2D32f::rb_class(), &CVSURFPOINT(self)->pt, self);
|
99
|
+
}
|
100
|
+
|
101
|
+
/*
|
102
|
+
* call-seq:
|
103
|
+
* pt = <i>value</i>
|
104
|
+
*
|
105
|
+
* Set position of the feature to <i>value</i>
|
106
|
+
*/
|
107
|
+
VALUE
|
108
|
+
rb_set_pt(VALUE self, VALUE value)
|
109
|
+
{
|
110
|
+
CVSURFPOINT(self)->pt = VALUE_TO_CVPOINT2D32F(value);
|
111
|
+
return self;
|
112
|
+
}
|
113
|
+
|
114
|
+
/*
|
115
|
+
* call-seq:
|
116
|
+
* laplacian -> number
|
117
|
+
* Return sign of the laplacian at the point (-1, 0 or +1)
|
118
|
+
*/
|
119
|
+
VALUE
|
120
|
+
rb_get_laplacian(VALUE self)
|
121
|
+
{
|
122
|
+
return INT2NUM(CVSURFPOINT(self)->laplacian);
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* call-seq:
|
127
|
+
* laplacian = <i>value</i> (-1, 0 or +1)
|
128
|
+
* Set sign of the laplacian at the point
|
129
|
+
*/
|
130
|
+
VALUE
|
131
|
+
rb_set_laplacian(VALUE self, VALUE value)
|
132
|
+
{
|
133
|
+
int val = NUM2INT(value);
|
134
|
+
CVSURFPOINT(self)->laplacian = (val > 0) ? 1 : (val < 0) ? -1 : 0;
|
135
|
+
return self;
|
136
|
+
}
|
137
|
+
|
138
|
+
/*
|
139
|
+
* call-seq:
|
140
|
+
* size -> number
|
141
|
+
* Return size of feature
|
142
|
+
*/
|
143
|
+
VALUE
|
144
|
+
rb_get_size(VALUE self)
|
145
|
+
{
|
146
|
+
return INT2NUM(CVSURFPOINT(self)->size);
|
147
|
+
}
|
148
|
+
|
149
|
+
/*
|
150
|
+
* call-seq:
|
151
|
+
* size = <i>value</i>
|
152
|
+
* Return size of feature
|
153
|
+
*/
|
154
|
+
VALUE
|
155
|
+
rb_set_size(VALUE self, VALUE value)
|
156
|
+
{
|
157
|
+
CVSURFPOINT(self)->size = NUM2INT(value);
|
158
|
+
return self;
|
159
|
+
}
|
160
|
+
|
161
|
+
/*
|
162
|
+
* call-seq:
|
163
|
+
* dir -> number
|
164
|
+
* Return orientation of the feature: 0..360 degrees
|
165
|
+
*/
|
166
|
+
VALUE
|
167
|
+
rb_get_dir(VALUE self)
|
168
|
+
{
|
169
|
+
return DBL2NUM((double)(CVSURFPOINT(self)->dir));
|
170
|
+
}
|
171
|
+
|
172
|
+
/*
|
173
|
+
* call-seq:
|
174
|
+
* dir = <i>value</i>
|
175
|
+
* Set orientation of the feature: 0..360 degrees
|
176
|
+
*/
|
177
|
+
VALUE
|
178
|
+
rb_set_dir(VALUE self, VALUE value)
|
179
|
+
{
|
180
|
+
CVSURFPOINT(self)->dir = (float)NUM2DBL(value);
|
181
|
+
return self;
|
182
|
+
}
|
183
|
+
|
184
|
+
/*
|
185
|
+
* call-seq:
|
186
|
+
* hessian -> number
|
187
|
+
* Return value of the hessian
|
188
|
+
*/
|
189
|
+
VALUE
|
190
|
+
rb_get_hessian(VALUE self)
|
191
|
+
{
|
192
|
+
return DBL2NUM((double)(CVSURFPOINT(self)->hessian));
|
193
|
+
}
|
194
|
+
|
195
|
+
/*
|
196
|
+
* call-seq:
|
197
|
+
* hessian = <i>value</i>
|
198
|
+
* Set value of the hessian
|
199
|
+
*/
|
200
|
+
VALUE
|
201
|
+
rb_set_hessian(VALUE self, VALUE value)
|
202
|
+
{
|
203
|
+
CVSURFPOINT(self)->hessian = (float)NUM2DBL(value);
|
204
|
+
return self;
|
205
|
+
}
|
206
|
+
|
207
|
+
VALUE
|
208
|
+
new_object()
|
209
|
+
{
|
210
|
+
return rb_allocate(rb_klass);
|
211
|
+
}
|
212
|
+
|
213
|
+
VALUE
|
214
|
+
new_object(CvSURFPoint* cvsurfpoint)
|
215
|
+
{
|
216
|
+
VALUE object = rb_allocate(rb_klass);
|
217
|
+
CvSURFPoint *ptr = CVSURFPOINT(object);
|
218
|
+
ptr = cvsurfpoint;
|
219
|
+
return object;
|
220
|
+
}
|
221
|
+
|
222
|
+
__NAMESPACE_END_CVSURFPOINT
|
223
|
+
__NAMESPACE_END_OPENCV
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvsurfpoint.h -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVSURFPOINT_H
|
11
|
+
#define RUBY_OPENCV_CVSURFPOINT_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVSURFPOINT namespace cCvSURFPoint {
|
16
|
+
#define __NAMESPACE_END_CVSURFPOINT }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVSURFPOINT
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void define_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_allocate(VALUE klass);
|
26
|
+
VALUE rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian);
|
27
|
+
VALUE rb_get_pt(VALUE self);
|
28
|
+
VALUE rb_set_pt(VALUE self, VALUE value);
|
29
|
+
VALUE rb_get_laplacian(VALUE self);
|
30
|
+
VALUE rb_set_laplacian(VALUE self, VALUE value);
|
31
|
+
VALUE rb_get_size(VALUE self);
|
32
|
+
VALUE rb_set_size(VALUE self, VALUE value);
|
33
|
+
VALUE rb_get_dir(VALUE self);
|
34
|
+
VALUE rb_set_dir(VALUE self, VALUE value);
|
35
|
+
VALUE rb_get_hessian(VALUE self);
|
36
|
+
VALUE rb_set_hessian(VALUE self, VALUE value);
|
37
|
+
|
38
|
+
VALUE new_object(CvSURFPoint *cvsurfpoint);
|
39
|
+
|
40
|
+
__NAMESPACE_END_CVSURFPOINT
|
41
|
+
|
42
|
+
inline CvSURFPoint*
|
43
|
+
CVSURFPOINT(VALUE object)
|
44
|
+
{
|
45
|
+
CvSURFPoint* ptr;
|
46
|
+
Data_Get_Struct(object, CvSURFPoint, ptr);
|
47
|
+
return ptr;
|
48
|
+
}
|
49
|
+
|
50
|
+
__NAMESPACE_END_OPENCV
|
51
|
+
|
52
|
+
#endif // RUBY_OPENCV_CVSURFPOINT_H
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvtermcriteria.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvtermcriteria.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvTermCriteria
|
13
|
+
*
|
14
|
+
* CvTermCriteria has parameter "max" and "eps".
|
15
|
+
* "max" is the maximum repetition frequency.
|
16
|
+
* "eps" is a minimum difference value during current and previous state
|
17
|
+
* (It is different to which state "eps" refer depending on the method).
|
18
|
+
*
|
19
|
+
* Because the name of CvTermCriteria seems to be very long, it has alias named CvTerm.
|
20
|
+
*/
|
21
|
+
__NAMESPACE_BEGIN_OPENCV
|
22
|
+
__NAMESPACE_BEGIN_CVTERMCRITERIA
|
23
|
+
|
24
|
+
VALUE rb_klass;
|
25
|
+
|
26
|
+
VALUE
|
27
|
+
rb_class()
|
28
|
+
{
|
29
|
+
return rb_klass;
|
30
|
+
}
|
31
|
+
|
32
|
+
void
|
33
|
+
define_ruby_class()
|
34
|
+
{
|
35
|
+
if (rb_klass)
|
36
|
+
return;
|
37
|
+
/*
|
38
|
+
* opencv = rb_define_module("OpenCV");
|
39
|
+
*
|
40
|
+
* note: this comment is used by rdoc.
|
41
|
+
*/
|
42
|
+
VALUE opencv = rb_module_opencv();
|
43
|
+
|
44
|
+
rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
|
45
|
+
/* CvTermCriteria: class */
|
46
|
+
rb_define_const(opencv, "CvTerm", rb_klass);
|
47
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
48
|
+
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
49
|
+
rb_define_method(rb_klass, "type", RUBY_METHOD_FUNC(rb_type), 0);
|
50
|
+
rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
|
51
|
+
rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
|
52
|
+
rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
|
53
|
+
rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
|
54
|
+
rb_define_alias(rb_klass, "epsilon", "eps");
|
55
|
+
rb_define_alias(rb_klass, "epsilon=", "eps=");
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE
|
59
|
+
rb_allocate(VALUE klass)
|
60
|
+
{
|
61
|
+
CvTermCriteria *ptr;
|
62
|
+
return Data_Make_Struct(klass, CvTermCriteria, 0, -1, ptr);
|
63
|
+
}
|
64
|
+
|
65
|
+
/*
|
66
|
+
* call-seq:
|
67
|
+
* CvTermCriteria.new([max = 0][,eps = 0.0]) -> obj
|
68
|
+
* CvTermCriteria.new(int) = CvTermCriteria.new(int, 0.0)
|
69
|
+
* CvTermCriteria.new(float) = CvTermCriteria.new(0, float)
|
70
|
+
*
|
71
|
+
* Create new term criteria.
|
72
|
+
*/
|
73
|
+
VALUE
|
74
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
75
|
+
{
|
76
|
+
VALUE max, eps;
|
77
|
+
rb_scan_args(argc, argv, "02", &max, &eps);
|
78
|
+
int type = 0;
|
79
|
+
if (!NIL_P(max))
|
80
|
+
type |= CV_TERMCRIT_ITER;
|
81
|
+
if (!NIL_P(eps))
|
82
|
+
type |= CV_TERMCRIT_EPS;
|
83
|
+
try {
|
84
|
+
*CVTERMCRITERIA(self) = cvTermCriteria(type, IF_INT(max, 0), IF_DBL(eps, 0.0));
|
85
|
+
}
|
86
|
+
catch (cv::Exception& e) {
|
87
|
+
raise_cverror(e);
|
88
|
+
}
|
89
|
+
return self;
|
90
|
+
}
|
91
|
+
|
92
|
+
/*
|
93
|
+
* call-seq:
|
94
|
+
* type -> int
|
95
|
+
*
|
96
|
+
* Return a combination of CV_TERMCRIT_ITER and CV_TERMCRIT_EPS
|
97
|
+
*/
|
98
|
+
VALUE
|
99
|
+
rb_type(VALUE self)
|
100
|
+
{
|
101
|
+
return INT2NUM(CVTERMCRITERIA(self)->type);
|
102
|
+
}
|
103
|
+
|
104
|
+
/*
|
105
|
+
* call-seq:
|
106
|
+
* max -> int or nil
|
107
|
+
*
|
108
|
+
* Return the maximum repetition frequency.
|
109
|
+
*/
|
110
|
+
VALUE
|
111
|
+
rb_max(VALUE self)
|
112
|
+
{
|
113
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
114
|
+
if (ptr->type & CV_TERMCRIT_ITER)
|
115
|
+
return INT2NUM(ptr->max_iter);
|
116
|
+
else
|
117
|
+
return Qnil;
|
118
|
+
}
|
119
|
+
|
120
|
+
/*
|
121
|
+
* call-seq:
|
122
|
+
* max = <i>val</i> -> self
|
123
|
+
*
|
124
|
+
* Set the maximum repetition frequency.
|
125
|
+
* If <i>val</i> is 0 (or negative value), repetition frequency is disregarded.
|
126
|
+
*/
|
127
|
+
VALUE
|
128
|
+
rb_set_max(VALUE self, VALUE max_value)
|
129
|
+
{
|
130
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
131
|
+
int max = NUM2INT(max_value);
|
132
|
+
if (max > 0) {
|
133
|
+
ptr->type |= CV_TERMCRIT_ITER;
|
134
|
+
ptr->max_iter = max;
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
ptr->type ^= CV_TERMCRIT_ITER;
|
138
|
+
ptr->max_iter = 0;
|
139
|
+
}
|
140
|
+
return self;
|
141
|
+
}
|
142
|
+
|
143
|
+
/*
|
144
|
+
* call-seq:
|
145
|
+
* eps -> float or nil
|
146
|
+
*
|
147
|
+
* Return the minimum difference value during current and previous state.
|
148
|
+
*/
|
149
|
+
VALUE
|
150
|
+
rb_eps(VALUE self)
|
151
|
+
{
|
152
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
153
|
+
if (ptr->type & CV_TERMCRIT_EPS)
|
154
|
+
return rb_float_new(ptr->epsilon);
|
155
|
+
else
|
156
|
+
return Qnil;
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
* call-seq:
|
161
|
+
* eps = <i>val</i> -> self
|
162
|
+
*
|
163
|
+
* Set the minimum difference value during current and previous state.
|
164
|
+
* If <i>val</i> is 0.0 (or negative value), the minimum difference value
|
165
|
+
* during current and previous state is disregarded.
|
166
|
+
*/
|
167
|
+
VALUE
|
168
|
+
rb_set_eps(VALUE self, VALUE eps_value)
|
169
|
+
{
|
170
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
171
|
+
double eps = NUM2DBL(eps_value);
|
172
|
+
if (eps > 0) {
|
173
|
+
ptr->type = ptr->type | CV_TERMCRIT_EPS;
|
174
|
+
ptr->epsilon = eps;
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
ptr->type = ptr->type ^ CV_TERMCRIT_EPS;
|
178
|
+
ptr->epsilon = 0;
|
179
|
+
}
|
180
|
+
return self;
|
181
|
+
}
|
182
|
+
|
183
|
+
VALUE
|
184
|
+
new_object(CvTermCriteria criteria)
|
185
|
+
{
|
186
|
+
VALUE object = rb_allocate(rb_klass);
|
187
|
+
*CVTERMCRITERIA(object) = criteria;
|
188
|
+
return object;
|
189
|
+
}
|
190
|
+
|
191
|
+
__NAMESPACE_END_CVTERMCRITERIA
|
192
|
+
__NAMESPACE_END_OPENCV
|