ruby-opencv 0.0.8.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +229 -0
- data/README.rdoc +149 -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-with-detected-bounding-rectangles.jpg +0 -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/GPATH +0 -0
- data/ext/opencv/GSYMS +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/ruby-opencv.gemspec +43 -0
- data/test/helper.rb +166 -0
- data/test/log.txt +55 -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
- data/test/videowriter_result.avi +0 -0
- metadata +394 -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 define_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,139 @@
|
|
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
|
+
* moments
|
16
|
+
*/
|
17
|
+
__NAMESPACE_BEGIN_OPENCV
|
18
|
+
__NAMESPACE_BEGIN_CVHUMOMENTS
|
19
|
+
|
20
|
+
#define DEFINE_CVHUMOMENTS_GETTER(elem) \
|
21
|
+
rb_define_method(rb_klass, #elem, RUBY_METHOD_FUNC(rb_##elem), 0)
|
22
|
+
|
23
|
+
#define CVHUMOMENTS_GETTER(elem) \
|
24
|
+
VALUE rb_##elem(VALUE self) { return DBL2NUM(CVHUMOMENTS(self)->elem); }
|
25
|
+
|
26
|
+
VALUE rb_klass;
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
rb_class()
|
30
|
+
{
|
31
|
+
return rb_klass;
|
32
|
+
}
|
33
|
+
|
34
|
+
void
|
35
|
+
define_ruby_class()
|
36
|
+
{
|
37
|
+
if (rb_klass)
|
38
|
+
return;
|
39
|
+
/*
|
40
|
+
* opencv = rb_define_module("OpenCV");
|
41
|
+
*
|
42
|
+
* note: this comment is used by rdoc.
|
43
|
+
*/
|
44
|
+
VALUE opencv = rb_module_opencv();
|
45
|
+
|
46
|
+
rb_klass = rb_define_class_under(opencv, "CvHuMoments", rb_cObject);
|
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, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
50
|
+
rb_define_alias(rb_klass, "to_a", "to_ary");
|
51
|
+
|
52
|
+
DEFINE_CVHUMOMENTS_GETTER(hu1);
|
53
|
+
DEFINE_CVHUMOMENTS_GETTER(hu2);
|
54
|
+
DEFINE_CVHUMOMENTS_GETTER(hu3);
|
55
|
+
DEFINE_CVHUMOMENTS_GETTER(hu4);
|
56
|
+
DEFINE_CVHUMOMENTS_GETTER(hu5);
|
57
|
+
DEFINE_CVHUMOMENTS_GETTER(hu6);
|
58
|
+
DEFINE_CVHUMOMENTS_GETTER(hu7);
|
59
|
+
}
|
60
|
+
|
61
|
+
VALUE
|
62
|
+
rb_allocate(VALUE klass)
|
63
|
+
{
|
64
|
+
CvHuMoments *ptr;
|
65
|
+
return Data_Make_Struct(klass, CvHuMoments, 0, -1, ptr);
|
66
|
+
}
|
67
|
+
|
68
|
+
/*
|
69
|
+
* call-seq:
|
70
|
+
* CvHuMoments.new(<i>src_moments</i>)
|
71
|
+
*
|
72
|
+
* Calculates the seven Hu invariants.
|
73
|
+
* <i>src_moments</i> The input moments
|
74
|
+
*
|
75
|
+
* seven Hu invariants that are defined as:
|
76
|
+
* h1=η20+η02
|
77
|
+
* h2=(η20-η02)²+4η11²
|
78
|
+
* h3=(η30-3η12)²+ (3η21-η03)²
|
79
|
+
* h4=(η30+η12)²+ (η21+η03)²
|
80
|
+
* h5=(η30-3η12)(η30+η12)[(η30+η12)²-3(η21+η03)²]+(3η21-η03)(η21+η03)[3(η30+η12)²-(η21+η03)²]
|
81
|
+
* h6=(η20-η02)[(η30+η12)²- (η21+η03)²]+4η11(η30+η12)(η21+η03)
|
82
|
+
* h7=(3η21-η03)(η21+η03)[3(η30+η12)²-(η21+η03)²]-(η30-3η12)(η21+η03)[3(η30+η12)²-(η21+η03)²]
|
83
|
+
* where ηi,j are normalized central moments of 2-nd and 3-rd orders. The computed values are proved to be invariant to the image scaling, rotation, and reflection except the seventh one, whose sign is changed by reflection.
|
84
|
+
*/
|
85
|
+
VALUE
|
86
|
+
rb_initialize(VALUE self, VALUE src_moments)
|
87
|
+
{
|
88
|
+
try {
|
89
|
+
cvGetHuMoments(CVMOMENTS(src_moments), CVHUMOMENTS(self));
|
90
|
+
}
|
91
|
+
catch (cv::Exception& e) {
|
92
|
+
raise_cverror(e);
|
93
|
+
}
|
94
|
+
return self;
|
95
|
+
}
|
96
|
+
|
97
|
+
CVHUMOMENTS_GETTER(hu1);
|
98
|
+
CVHUMOMENTS_GETTER(hu2);
|
99
|
+
CVHUMOMENTS_GETTER(hu3);
|
100
|
+
CVHUMOMENTS_GETTER(hu4);
|
101
|
+
CVHUMOMENTS_GETTER(hu5);
|
102
|
+
CVHUMOMENTS_GETTER(hu6);
|
103
|
+
CVHUMOMENTS_GETTER(hu7);
|
104
|
+
|
105
|
+
/*
|
106
|
+
* call-seq:
|
107
|
+
* to_ary -> [hu1, hu2, ... ,hu7]
|
108
|
+
*
|
109
|
+
* Return values by Array.
|
110
|
+
*/
|
111
|
+
VALUE
|
112
|
+
rb_to_ary(VALUE self)
|
113
|
+
{
|
114
|
+
CvHuMoments *hu_moments = CVHUMOMENTS(self);
|
115
|
+
return rb_ary_new3(7,
|
116
|
+
rb_float_new(hu_moments->hu1),
|
117
|
+
rb_float_new(hu_moments->hu2),
|
118
|
+
rb_float_new(hu_moments->hu3),
|
119
|
+
rb_float_new(hu_moments->hu4),
|
120
|
+
rb_float_new(hu_moments->hu5),
|
121
|
+
rb_float_new(hu_moments->hu6),
|
122
|
+
rb_float_new(hu_moments->hu7));
|
123
|
+
}
|
124
|
+
|
125
|
+
VALUE
|
126
|
+
new_object(CvMoments *src_moments)
|
127
|
+
{
|
128
|
+
VALUE object = rb_allocate(rb_klass);
|
129
|
+
try {
|
130
|
+
cvGetHuMoments(src_moments, CVHUMOMENTS(object));
|
131
|
+
}
|
132
|
+
catch (cv::Exception& e) {
|
133
|
+
raise_cverror(e);
|
134
|
+
}
|
135
|
+
return object;
|
136
|
+
}
|
137
|
+
|
138
|
+
__NAMESPACE_END_CVHUMOMENTS
|
139
|
+
__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 define_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,154 @@
|
|
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
|
+
*/
|
15
|
+
__NAMESPACE_BEGIN_OPENCV
|
16
|
+
__NAMESPACE_BEGIN_CVLINE
|
17
|
+
|
18
|
+
VALUE rb_klass;
|
19
|
+
|
20
|
+
VALUE
|
21
|
+
rb_class()
|
22
|
+
{
|
23
|
+
return rb_klass;
|
24
|
+
}
|
25
|
+
|
26
|
+
void
|
27
|
+
define_ruby_class()
|
28
|
+
{
|
29
|
+
if (rb_klass)
|
30
|
+
return;
|
31
|
+
/*
|
32
|
+
* opencv = rb_define_module("OpenCV");
|
33
|
+
*
|
34
|
+
* note: this comment is used by rdoc.
|
35
|
+
*/
|
36
|
+
VALUE opencv = rb_module_opencv();
|
37
|
+
|
38
|
+
rb_klass = rb_define_class_under(opencv, "CvLine", rb_cObject);
|
39
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
40
|
+
rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0);
|
41
|
+
rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1);
|
42
|
+
rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0);
|
43
|
+
rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1);
|
44
|
+
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
45
|
+
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
46
|
+
}
|
47
|
+
|
48
|
+
VALUE
|
49
|
+
rb_allocate(VALUE klass)
|
50
|
+
{
|
51
|
+
CvLine *ptr;
|
52
|
+
return Data_Make_Struct(klass, CvLine, 0, -1, ptr);
|
53
|
+
}
|
54
|
+
|
55
|
+
/*
|
56
|
+
* Return parameter on rho.
|
57
|
+
*/
|
58
|
+
VALUE
|
59
|
+
rb_rho(VALUE self)
|
60
|
+
{
|
61
|
+
return rb_float_new(CVLINE(self)->rho);
|
62
|
+
}
|
63
|
+
|
64
|
+
/*
|
65
|
+
* call-seq:
|
66
|
+
* rho = val
|
67
|
+
*
|
68
|
+
* Set rho parameter, return self.
|
69
|
+
*/
|
70
|
+
VALUE
|
71
|
+
rb_set_rho(VALUE self, VALUE rho)
|
72
|
+
{
|
73
|
+
CVLINE(self)->rho = NUM2DBL(rho);
|
74
|
+
return self;
|
75
|
+
}
|
76
|
+
|
77
|
+
/*
|
78
|
+
* Return parameter on theta.
|
79
|
+
*/
|
80
|
+
VALUE
|
81
|
+
rb_theta(VALUE self)
|
82
|
+
{
|
83
|
+
return rb_float_new(CVLINE(self)->theta);
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* call-seq:
|
88
|
+
* y = val
|
89
|
+
*
|
90
|
+
* Set theta parameter, return self.
|
91
|
+
*/
|
92
|
+
VALUE
|
93
|
+
rb_set_theta(VALUE self, VALUE theta)
|
94
|
+
{
|
95
|
+
CVLINE(self)->theta = NUM2DBL(theta);
|
96
|
+
return self;
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
* call-seq:
|
101
|
+
* [<i>index</i>]
|
102
|
+
*
|
103
|
+
* Return value of <i>index</i> dimension.
|
104
|
+
*/
|
105
|
+
VALUE
|
106
|
+
rb_aref(VALUE self, VALUE index)
|
107
|
+
{
|
108
|
+
switch (NUM2INT(index)) {
|
109
|
+
case 0:
|
110
|
+
return DBL2NUM(CVLINE(self)->rho);
|
111
|
+
break;
|
112
|
+
case 1:
|
113
|
+
return DBL2NUM(CVLINE(self)->theta);
|
114
|
+
break;
|
115
|
+
default:
|
116
|
+
rb_raise(rb_eIndexError, "index should be 0...2");
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
return Qnil;
|
120
|
+
}
|
121
|
+
|
122
|
+
/*
|
123
|
+
* call-seq:
|
124
|
+
* [<i>index</i>] = <i>value</i>
|
125
|
+
*
|
126
|
+
* Set value of <i>index</i> dimension to <i>value</i>
|
127
|
+
*/
|
128
|
+
VALUE
|
129
|
+
rb_aset(VALUE self, VALUE index, VALUE value)
|
130
|
+
{
|
131
|
+
switch (NUM2INT(index)) {
|
132
|
+
case 0:
|
133
|
+
CVLINE(self)->rho = NUM2DBL(value);
|
134
|
+
break;
|
135
|
+
case 1:
|
136
|
+
CVLINE(self)->theta = NUM2DBL(value);
|
137
|
+
break;
|
138
|
+
default:
|
139
|
+
rb_raise(rb_eIndexError, "index should be 0...2");
|
140
|
+
break;
|
141
|
+
}
|
142
|
+
return value;
|
143
|
+
}
|
144
|
+
|
145
|
+
VALUE
|
146
|
+
new_object(CvLine line)
|
147
|
+
{
|
148
|
+
VALUE object = rb_allocate(rb_klass);
|
149
|
+
*CVLINE(object) = line;
|
150
|
+
return object;
|
151
|
+
}
|
152
|
+
|
153
|
+
__NAMESPACE_END_CVLINE
|
154
|
+
__NAMESPACE_END_OPENCV
|
data/ext/opencv/cvline.h
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvline.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2007 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVLINE_H
|
11
|
+
#define RUBY_OPENCV_CVLINE_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVLINE namespace cCvLine {
|
16
|
+
#define __NAMESPACE_END_CVLINE }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
|
20
|
+
typedef struct CvLine {
|
21
|
+
float rho;
|
22
|
+
float theta;
|
23
|
+
} CvLine;
|
24
|
+
|
25
|
+
__NAMESPACE_BEGIN_CVLINE
|
26
|
+
|
27
|
+
VALUE rb_class();
|
28
|
+
|
29
|
+
void define_ruby_class();
|
30
|
+
|
31
|
+
VALUE rb_allocate(VALUE klass);
|
32
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
33
|
+
VALUE rb_rho(VALUE self);
|
34
|
+
VALUE rb_set_rho(VALUE self, VALUE rho);
|
35
|
+
VALUE rb_theta(VALUE self);
|
36
|
+
VALUE rb_set_theta(VALUE self, VALUE theta);
|
37
|
+
VALUE rb_aref(VALUE self, VALUE index);
|
38
|
+
VALUE rb_aset(VALUE self, VALUE index, VALUE value);
|
39
|
+
|
40
|
+
VALUE new_object(CvLine line);
|
41
|
+
|
42
|
+
__NAMESPACE_END_CVLINE
|
43
|
+
|
44
|
+
inline CvLine*
|
45
|
+
CVLINE(VALUE object)
|
46
|
+
{
|
47
|
+
CvLine *ptr;
|
48
|
+
Data_Get_Struct(object, CvLine, ptr);
|
49
|
+
return ptr;
|
50
|
+
}
|
51
|
+
|
52
|
+
__NAMESPACE_END_OPENCV
|
53
|
+
|
54
|
+
#endif // RUBY_OPENCV_CVLINE_H
|