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,64 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvsize2d32f.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVSIZE2D32F_H
|
11
|
+
#define RUBY_OPENCV_CVSIZE2D32F_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVSIZE2D32F namespace cCvSize2D32f {
|
16
|
+
#define __NAMESPACE_END_CVSIZE2D32F }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVSIZE2D32F
|
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_width(VALUE self);
|
30
|
+
VALUE rb_set_width(VALUE self, VALUE width);
|
31
|
+
VALUE rb_height(VALUE self);
|
32
|
+
VALUE rb_set_height(VALUE self, VALUE height);
|
33
|
+
|
34
|
+
VALUE rb_to_s(VALUE self);
|
35
|
+
VALUE rb_to_ary(VALUE self);
|
36
|
+
|
37
|
+
VALUE new_object(CvSize2D32f size);
|
38
|
+
|
39
|
+
__NAMESPACE_END_CVSIZE2D32F
|
40
|
+
|
41
|
+
inline CvSize2D32f*
|
42
|
+
CVSIZE2D32F(VALUE object)
|
43
|
+
{
|
44
|
+
CvSize2D32f *ptr;
|
45
|
+
Data_Get_Struct(object, CvSize2D32f, ptr);
|
46
|
+
return ptr;
|
47
|
+
}
|
48
|
+
|
49
|
+
inline CvSize2D32f
|
50
|
+
VALUE_TO_CVSIZE2D32F(VALUE object)
|
51
|
+
{
|
52
|
+
if (cCvSize2D32f::rb_compatible_q(cCvSize2D32f::rb_class(), object)) {
|
53
|
+
return cvSize2D32f(NUM2DBL(rb_funcall(object, rb_intern("width"), 0)),
|
54
|
+
NUM2DBL(rb_funcall(object, rb_intern("height"), 0)));
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
raise_compatible_typeerror(object, cCvSize2D32f::rb_class());
|
58
|
+
}
|
59
|
+
throw "Should never reach here";
|
60
|
+
}
|
61
|
+
|
62
|
+
__NAMESPACE_END_OPENCV
|
63
|
+
|
64
|
+
#endif // RUBY_OPENCV_CVSIZE2D32F_H
|
@@ -0,0 +1,126 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvslice.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvslice.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvSlice
|
13
|
+
*
|
14
|
+
* C structure is here, very simple.
|
15
|
+
* typdef struct CvSlice {
|
16
|
+
* int start_index;
|
17
|
+
* int end_index;
|
18
|
+
* } CvSlice;
|
19
|
+
*/
|
20
|
+
__NAMESPACE_BEGIN_OPENCV
|
21
|
+
__NAMESPACE_BEGIN_CVSLICE
|
22
|
+
|
23
|
+
VALUE rb_klass;
|
24
|
+
|
25
|
+
VALUE
|
26
|
+
rb_class()
|
27
|
+
{
|
28
|
+
return rb_klass;
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
rb_allocate(VALUE klass)
|
33
|
+
{
|
34
|
+
CvSlice *ptr;
|
35
|
+
return Data_Make_Struct(klass, CvSlice, 0, -1, ptr);
|
36
|
+
}
|
37
|
+
|
38
|
+
/*
|
39
|
+
* call-seq:
|
40
|
+
* new(start, end)
|
41
|
+
*
|
42
|
+
* Create new slice object.
|
43
|
+
*/
|
44
|
+
VALUE
|
45
|
+
rb_initialize(VALUE self, VALUE start, VALUE end)
|
46
|
+
{
|
47
|
+
CvSlice *self_ptr = CVSLICE(self);
|
48
|
+
self_ptr->start_index = NUM2INT(start);
|
49
|
+
self_ptr->end_index = NUM2INT(end);
|
50
|
+
return self;
|
51
|
+
}
|
52
|
+
|
53
|
+
/*
|
54
|
+
* call-seq:
|
55
|
+
* start_index
|
56
|
+
*
|
57
|
+
*/
|
58
|
+
VALUE
|
59
|
+
rb_start_index_aref(VALUE self)
|
60
|
+
{
|
61
|
+
return INT2NUM(CVSLICE(self)->start_index);
|
62
|
+
}
|
63
|
+
|
64
|
+
/*
|
65
|
+
* call-seq:
|
66
|
+
* end_index
|
67
|
+
*
|
68
|
+
*/
|
69
|
+
VALUE
|
70
|
+
rb_end_index_aref(VALUE self)
|
71
|
+
{
|
72
|
+
return INT2NUM(CVSLICE(self)->end_index);
|
73
|
+
}
|
74
|
+
|
75
|
+
/*
|
76
|
+
* call-seq:
|
77
|
+
* start_index = index
|
78
|
+
*
|
79
|
+
*/
|
80
|
+
VALUE
|
81
|
+
rb_start_index_aset(VALUE self, VALUE index)
|
82
|
+
{
|
83
|
+
CVSLICE(self)->start_index = NUM2INT(index);
|
84
|
+
return self;
|
85
|
+
}
|
86
|
+
|
87
|
+
/*
|
88
|
+
* call-seq:
|
89
|
+
* end_index = index
|
90
|
+
*
|
91
|
+
*/
|
92
|
+
VALUE
|
93
|
+
rb_end_index_aset(VALUE self, VALUE index)
|
94
|
+
{
|
95
|
+
CVSLICE(self)->end_index = NUM2INT(index);
|
96
|
+
return self;
|
97
|
+
}
|
98
|
+
|
99
|
+
void
|
100
|
+
init_ruby_class()
|
101
|
+
{
|
102
|
+
#if 0
|
103
|
+
// For documentation using YARD
|
104
|
+
VALUE opencv = rb_define_module("OpenCV");
|
105
|
+
#endif
|
106
|
+
|
107
|
+
if (rb_klass)
|
108
|
+
return;
|
109
|
+
/*
|
110
|
+
* opencv = rb_define_module("OpenCV");
|
111
|
+
*
|
112
|
+
* note: this comment is used by rdoc.
|
113
|
+
*/
|
114
|
+
VALUE opencv = rb_module_opencv();
|
115
|
+
rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
|
116
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
117
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
|
118
|
+
rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
|
119
|
+
rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
|
120
|
+
rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
|
121
|
+
rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
|
122
|
+
}
|
123
|
+
|
124
|
+
__NAMESPACE_END_CVSLICE
|
125
|
+
__NAMESPACE_END_OPENCV
|
126
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvslice.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVSLICE_H
|
11
|
+
#define RUBY_OPENCV_CVSLICE_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVSLICE namespace cCvSlice {
|
16
|
+
#define __NAMESPACE_END_CVSLICE }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVSLICE
|
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 start, VALUE end);
|
27
|
+
VALUE rb_start_index_aref(VALUE self);
|
28
|
+
VALUE rb_end_index_aref(VALUE self);
|
29
|
+
VALUE rb_start_index_aset(VALUE self, VALUE index);
|
30
|
+
VALUE rb_end_index_aset(VALUE self, VALUE index);
|
31
|
+
|
32
|
+
__NAMESPACE_END_CVSLICE
|
33
|
+
|
34
|
+
inline CvSlice*
|
35
|
+
CVSLICE(VALUE object)
|
36
|
+
{
|
37
|
+
CvSlice *ptr;
|
38
|
+
Data_Get_Struct(object, CvSlice, ptr);
|
39
|
+
return ptr;
|
40
|
+
}
|
41
|
+
|
42
|
+
inline CvSlice
|
43
|
+
VALUE_TO_CVSLICE(VALUE object)
|
44
|
+
{
|
45
|
+
if (rb_obj_is_kind_of(object, cCvSlice::rb_class())) {
|
46
|
+
CvSlice* ptr = CVSLICE(object);
|
47
|
+
return *ptr;
|
48
|
+
}
|
49
|
+
else if (rb_obj_is_kind_of(object, rb_cRange)) {
|
50
|
+
return cvSlice(NUM2INT(rb_funcall(object, rb_intern("begin"), 0)),
|
51
|
+
rb_funcall(object, rb_intern("exclude_end?"), 0) ? NUM2INT(rb_funcall(object, rb_intern("end"), 0)) : NUM2INT(rb_funcall(object, rb_intern("end"), 0)) - 1);
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
raise_compatible_typeerror(object, cCvSlice::rb_class());
|
55
|
+
}
|
56
|
+
throw "Should never reach here";
|
57
|
+
}
|
58
|
+
|
59
|
+
__NAMESPACE_END_OPENCV
|
60
|
+
|
61
|
+
#endif // RUBY_OPENCV_CVSLICE_H
|
@@ -0,0 +1,208 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvsurfparams.cpp -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvsurfparams.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvSURFParams
|
13
|
+
*
|
14
|
+
* C structure is here.
|
15
|
+
* typedef struct CvSURFParams {
|
16
|
+
* int extended;
|
17
|
+
* double hessianThreshold;
|
18
|
+
* int nOctaves;
|
19
|
+
* int nOctaveLayers;
|
20
|
+
* } CvSURFParams;
|
21
|
+
*/
|
22
|
+
__NAMESPACE_BEGIN_OPENCV
|
23
|
+
__NAMESPACE_BEGIN_CVSURFPARAMS
|
24
|
+
|
25
|
+
VALUE rb_klass;
|
26
|
+
|
27
|
+
VALUE
|
28
|
+
rb_class()
|
29
|
+
{
|
30
|
+
return rb_klass;
|
31
|
+
}
|
32
|
+
|
33
|
+
VALUE
|
34
|
+
rb_allocate(VALUE klass)
|
35
|
+
{
|
36
|
+
CvSURFParams *ptr;
|
37
|
+
return Data_Make_Struct(klass, CvSURFParams, 0, -1, ptr);
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* Create a CvSURFParams
|
42
|
+
*
|
43
|
+
* @overload CvSURFParams.new(hessian_threshold, extended = false, n_octaves = 3, n_octave_layers = 4)
|
44
|
+
* @param hessian_threshold [Number]
|
45
|
+
* @param extended [Boolean] If <tt>true</tt>, exteneded descriptors (128 elements each),
|
46
|
+
* otherwise basic descriptors (64 elements each)
|
47
|
+
* @param n_octaves [Integer] Number of octaves to be used for extraction
|
48
|
+
* @param n_octave_layers [Integer] Number of layers within each octave
|
49
|
+
*/
|
50
|
+
VALUE
|
51
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
52
|
+
{
|
53
|
+
CvSURFParams *self_ptr = CVSURFPARAMS(self);
|
54
|
+
VALUE h_thresh, ext, noct, noctl;
|
55
|
+
rb_scan_args(argc, argv, "13", &h_thresh, &ext, &noct, &noctl);
|
56
|
+
|
57
|
+
self_ptr->hessianThreshold = NUM2DBL(h_thresh);
|
58
|
+
self_ptr->extended = NIL_P(ext) ? 0 : BOOL2INT(ext);
|
59
|
+
self_ptr->nOctaves = NIL_P(noct) ? 3 : NUM2INT(noct);
|
60
|
+
self_ptr->nOctaveLayers = NIL_P(noctl) ? 4 : NUM2INT(noctl);
|
61
|
+
|
62
|
+
return self;
|
63
|
+
}
|
64
|
+
|
65
|
+
/*
|
66
|
+
* call-seq:
|
67
|
+
* hessian_threshold -> number
|
68
|
+
* Return threshold of hessian
|
69
|
+
*/
|
70
|
+
VALUE
|
71
|
+
rb_get_hessian_threshold(VALUE self)
|
72
|
+
{
|
73
|
+
return DBL2NUM(CVSURFPARAMS(self)->hessianThreshold);
|
74
|
+
}
|
75
|
+
|
76
|
+
/*
|
77
|
+
* call-seq:
|
78
|
+
* hessian_threshold = <i>value</i>
|
79
|
+
*
|
80
|
+
* Set threshold of hessian to <i>value</i>
|
81
|
+
*/
|
82
|
+
VALUE
|
83
|
+
rb_set_hessian_threshold(VALUE self, VALUE value)
|
84
|
+
{
|
85
|
+
CVSURFPARAMS(self)->hessianThreshold = NUM2DBL(value);
|
86
|
+
return self;
|
87
|
+
}
|
88
|
+
|
89
|
+
/*
|
90
|
+
* call-seq:
|
91
|
+
* extended -> bool
|
92
|
+
* Return the type of descripters
|
93
|
+
* false: basic descriptors (64 elements each)
|
94
|
+
* true : exteneded descriptors (128 elements each)
|
95
|
+
*/
|
96
|
+
VALUE
|
97
|
+
rb_get_extended(VALUE self)
|
98
|
+
{
|
99
|
+
return INT2BOOL(CVSURFPARAMS(self)->extended);
|
100
|
+
}
|
101
|
+
|
102
|
+
/*
|
103
|
+
* call-seq:
|
104
|
+
* extended = <i>value</i>
|
105
|
+
* Set the type of descripters
|
106
|
+
* false: basic descriptors (64 elements each)
|
107
|
+
* true : exteneded descriptors (128 elements each)
|
108
|
+
*/
|
109
|
+
VALUE
|
110
|
+
rb_set_extended(VALUE self, VALUE value)
|
111
|
+
{
|
112
|
+
CVSURFPARAMS(self)->extended = BOOL2INT(value);
|
113
|
+
return self;
|
114
|
+
}
|
115
|
+
|
116
|
+
/*
|
117
|
+
* call-seq:
|
118
|
+
* n_octaves -> fixnum
|
119
|
+
* Return the number of octaves to be used for extraction
|
120
|
+
*/
|
121
|
+
VALUE
|
122
|
+
rb_get_n_octaves(VALUE self)
|
123
|
+
{
|
124
|
+
return INT2NUM(CVSURFPARAMS(self)->nOctaves);
|
125
|
+
}
|
126
|
+
|
127
|
+
/*
|
128
|
+
* call-seq:
|
129
|
+
* n_octaves = <i>value</i>
|
130
|
+
* Set the number of octaves to be used for extraction
|
131
|
+
*/
|
132
|
+
VALUE
|
133
|
+
rb_set_n_octaves(VALUE self, VALUE value)
|
134
|
+
{
|
135
|
+
CVSURFPARAMS(self)->nOctaves = NUM2INT(value);
|
136
|
+
return self;
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* n_octave_layers -> fixnum
|
142
|
+
* Return the number of layers within each octave
|
143
|
+
*/
|
144
|
+
VALUE
|
145
|
+
rb_get_n_octave_layers(VALUE self)
|
146
|
+
{
|
147
|
+
return INT2NUM(CVSURFPARAMS(self)->nOctaveLayers);
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* call-seq:
|
152
|
+
* n_octave_layers = <i>value</i>
|
153
|
+
* Set the number of layers within each octave
|
154
|
+
*/
|
155
|
+
VALUE
|
156
|
+
rb_set_n_octave_layers(VALUE self, VALUE value)
|
157
|
+
{
|
158
|
+
CVSURFPARAMS(self)->nOctaveLayers = NUM2INT(value);
|
159
|
+
return self;
|
160
|
+
}
|
161
|
+
|
162
|
+
VALUE
|
163
|
+
new_object()
|
164
|
+
{
|
165
|
+
return rb_allocate(rb_klass);
|
166
|
+
}
|
167
|
+
|
168
|
+
VALUE
|
169
|
+
new_object(CvSURFParams* cvsurfparams)
|
170
|
+
{
|
171
|
+
VALUE object = rb_allocate(rb_klass);
|
172
|
+
CvSURFParams *ptr = CVSURFPARAMS(object);
|
173
|
+
ptr = cvsurfparams;
|
174
|
+
return object;
|
175
|
+
}
|
176
|
+
|
177
|
+
void
|
178
|
+
init_ruby_class()
|
179
|
+
{
|
180
|
+
#if 0
|
181
|
+
// For documentation using YARD
|
182
|
+
VALUE opencv = rb_define_module("OpenCV");
|
183
|
+
#endif
|
184
|
+
|
185
|
+
if (rb_klass)
|
186
|
+
return;
|
187
|
+
/*
|
188
|
+
* opencv = rb_define_module("OpenCV");
|
189
|
+
*
|
190
|
+
* note: this comment is used by rdoc.
|
191
|
+
*/
|
192
|
+
VALUE opencv = rb_module_opencv();
|
193
|
+
rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
|
194
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
195
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
196
|
+
rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
|
197
|
+
rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
|
198
|
+
rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
|
199
|
+
rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
|
200
|
+
rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
|
201
|
+
rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
|
202
|
+
rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
|
203
|
+
rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
|
204
|
+
}
|
205
|
+
|
206
|
+
__NAMESPACE_END_CVSURFPARAMS
|
207
|
+
__NAMESPACE_END_OPENCV
|
208
|
+
|