bonanza-ruby-opencv 0.0.13.20140330211753
Sign up to get free protection for your applications and to get access to all the features.
- 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,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 init_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,279 @@
|
|
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
|
+
VALUE
|
39
|
+
rb_allocate(VALUE klass)
|
40
|
+
{
|
41
|
+
CvSURFPoint *ptr;
|
42
|
+
return Data_Make_Struct(klass, CvSURFPoint, 0, -1, ptr);
|
43
|
+
}
|
44
|
+
|
45
|
+
/*
|
46
|
+
* Create a CvSURFPoint
|
47
|
+
*
|
48
|
+
* @overload new(pt, laplacian, size, dir, hessian)
|
49
|
+
* @param pt [CvPoint2D32f] Position of the feature within the image
|
50
|
+
* @param laplacian [Integer] -1, 0 or +1. sign of the laplacian at the point.
|
51
|
+
* Can be used to speedup feature comparison
|
52
|
+
* (normally features with laplacians of different signs can not match)
|
53
|
+
* @param size [Integer] Size of the feature
|
54
|
+
* @param dir [Number] Orientation of the feature: 0..360 degrees
|
55
|
+
* @param hessian [Number] Value of the hessian (can be used to
|
56
|
+
* approximately estimate the feature strengths)
|
57
|
+
* @return [CvSURFPoint] self
|
58
|
+
*/
|
59
|
+
VALUE
|
60
|
+
rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian)
|
61
|
+
{
|
62
|
+
CvSURFPoint *self_ptr = CVSURFPOINT(self);
|
63
|
+
self_ptr->pt = VALUE_TO_CVPOINT2D32F(pt);
|
64
|
+
self_ptr->laplacian = NUM2INT(laplacian);
|
65
|
+
self_ptr->size = NUM2INT(size);
|
66
|
+
self_ptr->dir = (float)NUM2DBL(dir);
|
67
|
+
self_ptr->hessian = (float)NUM2DBL(hessian);
|
68
|
+
|
69
|
+
return self;
|
70
|
+
}
|
71
|
+
|
72
|
+
/*
|
73
|
+
* Return position of the feature as CvPoint2D32f.
|
74
|
+
*
|
75
|
+
* @overload pt
|
76
|
+
* @return [CvPoint2D32f] Position of the feature.
|
77
|
+
*/
|
78
|
+
VALUE
|
79
|
+
rb_get_pt(VALUE self)
|
80
|
+
{
|
81
|
+
return REFER_OBJECT(cCvPoint2D32f::rb_class(), &CVSURFPOINT(self)->pt, self);
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
* Set position of the feature.
|
86
|
+
*
|
87
|
+
* @overload pt=(value)
|
88
|
+
* @param value [CvPoint2D32f] Valuet to set.
|
89
|
+
*/
|
90
|
+
VALUE
|
91
|
+
rb_set_pt(VALUE self, VALUE value)
|
92
|
+
{
|
93
|
+
CVSURFPOINT(self)->pt = VALUE_TO_CVPOINT2D32F(value);
|
94
|
+
return self;
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* Return sign of the laplacian at the point (-1, 0 or +1)
|
99
|
+
*
|
100
|
+
* @overload laplacian
|
101
|
+
* @return [Integer] Sign of the laplacian at the point.
|
102
|
+
*/
|
103
|
+
VALUE
|
104
|
+
rb_get_laplacian(VALUE self)
|
105
|
+
{
|
106
|
+
return INT2NUM(CVSURFPOINT(self)->laplacian);
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* Set sign of the laplacian at the point
|
111
|
+
*
|
112
|
+
* @overload laplacian=(value)
|
113
|
+
* @param value [Integer] Value to set.
|
114
|
+
*/
|
115
|
+
VALUE
|
116
|
+
rb_set_laplacian(VALUE self, VALUE value)
|
117
|
+
{
|
118
|
+
int val = NUM2INT(value);
|
119
|
+
CVSURFPOINT(self)->laplacian = (val > 0) ? 1 : (val < 0) ? -1 : 0;
|
120
|
+
return self;
|
121
|
+
}
|
122
|
+
|
123
|
+
/*
|
124
|
+
* Returns size of feature.
|
125
|
+
*
|
126
|
+
* @overload size
|
127
|
+
* @return [Integer] Size of feature.
|
128
|
+
*/
|
129
|
+
VALUE
|
130
|
+
rb_get_size(VALUE self)
|
131
|
+
{
|
132
|
+
return INT2NUM(CVSURFPOINT(self)->size);
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* Return size of feature
|
137
|
+
*
|
138
|
+
* @overload size=(value)
|
139
|
+
* @param [Integer] Value to set.
|
140
|
+
*/
|
141
|
+
VALUE
|
142
|
+
rb_set_size(VALUE self, VALUE value)
|
143
|
+
{
|
144
|
+
CVSURFPOINT(self)->size = NUM2INT(value);
|
145
|
+
return self;
|
146
|
+
}
|
147
|
+
|
148
|
+
/*
|
149
|
+
* Return orientation of the feature: 0..360 degrees
|
150
|
+
*
|
151
|
+
* @overload dir
|
152
|
+
* @return [Number] Orientation of the feature.
|
153
|
+
*/
|
154
|
+
VALUE
|
155
|
+
rb_get_dir(VALUE self)
|
156
|
+
{
|
157
|
+
return DBL2NUM((double)(CVSURFPOINT(self)->dir));
|
158
|
+
}
|
159
|
+
|
160
|
+
/*
|
161
|
+
* Set orientation of the feature: 0..360 degrees.
|
162
|
+
*
|
163
|
+
* @overload dir=(value)
|
164
|
+
* @param [Number] Value to set.
|
165
|
+
*/
|
166
|
+
VALUE
|
167
|
+
rb_set_dir(VALUE self, VALUE value)
|
168
|
+
{
|
169
|
+
CVSURFPOINT(self)->dir = (float)NUM2DBL(value);
|
170
|
+
return self;
|
171
|
+
}
|
172
|
+
|
173
|
+
/*
|
174
|
+
* Return value of the hessian
|
175
|
+
*
|
176
|
+
* @overload hessian
|
177
|
+
* @return [Number] Hessian
|
178
|
+
*/
|
179
|
+
VALUE
|
180
|
+
rb_get_hessian(VALUE self)
|
181
|
+
{
|
182
|
+
return DBL2NUM((double)(CVSURFPOINT(self)->hessian));
|
183
|
+
}
|
184
|
+
|
185
|
+
/*
|
186
|
+
* Set value of the hessian
|
187
|
+
*
|
188
|
+
* @overload hessian=(value)
|
189
|
+
* @param [Number] Value to set.
|
190
|
+
*/
|
191
|
+
VALUE
|
192
|
+
rb_set_hessian(VALUE self, VALUE value)
|
193
|
+
{
|
194
|
+
CVSURFPOINT(self)->hessian = (float)NUM2DBL(value);
|
195
|
+
return self;
|
196
|
+
}
|
197
|
+
|
198
|
+
/*
|
199
|
+
* call-seq:
|
200
|
+
*
|
201
|
+
*
|
202
|
+
* From: https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/find_obj.cpp?rev=2065
|
203
|
+
*/
|
204
|
+
VALUE
|
205
|
+
rb_flann(VALUE klass, VALUE objectDesc, VALUE imageDesc)
|
206
|
+
{
|
207
|
+
const cv::Mat m_object(CVMAT(objectDesc));
|
208
|
+
const cv::Mat m_image(CVMAT(imageDesc));
|
209
|
+
|
210
|
+
cv::Mat m_indices(m_object.rows, 2, CV_32S);
|
211
|
+
cv::Mat m_dists(m_object.rows, 2, CV_32F);
|
212
|
+
|
213
|
+
cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4)); // using 4 randomized kdtrees
|
214
|
+
flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64)); // maximum number of leafs checked
|
215
|
+
|
216
|
+
VALUE ptpairs = rb_ary_new();
|
217
|
+
|
218
|
+
int* indices_ptr = m_indices.ptr<int>(0);
|
219
|
+
float* dists_ptr = m_dists.ptr<float>(0);
|
220
|
+
for (int i = 0; i < m_indices.rows; ++i) {
|
221
|
+
if (dists_ptr[2 * i] < 0.6 * dists_ptr[2 * i + 1]) {
|
222
|
+
rb_ary_push(ptpairs, rb_int_new(i));
|
223
|
+
rb_ary_push(ptpairs, rb_int_new(indices_ptr[2 * i]));
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
return ptpairs;
|
228
|
+
}
|
229
|
+
|
230
|
+
VALUE
|
231
|
+
new_object()
|
232
|
+
{
|
233
|
+
return rb_allocate(rb_klass);
|
234
|
+
}
|
235
|
+
|
236
|
+
VALUE
|
237
|
+
new_object(CvSURFPoint* cvsurfpoint)
|
238
|
+
{
|
239
|
+
VALUE object = rb_allocate(rb_klass);
|
240
|
+
CvSURFPoint *ptr = CVSURFPOINT(object);
|
241
|
+
ptr = cvsurfpoint;
|
242
|
+
return object;
|
243
|
+
}
|
244
|
+
|
245
|
+
void
|
246
|
+
init_ruby_class()
|
247
|
+
{
|
248
|
+
#if 0
|
249
|
+
// For documentation using YARD
|
250
|
+
VALUE opencv = rb_define_module("OpenCV");
|
251
|
+
#endif
|
252
|
+
|
253
|
+
if (rb_klass)
|
254
|
+
return;
|
255
|
+
/*
|
256
|
+
* opencv = rb_define_module("OpenCV");
|
257
|
+
*
|
258
|
+
* note: this comment is used by rdoc.
|
259
|
+
*/
|
260
|
+
VALUE opencv = rb_module_opencv();
|
261
|
+
rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
|
262
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
263
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
|
264
|
+
rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
|
265
|
+
rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
|
266
|
+
rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
|
267
|
+
rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
|
268
|
+
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
269
|
+
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
270
|
+
rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
|
271
|
+
rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
|
272
|
+
rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
|
273
|
+
rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
|
274
|
+
rb_define_singleton_method(rb_klass, "flann", RUBY_METHOD_FUNC(rb_flann), 2);
|
275
|
+
}
|
276
|
+
|
277
|
+
__NAMESPACE_END_CVSURFPOINT
|
278
|
+
__NAMESPACE_END_OPENCV
|
279
|
+
|
@@ -0,0 +1,54 @@
|
|
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 init_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 rb_flann(VALUE klass, VALUE objectDescriptors, VALUE imageDescriptors);
|
39
|
+
|
40
|
+
VALUE new_object(CvSURFPoint *cvsurfpoint);
|
41
|
+
|
42
|
+
__NAMESPACE_END_CVSURFPOINT
|
43
|
+
|
44
|
+
inline CvSURFPoint*
|
45
|
+
CVSURFPOINT(VALUE object)
|
46
|
+
{
|
47
|
+
CvSURFPoint* ptr;
|
48
|
+
Data_Get_Struct(object, CvSURFPoint, ptr);
|
49
|
+
return ptr;
|
50
|
+
}
|
51
|
+
|
52
|
+
__NAMESPACE_END_OPENCV
|
53
|
+
|
54
|
+
#endif // RUBY_OPENCV_CVSURFPOINT_H
|
@@ -0,0 +1,198 @@
|
|
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
|
+
VALUE
|
33
|
+
rb_allocate(VALUE klass)
|
34
|
+
{
|
35
|
+
CvTermCriteria *ptr;
|
36
|
+
return Data_Make_Struct(klass, CvTermCriteria, 0, -1, ptr);
|
37
|
+
}
|
38
|
+
|
39
|
+
/*
|
40
|
+
* call-seq:
|
41
|
+
* CvTermCriteria.new([max = 0][,eps = 0.0]) -> obj
|
42
|
+
* CvTermCriteria.new(int) = CvTermCriteria.new(int, 0.0)
|
43
|
+
* CvTermCriteria.new(float) = CvTermCriteria.new(0, float)
|
44
|
+
*
|
45
|
+
* Create new term criteria.
|
46
|
+
*/
|
47
|
+
VALUE
|
48
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
49
|
+
{
|
50
|
+
VALUE max, eps;
|
51
|
+
rb_scan_args(argc, argv, "02", &max, &eps);
|
52
|
+
int type = 0;
|
53
|
+
if (!NIL_P(max))
|
54
|
+
type |= CV_TERMCRIT_ITER;
|
55
|
+
if (!NIL_P(eps))
|
56
|
+
type |= CV_TERMCRIT_EPS;
|
57
|
+
try {
|
58
|
+
*CVTERMCRITERIA(self) = cvTermCriteria(type, IF_INT(max, 0), IF_DBL(eps, 0.0));
|
59
|
+
}
|
60
|
+
catch (cv::Exception& e) {
|
61
|
+
raise_cverror(e);
|
62
|
+
}
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* type -> int
|
69
|
+
*
|
70
|
+
* Return a combination of CV_TERMCRIT_ITER and CV_TERMCRIT_EPS
|
71
|
+
*/
|
72
|
+
VALUE
|
73
|
+
rb_type(VALUE self)
|
74
|
+
{
|
75
|
+
return INT2NUM(CVTERMCRITERIA(self)->type);
|
76
|
+
}
|
77
|
+
|
78
|
+
/*
|
79
|
+
* call-seq:
|
80
|
+
* max -> int or nil
|
81
|
+
*
|
82
|
+
* Return the maximum repetition frequency.
|
83
|
+
*/
|
84
|
+
VALUE
|
85
|
+
rb_max(VALUE self)
|
86
|
+
{
|
87
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
88
|
+
if (ptr->type & CV_TERMCRIT_ITER)
|
89
|
+
return INT2NUM(ptr->max_iter);
|
90
|
+
else
|
91
|
+
return Qnil;
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* call-seq:
|
96
|
+
* max = <i>val</i> -> self
|
97
|
+
*
|
98
|
+
* Set the maximum repetition frequency.
|
99
|
+
* If <i>val</i> is 0 (or negative value), repetition frequency is disregarded.
|
100
|
+
*/
|
101
|
+
VALUE
|
102
|
+
rb_set_max(VALUE self, VALUE max_value)
|
103
|
+
{
|
104
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
105
|
+
int max = NUM2INT(max_value);
|
106
|
+
if (max > 0) {
|
107
|
+
ptr->type |= CV_TERMCRIT_ITER;
|
108
|
+
ptr->max_iter = max;
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
ptr->type ^= CV_TERMCRIT_ITER;
|
112
|
+
ptr->max_iter = 0;
|
113
|
+
}
|
114
|
+
return self;
|
115
|
+
}
|
116
|
+
|
117
|
+
/*
|
118
|
+
* call-seq:
|
119
|
+
* eps -> float or nil
|
120
|
+
*
|
121
|
+
* Return the minimum difference value during current and previous state.
|
122
|
+
*/
|
123
|
+
VALUE
|
124
|
+
rb_eps(VALUE self)
|
125
|
+
{
|
126
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
127
|
+
if (ptr->type & CV_TERMCRIT_EPS)
|
128
|
+
return rb_float_new(ptr->epsilon);
|
129
|
+
else
|
130
|
+
return Qnil;
|
131
|
+
}
|
132
|
+
|
133
|
+
/*
|
134
|
+
* call-seq:
|
135
|
+
* eps = <i>val</i> -> self
|
136
|
+
*
|
137
|
+
* Set the minimum difference value during current and previous state.
|
138
|
+
* If <i>val</i> is 0.0 (or negative value), the minimum difference value
|
139
|
+
* during current and previous state is disregarded.
|
140
|
+
*/
|
141
|
+
VALUE
|
142
|
+
rb_set_eps(VALUE self, VALUE eps_value)
|
143
|
+
{
|
144
|
+
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
145
|
+
double eps = NUM2DBL(eps_value);
|
146
|
+
if (eps > 0) {
|
147
|
+
ptr->type = ptr->type | CV_TERMCRIT_EPS;
|
148
|
+
ptr->epsilon = eps;
|
149
|
+
}
|
150
|
+
else {
|
151
|
+
ptr->type = ptr->type ^ CV_TERMCRIT_EPS;
|
152
|
+
ptr->epsilon = 0;
|
153
|
+
}
|
154
|
+
return self;
|
155
|
+
}
|
156
|
+
|
157
|
+
VALUE
|
158
|
+
new_object(CvTermCriteria criteria)
|
159
|
+
{
|
160
|
+
VALUE object = rb_allocate(rb_klass);
|
161
|
+
*CVTERMCRITERIA(object) = criteria;
|
162
|
+
return object;
|
163
|
+
}
|
164
|
+
|
165
|
+
void
|
166
|
+
init_ruby_class()
|
167
|
+
{
|
168
|
+
#if 0
|
169
|
+
// For documentation using YARD
|
170
|
+
VALUE opencv = rb_define_module("OpenCV");
|
171
|
+
#endif
|
172
|
+
|
173
|
+
if (rb_klass)
|
174
|
+
return;
|
175
|
+
/*
|
176
|
+
* opencv = rb_define_module("OpenCV");
|
177
|
+
*
|
178
|
+
* note: this comment is used by rdoc.
|
179
|
+
*/
|
180
|
+
VALUE opencv = rb_module_opencv();
|
181
|
+
|
182
|
+
rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
|
183
|
+
/* CvTermCriteria: class */
|
184
|
+
rb_define_const(opencv, "CvTerm", rb_klass);
|
185
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
186
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
187
|
+
rb_define_method(rb_klass, "type", RUBY_METHOD_FUNC(rb_type), 0);
|
188
|
+
rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
|
189
|
+
rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
|
190
|
+
rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
|
191
|
+
rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
|
192
|
+
rb_define_alias(rb_klass, "epsilon", "eps");
|
193
|
+
rb_define_alias(rb_klass, "epsilon=", "eps=");
|
194
|
+
}
|
195
|
+
|
196
|
+
__NAMESPACE_END_CVTERMCRITERIA
|
197
|
+
__NAMESPACE_END_OPENCV
|
198
|
+
|