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,73 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvhistogram.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2008 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVHISTOGRAM_H
|
11
|
+
#define RUBY_OPENCV_CVHISTOGRAM_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVHISTOGRAM namespace cCvHistogram {
|
16
|
+
#define __NAMESPACE_END_CVHISTOGRAM }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVHISTOGRAM
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
VALUE rb_allocate(VALUE klass);
|
23
|
+
void init_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
26
|
+
VALUE rb_is_uniform(VALUE self);
|
27
|
+
VALUE rb_is_sparse(VALUE self);
|
28
|
+
VALUE rb_has_range(VALUE self);
|
29
|
+
VALUE rb_calc_hist(int argc, VALUE* argv, VALUE self);
|
30
|
+
VALUE rb_calc_hist_bang(int argc, VALUE* argv, VALUE self);
|
31
|
+
VALUE rb_aref(VALUE self, VALUE args);
|
32
|
+
VALUE rb_min_max_value(VALUE self);
|
33
|
+
VALUE rb_dims(VALUE self);
|
34
|
+
VALUE rb_copy_hist(VALUE self);
|
35
|
+
|
36
|
+
VALUE rb_clear_hist(VALUE self);
|
37
|
+
VALUE rb_clear_hist_bang(VALUE self);
|
38
|
+
|
39
|
+
VALUE rb_normalize_hist(VALUE self, VALUE factor);
|
40
|
+
VALUE rb_normalize_hist_bang(VALUE self, VALUE factor);
|
41
|
+
VALUE rb_thresh_hist(VALUE self, VALUE threshold);
|
42
|
+
VALUE rb_thresh_hist_bang(VALUE self, VALUE threshold);
|
43
|
+
|
44
|
+
VALUE rb_set_hist_bin_ranges(int argc, VALUE* argv, VALUE self);
|
45
|
+
VALUE rb_set_hist_bin_ranges_bang(int argc, VALUE* argv, VALUE self);
|
46
|
+
|
47
|
+
VALUE rb_calc_back_project(VALUE self, VALUE image);
|
48
|
+
VALUE rb_calc_back_project_patch(VALUE self, VALUE image, VALUE patch_size, VALUE method, VALUE factor);
|
49
|
+
|
50
|
+
VALUE rb_compare_hist(VALUE self, VALUE hist1, VALUE hist2, VALUE method);
|
51
|
+
VALUE rb_calc_prob_density(int argc, VALUE* argv, VALUE self);
|
52
|
+
|
53
|
+
__NAMESPACE_END_CVHISTOGRAM
|
54
|
+
|
55
|
+
inline CvHistogram*
|
56
|
+
CVHISTOGRAM(VALUE object)
|
57
|
+
{
|
58
|
+
CvHistogram* ptr;
|
59
|
+
Data_Get_Struct(object, CvHistogram, ptr);
|
60
|
+
return ptr;
|
61
|
+
}
|
62
|
+
|
63
|
+
inline CvHistogram*
|
64
|
+
CVHISTOGRAM_WITH_CHECK(VALUE object)
|
65
|
+
{
|
66
|
+
if (!rb_obj_is_kind_of(object, cCvHistogram::rb_class()))
|
67
|
+
raise_typeerror(object, cCvHistogram::rb_class());
|
68
|
+
return CVHISTOGRAM(object);
|
69
|
+
}
|
70
|
+
|
71
|
+
__NAMESPACE_END_OPENCV
|
72
|
+
|
73
|
+
#endif // RUBY_OPENCV_CVHISTOGRAM_H
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvhumoments.cpp -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvhumoments.h"
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Document-class: OpenCV::CvHuMoments
|
14
|
+
*
|
15
|
+
* Hu invariants
|
16
|
+
*/
|
17
|
+
__NAMESPACE_BEGIN_OPENCV
|
18
|
+
__NAMESPACE_BEGIN_CVHUMOMENTS
|
19
|
+
|
20
|
+
VALUE rb_klass;
|
21
|
+
|
22
|
+
VALUE
|
23
|
+
rb_class()
|
24
|
+
{
|
25
|
+
return rb_klass;
|
26
|
+
}
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
rb_allocate(VALUE klass)
|
30
|
+
{
|
31
|
+
CvHuMoments *ptr;
|
32
|
+
return Data_Make_Struct(klass, CvHuMoments, 0, -1, ptr);
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* Calculates the seven Hu invariants
|
37
|
+
* @overload new(src_moments)
|
38
|
+
* @param src_moments [CvMoment] Input moments
|
39
|
+
* @return [CvHuMoments] Output Hu invariants
|
40
|
+
* @opencv_func cvGetHuMoments
|
41
|
+
* @see http://en.wikipedia.org/wiki/Image_moment#Rotation_invariant_moments
|
42
|
+
*/
|
43
|
+
VALUE
|
44
|
+
rb_initialize(VALUE self, VALUE src_moments)
|
45
|
+
{
|
46
|
+
try {
|
47
|
+
cvGetHuMoments(CVMOMENTS(src_moments), CVHUMOMENTS(self));
|
48
|
+
}
|
49
|
+
catch (cv::Exception& e) {
|
50
|
+
raise_cverror(e);
|
51
|
+
}
|
52
|
+
return self;
|
53
|
+
}
|
54
|
+
|
55
|
+
/*
|
56
|
+
* Returns hu1 invariant
|
57
|
+
* @overload hu1
|
58
|
+
* @return [Number] hu1 invariant
|
59
|
+
*/
|
60
|
+
VALUE rb_hu1(VALUE self) {
|
61
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu1);
|
62
|
+
}
|
63
|
+
|
64
|
+
/*
|
65
|
+
* Returns hu2 invariant
|
66
|
+
* @overload hu2
|
67
|
+
* @return [Number] hu2 invariant
|
68
|
+
*/
|
69
|
+
VALUE rb_hu2(VALUE self) {
|
70
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu2);
|
71
|
+
}
|
72
|
+
|
73
|
+
/*
|
74
|
+
* Returns hu3 invariant
|
75
|
+
* @overload hu3
|
76
|
+
* @return [Number] hu3 invariant
|
77
|
+
*/
|
78
|
+
VALUE rb_hu3(VALUE self) {
|
79
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu3);
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* Returns hu4 invariant
|
84
|
+
* @overload hu4
|
85
|
+
* @return [Number] hu4 invariant
|
86
|
+
*/
|
87
|
+
VALUE rb_hu4(VALUE self) {
|
88
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu4);
|
89
|
+
}
|
90
|
+
|
91
|
+
/*
|
92
|
+
* Returns hu5 invariant
|
93
|
+
* @overload hu5
|
94
|
+
* @return [Number] hu5 invariant
|
95
|
+
*/
|
96
|
+
VALUE rb_hu5(VALUE self) {
|
97
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu5);
|
98
|
+
}
|
99
|
+
|
100
|
+
/*
|
101
|
+
* Returns hu6 invariant
|
102
|
+
* @overload hu6
|
103
|
+
* @return [Number] hu6 invariant
|
104
|
+
*/
|
105
|
+
VALUE rb_hu6(VALUE self) {
|
106
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu6);
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* Returns hu7 invariant
|
111
|
+
* @overload hu7
|
112
|
+
* @return [Number] hu7 invariant
|
113
|
+
*/
|
114
|
+
VALUE rb_hu7(VALUE self) {
|
115
|
+
return DBL2NUM(CVHUMOMENTS(self)->hu7);
|
116
|
+
}
|
117
|
+
|
118
|
+
/*
|
119
|
+
* Returns hu invaliants as an Array
|
120
|
+
* @overload to_ary
|
121
|
+
* @return [Array<Number>] Hu invaliants
|
122
|
+
*/
|
123
|
+
VALUE
|
124
|
+
rb_to_ary(VALUE self)
|
125
|
+
{
|
126
|
+
CvHuMoments *hu_moments = CVHUMOMENTS(self);
|
127
|
+
return rb_ary_new3(7,
|
128
|
+
rb_float_new(hu_moments->hu1),
|
129
|
+
rb_float_new(hu_moments->hu2),
|
130
|
+
rb_float_new(hu_moments->hu3),
|
131
|
+
rb_float_new(hu_moments->hu4),
|
132
|
+
rb_float_new(hu_moments->hu5),
|
133
|
+
rb_float_new(hu_moments->hu6),
|
134
|
+
rb_float_new(hu_moments->hu7));
|
135
|
+
}
|
136
|
+
|
137
|
+
VALUE
|
138
|
+
new_object(CvMoments *src_moments)
|
139
|
+
{
|
140
|
+
VALUE object = rb_allocate(rb_klass);
|
141
|
+
try {
|
142
|
+
cvGetHuMoments(src_moments, CVHUMOMENTS(object));
|
143
|
+
}
|
144
|
+
catch (cv::Exception& e) {
|
145
|
+
raise_cverror(e);
|
146
|
+
}
|
147
|
+
return object;
|
148
|
+
}
|
149
|
+
|
150
|
+
void
|
151
|
+
init_ruby_class()
|
152
|
+
{
|
153
|
+
#if 0
|
154
|
+
// For documentation using YARD
|
155
|
+
VALUE opencv = rb_define_module("OpenCV");
|
156
|
+
#endif
|
157
|
+
|
158
|
+
if (rb_klass)
|
159
|
+
return;
|
160
|
+
VALUE opencv = rb_module_opencv();
|
161
|
+
|
162
|
+
rb_klass = rb_define_class_under(opencv, "CvHuMoments", rb_cObject);
|
163
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
164
|
+
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
|
165
|
+
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
166
|
+
rb_define_alias(rb_klass, "to_a", "to_ary");
|
167
|
+
|
168
|
+
rb_define_method(rb_klass, "hu1", RUBY_METHOD_FUNC(rb_hu1), 0);
|
169
|
+
rb_define_method(rb_klass, "hu2", RUBY_METHOD_FUNC(rb_hu2), 0);
|
170
|
+
rb_define_method(rb_klass, "hu3", RUBY_METHOD_FUNC(rb_hu3), 0);
|
171
|
+
rb_define_method(rb_klass, "hu4", RUBY_METHOD_FUNC(rb_hu4), 0);
|
172
|
+
rb_define_method(rb_klass, "hu5", RUBY_METHOD_FUNC(rb_hu5), 0);
|
173
|
+
rb_define_method(rb_klass, "hu6", RUBY_METHOD_FUNC(rb_hu6), 0);
|
174
|
+
rb_define_method(rb_klass, "hu7", RUBY_METHOD_FUNC(rb_hu7), 0);
|
175
|
+
}
|
176
|
+
|
177
|
+
__NAMESPACE_END_CVHUMOMENTS
|
178
|
+
__NAMESPACE_END_OPENCV
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvhumoments.h -
|
4
|
+
|
5
|
+
$Author: ser1zw $
|
6
|
+
|
7
|
+
Copyright (C) 2011 ser1zw
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVHUMOMENTS_H
|
11
|
+
#define RUBY_OPENCV_CVHUMOMENTS_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVHUMOMENTS namespace cCvHuMoments {
|
16
|
+
#define __NAMESPACE_END_CVHUMOMENTS }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVHUMOMENTS
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void init_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_allocate(VALUE klass);
|
26
|
+
VALUE rb_initialize(VALUE src_moments, VALUE self);
|
27
|
+
|
28
|
+
VALUE rb_hu1(VALUE self);
|
29
|
+
VALUE rb_hu2(VALUE self);
|
30
|
+
VALUE rb_hu3(VALUE self);
|
31
|
+
VALUE rb_hu4(VALUE self);
|
32
|
+
VALUE rb_hu5(VALUE self);
|
33
|
+
VALUE rb_hu6(VALUE self);
|
34
|
+
VALUE rb_hu7(VALUE self);
|
35
|
+
VALUE rb_to_ary(VALUE self);
|
36
|
+
|
37
|
+
VALUE new_object(CvMoments *cvmoments);
|
38
|
+
|
39
|
+
__NAMESPACE_END_CVHUMOMENTS
|
40
|
+
|
41
|
+
inline CvHuMoments*
|
42
|
+
CVHUMOMENTS(VALUE object)
|
43
|
+
{
|
44
|
+
CvHuMoments *ptr;
|
45
|
+
Data_Get_Struct(object, CvHuMoments, ptr);
|
46
|
+
return ptr;
|
47
|
+
}
|
48
|
+
|
49
|
+
__NAMESPACE_END_OPENCV
|
50
|
+
|
51
|
+
#endif // RUBY_OPENCV_CVHUMOMENTS_H
|
@@ -0,0 +1,159 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvline.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvline.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvLine
|
13
|
+
*
|
14
|
+
* Line parameters represented by a two-element (rho, theta)
|
15
|
+
* for CvMat#hough_lines
|
16
|
+
*/
|
17
|
+
__NAMESPACE_BEGIN_OPENCV
|
18
|
+
__NAMESPACE_BEGIN_CVLINE
|
19
|
+
|
20
|
+
VALUE rb_klass;
|
21
|
+
|
22
|
+
VALUE
|
23
|
+
rb_class()
|
24
|
+
{
|
25
|
+
return rb_klass;
|
26
|
+
}
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
rb_allocate(VALUE klass)
|
30
|
+
{
|
31
|
+
CvLine *ptr;
|
32
|
+
return Data_Make_Struct(klass, CvLine, 0, -1, ptr);
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* Returns distance from the coordinate origin (0, 0)
|
37
|
+
* @overload rho
|
38
|
+
* @return [Number] Distance from the coordinate origin
|
39
|
+
*/
|
40
|
+
VALUE
|
41
|
+
rb_rho(VALUE self)
|
42
|
+
{
|
43
|
+
return rb_float_new(CVLINE(self)->rho);
|
44
|
+
}
|
45
|
+
|
46
|
+
/*
|
47
|
+
* Set distance from the coordinate origin (0, 0)
|
48
|
+
* @overload rho=(value)
|
49
|
+
* @param value [Number] Distance from the coordinate origin
|
50
|
+
*/
|
51
|
+
VALUE
|
52
|
+
rb_set_rho(VALUE self, VALUE rho)
|
53
|
+
{
|
54
|
+
CVLINE(self)->rho = NUM2DBL(rho);
|
55
|
+
return self;
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Returns line rotation angle in radians
|
60
|
+
* @overload theta
|
61
|
+
* @return [Number] Line rotation angle in radians
|
62
|
+
*/
|
63
|
+
VALUE
|
64
|
+
rb_theta(VALUE self)
|
65
|
+
{
|
66
|
+
return rb_float_new(CVLINE(self)->theta);
|
67
|
+
}
|
68
|
+
|
69
|
+
/*
|
70
|
+
* Set line rotation angle in radians
|
71
|
+
* @overload theta=(value)
|
72
|
+
* @param value [Number] Line rotation angle
|
73
|
+
*/
|
74
|
+
VALUE
|
75
|
+
rb_set_theta(VALUE self, VALUE theta)
|
76
|
+
{
|
77
|
+
CVLINE(self)->theta = NUM2DBL(theta);
|
78
|
+
return self;
|
79
|
+
}
|
80
|
+
|
81
|
+
/*
|
82
|
+
* Returns value of rho, theta
|
83
|
+
* @overload [](index)
|
84
|
+
* @param index [Integer] Index
|
85
|
+
* @return [Number] If index = 0, returns rho, else if index = 1, returns theta.
|
86
|
+
*/
|
87
|
+
VALUE
|
88
|
+
rb_aref(VALUE self, VALUE index)
|
89
|
+
{
|
90
|
+
switch (NUM2INT(index)) {
|
91
|
+
case 0:
|
92
|
+
return DBL2NUM(CVLINE(self)->rho);
|
93
|
+
break;
|
94
|
+
case 1:
|
95
|
+
return DBL2NUM(CVLINE(self)->theta);
|
96
|
+
break;
|
97
|
+
default:
|
98
|
+
rb_raise(rb_eIndexError, "index should be 0...2");
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
return Qnil;
|
102
|
+
}
|
103
|
+
|
104
|
+
/*
|
105
|
+
* Set value of rho, theta
|
106
|
+
* @overload []=(index, value)
|
107
|
+
* @param index [Integer] Index
|
108
|
+
* @param value [Number] Value
|
109
|
+
* @return [Number] If index = 0, set rho, else if index = 1, set theta.
|
110
|
+
*/
|
111
|
+
VALUE
|
112
|
+
rb_aset(VALUE self, VALUE index, VALUE value)
|
113
|
+
{
|
114
|
+
switch (NUM2INT(index)) {
|
115
|
+
case 0:
|
116
|
+
CVLINE(self)->rho = NUM2DBL(value);
|
117
|
+
break;
|
118
|
+
case 1:
|
119
|
+
CVLINE(self)->theta = NUM2DBL(value);
|
120
|
+
break;
|
121
|
+
default:
|
122
|
+
rb_raise(rb_eIndexError, "index should be 0...2");
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
return value;
|
126
|
+
}
|
127
|
+
|
128
|
+
VALUE
|
129
|
+
new_object(CvLine line)
|
130
|
+
{
|
131
|
+
VALUE object = rb_allocate(rb_klass);
|
132
|
+
*CVLINE(object) = line;
|
133
|
+
return object;
|
134
|
+
}
|
135
|
+
|
136
|
+
void
|
137
|
+
init_ruby_class()
|
138
|
+
{
|
139
|
+
#if 0
|
140
|
+
// For documentation using YARD
|
141
|
+
VALUE opencv = rb_define_module("OpenCV");
|
142
|
+
#endif
|
143
|
+
|
144
|
+
if (rb_klass)
|
145
|
+
return;
|
146
|
+
VALUE opencv = rb_module_opencv();
|
147
|
+
|
148
|
+
rb_klass = rb_define_class_under(opencv, "CvLine", rb_cObject);
|
149
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
150
|
+
rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0);
|
151
|
+
rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1);
|
152
|
+
rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0);
|
153
|
+
rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1);
|
154
|
+
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
155
|
+
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
156
|
+
}
|
157
|
+
|
158
|
+
__NAMESPACE_END_CVLINE
|
159
|
+
__NAMESPACE_END_OPENCV
|