ruby-opencv 0.0.10-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +227 -0
- data/README.md +98 -0
- data/Rakefile +90 -0
- data/config.yml +7 -0
- data/examples/alpha_blend.rb +21 -0
- data/examples/box.png +0 -0
- data/examples/box_in_scene.png +0 -0
- data/examples/contours/bitmap-contours-with-labels.png +0 -0
- data/examples/contours/bitmap-contours.png +0 -0
- data/examples/contours/bounding-box-detect-canny.rb +62 -0
- data/examples/contours/contour_retrieval_modes.rb +139 -0
- data/examples/contours/rotated-boxes.jpg +0 -0
- data/examples/convexhull.rb +47 -0
- data/examples/face_detect.rb +20 -0
- data/examples/find_obj.rb +169 -0
- data/examples/houghcircle.rb +22 -0
- data/examples/inpaint.png +0 -0
- data/examples/inpaint.rb +57 -0
- data/examples/lenna-rotated.jpg +0 -0
- data/examples/lenna.jpg +0 -0
- data/examples/match_kdtree.rb +88 -0
- data/examples/matching_to_many_images.rb +16 -0
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +3 -0
- data/examples/paint.rb +70 -0
- data/examples/snake.rb +43 -0
- data/examples/stuff.jpg +0 -0
- data/examples/tiffany.jpg +0 -0
- data/ext/opencv/curve.cpp +112 -0
- data/ext/opencv/curve.h +34 -0
- data/ext/opencv/cvavgcomp.cpp +67 -0
- data/ext/opencv/cvavgcomp.h +39 -0
- data/ext/opencv/cvbox2d.cpp +197 -0
- data/ext/opencv/cvbox2d.h +61 -0
- data/ext/opencv/cvcapture.cpp +506 -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 +192 -0
- data/ext/opencv/cvutils.h +30 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/extconf.rb +83 -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/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +727 -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/images/CvMat_sobel.png +0 -0
- data/images/CvMat_sub_rect.png +0 -0
- data/images/CvSeq_relationmap.png +0 -0
- data/images/face_detect_from_lena.jpg +0 -0
- data/lib/1.9/opencv.so +0 -0
- data/lib/2.0/opencv.so +0 -0
- data/lib/opencv.rb +12 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +44 -0
- data/test/helper.rb +166 -0
- data/test/runner.rb +30 -0
- data/test/samples/airplane.jpg +0 -0
- data/test/samples/baboon.jpg +0 -0
- data/test/samples/baboon200.jpg +0 -0
- data/test/samples/baboon200_rotated.jpg +0 -0
- data/test/samples/blank0.jpg +0 -0
- data/test/samples/blank1.jpg +0 -0
- data/test/samples/blank2.jpg +0 -0
- data/test/samples/blank3.jpg +0 -0
- data/test/samples/blank4.jpg +0 -0
- data/test/samples/blank5.jpg +0 -0
- data/test/samples/blank6.jpg +0 -0
- data/test/samples/blank7.jpg +0 -0
- data/test/samples/blank8.jpg +0 -0
- data/test/samples/blank9.jpg +0 -0
- data/test/samples/cat.jpg +0 -0
- data/test/samples/chessboard.jpg +0 -0
- data/test/samples/contours.jpg +0 -0
- data/test/samples/fruits.jpg +0 -0
- data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
- data/test/samples/inpaint-mask.bmp +0 -0
- data/test/samples/lena-256x256.jpg +0 -0
- data/test/samples/lena-32x32.jpg +0 -0
- data/test/samples/lena-eyes.jpg +0 -0
- data/test/samples/lena-inpaint.jpg +0 -0
- data/test/samples/lena.jpg +0 -0
- data/test/samples/lines.jpg +0 -0
- data/test/samples/messy0.jpg +0 -0
- data/test/samples/messy1.jpg +0 -0
- data/test/samples/movie_sample.avi +0 -0
- data/test/samples/one_way_train_0000.jpg +0 -0
- data/test/samples/one_way_train_0001.jpg +0 -0
- data/test/samples/partially_blank0.jpg +0 -0
- data/test/samples/partially_blank1.jpg +0 -0
- data/test/samples/smooth0.jpg +0 -0
- data/test/samples/smooth1.jpg +0 -0
- data/test/samples/smooth2.jpg +0 -0
- data/test/samples/smooth3.jpg +0 -0
- data/test/samples/smooth4.jpg +0 -0
- data/test/samples/smooth5.jpg +0 -0
- data/test/samples/smooth6.jpg +0 -0
- data/test/samples/str-cv-rotated.jpg +0 -0
- data/test/samples/str-cv.jpg +0 -0
- data/test/samples/str-ov.jpg +0 -0
- data/test/samples/stuff.jpg +0 -0
- data/test/test_curve.rb +43 -0
- data/test/test_cvavgcomp.rb +24 -0
- data/test/test_cvbox2d.rb +76 -0
- data/test/test_cvcapture.rb +183 -0
- data/test/test_cvchain.rb +108 -0
- data/test/test_cvcircle32f.rb +41 -0
- data/test/test_cvconnectedcomp.rb +61 -0
- data/test/test_cvcontour.rb +150 -0
- data/test/test_cvcontourtree.rb +43 -0
- data/test/test_cverror.rb +50 -0
- data/test/test_cvfeaturetree.rb +65 -0
- data/test/test_cvfont.rb +58 -0
- data/test/test_cvhaarclassifiercascade.rb +63 -0
- data/test/test_cvhistogram.rb +271 -0
- data/test/test_cvhumoments.rb +83 -0
- data/test/test_cvline.rb +50 -0
- data/test/test_cvmat.rb +2947 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2015 -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 +329 -0
- data/test/test_pointset.rb +126 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +386 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvcircle32f.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2007 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVCIRCLE32F_H
|
11
|
+
#define RUBY_OPENCV_CVCIRCLE32F_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVCIRCLE32F namespace cCvCircle32f {
|
16
|
+
#define __NAMESPACE_END_CVCIRCLE32F }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
|
20
|
+
typedef struct CvCircle32f {
|
21
|
+
CvPoint2D32f center;
|
22
|
+
float radius;
|
23
|
+
} CvCircle32f;
|
24
|
+
|
25
|
+
__NAMESPACE_BEGIN_CVCIRCLE32F
|
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_center(VALUE self);
|
34
|
+
VALUE rb_radius(VALUE self);
|
35
|
+
VALUE rb_aref(VALUE self, VALUE index);
|
36
|
+
VALUE rb_to_ary(VALUE self);
|
37
|
+
|
38
|
+
VALUE new_object(CvCircle32f circle32f);
|
39
|
+
|
40
|
+
__NAMESPACE_END_CVCIRCLE32F
|
41
|
+
|
42
|
+
inline CvCircle32f*
|
43
|
+
CVCIRCLE32F(VALUE object)
|
44
|
+
{
|
45
|
+
CvCircle32f *ptr;
|
46
|
+
Data_Get_Struct(object, CvCircle32f, ptr);
|
47
|
+
return ptr;
|
48
|
+
}
|
49
|
+
|
50
|
+
__NAMESPACE_END_OPENCV
|
51
|
+
|
52
|
+
#endif // RUBY_OPENCV_CVCIRCLE32F_H
|
@@ -0,0 +1,282 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvcondensation.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvcondensation.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvConDensation
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
__NAMESPACE_BEGIN_OPENCV
|
16
|
+
__NAMESPACE_BEGIN_CVCONDENSATION
|
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
|
+
rb_klass = rb_define_class_under(opencv, "CvConDensation", rb_cObject);
|
38
|
+
rb_define_method(rb_klass, "dp", RUBY_METHOD_FUNC(rb_dp), 0);
|
39
|
+
rb_define_method(rb_klass, "mp", RUBY_METHOD_FUNC(rb_mp), 0);
|
40
|
+
rb_define_method(rb_klass, "dynamic_matrix", RUBY_METHOD_FUNC(rb_dynamic_matrix), 0);
|
41
|
+
rb_define_method(rb_klass, "confidence", RUBY_METHOD_FUNC(rb_confidence), 0);
|
42
|
+
rb_define_method(rb_klass, "cumulative", RUBY_METHOD_FUNC(rb_cumulative), 0);
|
43
|
+
rb_define_method(rb_klass, "state", RUBY_METHOD_FUNC(rb_state), 0);
|
44
|
+
rb_define_method(rb_klass, "samples_num", RUBY_METHOD_FUNC(rb_samples_num), 0);
|
45
|
+
rb_define_method(rb_klass, "init_sample_set", RUBY_METHOD_FUNC(rb_init_sample_set), 2);
|
46
|
+
rb_define_method(rb_klass, "update_by_time", RUBY_METHOD_FUNC(rb_update_by_time), 0);
|
47
|
+
rb_define_alias(rb_klass, "update", "update_by_time");
|
48
|
+
rb_define_method(rb_klass, "each_sample", RUBY_METHOD_FUNC(rb_each_sample), 0);
|
49
|
+
rb_define_method(rb_klass, "calculate_confidence", RUBY_METHOD_FUNC(rb_calculate_confidence), 0);
|
50
|
+
}
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* dp -> int
|
55
|
+
*
|
56
|
+
* Return dimension of state vector
|
57
|
+
*/
|
58
|
+
VALUE
|
59
|
+
rb_dp(VALUE self)
|
60
|
+
{
|
61
|
+
return INT2NUM(CVCONDENSATION(self)->DP);
|
62
|
+
}
|
63
|
+
|
64
|
+
/*
|
65
|
+
* call-seq:
|
66
|
+
* mp -> int
|
67
|
+
*
|
68
|
+
* Return demension of measurement vector.
|
69
|
+
*/
|
70
|
+
VALUE
|
71
|
+
rb_mp(VALUE self)
|
72
|
+
{
|
73
|
+
return INT2NUM(CVCONDENSATION(self)->MP);
|
74
|
+
}
|
75
|
+
|
76
|
+
/*
|
77
|
+
* call-seq:
|
78
|
+
* dynamic_matrix -> mat
|
79
|
+
*
|
80
|
+
* Return matrix of the linear Dynamics system.
|
81
|
+
*/
|
82
|
+
VALUE
|
83
|
+
rb_dynamic_matrix(VALUE self)
|
84
|
+
{
|
85
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
86
|
+
CvMat* mat = NULL;
|
87
|
+
try {
|
88
|
+
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, cd->DP, CV_MAKETYPE(CV_32F, 1), cd->DynamMatr);
|
89
|
+
}
|
90
|
+
catch (cv::Exception& e) {
|
91
|
+
raise_cverror(e);
|
92
|
+
}
|
93
|
+
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
* call-seq:
|
98
|
+
* confidence -> mat
|
99
|
+
*
|
100
|
+
* Return confidence for each sample.
|
101
|
+
*/
|
102
|
+
VALUE
|
103
|
+
rb_confidence(VALUE self)
|
104
|
+
{
|
105
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
106
|
+
CvMat* mat = NULL;
|
107
|
+
try {
|
108
|
+
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flConfidence);
|
109
|
+
}
|
110
|
+
catch (cv::Exception& e) {
|
111
|
+
raise_cverror(e);
|
112
|
+
}
|
113
|
+
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
114
|
+
}
|
115
|
+
|
116
|
+
/*
|
117
|
+
* call-seq:
|
118
|
+
* cumulative -> mat
|
119
|
+
*
|
120
|
+
* Return cumulative confidence.
|
121
|
+
*/
|
122
|
+
VALUE
|
123
|
+
rb_cumulative(VALUE self)
|
124
|
+
{
|
125
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
126
|
+
CvMat* mat = NULL;
|
127
|
+
try {
|
128
|
+
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flCumulative);
|
129
|
+
}
|
130
|
+
catch (cv::Exception& e) {
|
131
|
+
raise_cverror(e);
|
132
|
+
}
|
133
|
+
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
134
|
+
}
|
135
|
+
|
136
|
+
/*
|
137
|
+
* call-seq:
|
138
|
+
* state -> mat
|
139
|
+
*
|
140
|
+
* Return vector of state
|
141
|
+
*/
|
142
|
+
VALUE
|
143
|
+
rb_state(VALUE self)
|
144
|
+
{
|
145
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
146
|
+
CvMat* mat = NULL;
|
147
|
+
try {
|
148
|
+
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->State);
|
149
|
+
}
|
150
|
+
catch (cv::Exception& e) {
|
151
|
+
raise_cverror(e);
|
152
|
+
}
|
153
|
+
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
* call-seq:
|
158
|
+
* samples_num -> int
|
159
|
+
*
|
160
|
+
* Return number of the samples
|
161
|
+
*/
|
162
|
+
VALUE
|
163
|
+
rb_samples_num(VALUE self)
|
164
|
+
{
|
165
|
+
return INT2NUM(CVCONDENSATION(self)->SamplesNum);
|
166
|
+
}
|
167
|
+
|
168
|
+
/*
|
169
|
+
* call-seq:
|
170
|
+
* init_sample_set(upper, lower)
|
171
|
+
*
|
172
|
+
* Initializes sample set for ConDensation algorithm.
|
173
|
+
* Fills the samples with values within specified(lower to upper) ranges.
|
174
|
+
*/
|
175
|
+
VALUE
|
176
|
+
rb_init_sample_set(VALUE self, VALUE lower, VALUE upper)
|
177
|
+
{
|
178
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
179
|
+
CvMat *lower_bound = CVMAT_WITH_CHECK(lower), *upper_bound = CVMAT_WITH_CHECK(upper), lb_stub, ub_stub;
|
180
|
+
int lower_type = lower_bound->type, upper_type = lower_bound->type;
|
181
|
+
try {
|
182
|
+
if (lower_type != CV_32FC1 || lower_bound->cols != 1) {
|
183
|
+
if (CV_MAT_DEPTH(lower_type) == CV_32F) {
|
184
|
+
lower_bound = cvReshape(lower_bound, &lb_stub, 1, lower_bound->rows * lower_bound->cols);
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
lower = cCvMat::new_object(cvSize(lower_bound->rows * lower_bound->cols, 1), CV_MAKETYPE(CV_32S, 1));
|
188
|
+
cvConvertScale(lower_bound, CVARR(lower));
|
189
|
+
lower_bound = CVMAT(lower);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
if (upper_type != CV_32FC1 || upper_bound->cols != 1) {
|
193
|
+
if (CV_MAT_DEPTH(upper_type) == CV_32F) {
|
194
|
+
upper_bound = cvReshape(upper_bound, &ub_stub, 1, upper_bound->rows * upper_bound->cols);
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
upper = cCvMat::new_object(cvSize(upper_bound->rows * upper_bound->cols, 1), CV_MAKETYPE(CV_32F, 1));
|
198
|
+
cvConvertScale(upper_bound, CVARR(upper));
|
199
|
+
upper_bound = CVMAT(upper);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
if (lower_bound->rows != cd->DP || upper_bound->rows != cd->DP) {
|
203
|
+
rb_raise(rb_eTypeError, "sample matrix step unmatch.");
|
204
|
+
}
|
205
|
+
cvConDensInitSampleSet(cd, lower_bound, upper_bound);
|
206
|
+
}
|
207
|
+
catch (cv::Exception& e) {
|
208
|
+
raise_cverror(e);
|
209
|
+
}
|
210
|
+
return self;
|
211
|
+
}
|
212
|
+
|
213
|
+
/*
|
214
|
+
* call-seq:
|
215
|
+
* update_by_time
|
216
|
+
*
|
217
|
+
* Estimates subsequent model state.
|
218
|
+
*/
|
219
|
+
VALUE
|
220
|
+
rb_update_by_time(VALUE self)
|
221
|
+
{
|
222
|
+
try {
|
223
|
+
cvConDensUpdateByTime(CVCONDENSATION(self));
|
224
|
+
}
|
225
|
+
catch (cv::Exception& e) {
|
226
|
+
raise_cverror(e);
|
227
|
+
}
|
228
|
+
return self;
|
229
|
+
}
|
230
|
+
|
231
|
+
/*
|
232
|
+
* call-seq:
|
233
|
+
* each_sample {|mat| ... }
|
234
|
+
*
|
235
|
+
* Evaluate each sample by given block.
|
236
|
+
*/
|
237
|
+
VALUE
|
238
|
+
rb_each_sample(VALUE self)
|
239
|
+
{
|
240
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
241
|
+
if (rb_block_given_p()) {
|
242
|
+
try {
|
243
|
+
for (int i = 0; i < cd->SamplesNum; ++i) {
|
244
|
+
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
245
|
+
rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
246
|
+
}
|
247
|
+
}
|
248
|
+
catch (cv::Exception& e) {
|
249
|
+
raise_cverror(e);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
return self;
|
253
|
+
}
|
254
|
+
|
255
|
+
/*
|
256
|
+
* call-seq:
|
257
|
+
* calculate_confidence {|value| ... }
|
258
|
+
*
|
259
|
+
* Evalute each sample by given block, then return value set to confidence.
|
260
|
+
*/
|
261
|
+
VALUE
|
262
|
+
rb_calculate_confidence(VALUE self)
|
263
|
+
{
|
264
|
+
VALUE value;
|
265
|
+
CvConDensation *cd = CVCONDENSATION(self);
|
266
|
+
if (rb_block_given_p()) {
|
267
|
+
try {
|
268
|
+
for (int i = 0; i < cd->SamplesNum; ++i) {
|
269
|
+
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
270
|
+
value = rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
271
|
+
cd->flConfidence[i] = NUM2DBL(value);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
catch (cv::Exception& e) {
|
275
|
+
raise_cverror(e);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
return self;
|
279
|
+
}
|
280
|
+
|
281
|
+
__NAMESPACE_END_CVCONDENSATION
|
282
|
+
__NAMESPACE_END_OPENCV
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvcondensation.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_CVCONDENSATION_H
|
11
|
+
#define RUBY_OPENCV_CVCONDENSATION_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_CVCONDENSATION namespace cCvConDensation {
|
16
|
+
#define __NAMESPACE_END_CVCONDENSATION }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_CVCONDENSATION
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
void define_ruby_class();
|
23
|
+
|
24
|
+
VALUE rb_dp(VALUE self);
|
25
|
+
VALUE rb_mp(VALUE self);
|
26
|
+
VALUE rb_dynamic_matrix(VALUE self);
|
27
|
+
VALUE rb_state(VALUE self);
|
28
|
+
VALUE rb_confidence(VALUE self);
|
29
|
+
VALUE rb_cumulative(VALUE self);
|
30
|
+
VALUE rb_samples_num(VALUE self);
|
31
|
+
|
32
|
+
VALUE rb_init_sample_set(VALUE self, VALUE lower, VALUE upper);
|
33
|
+
VALUE rb_update_by_time(VALUE self);
|
34
|
+
VALUE rb_each_sample(VALUE self);
|
35
|
+
VALUE rb_calculate_confidence(VALUE self);
|
36
|
+
|
37
|
+
__NAMESPACE_END_CVCONDENSATION
|
38
|
+
|
39
|
+
inline CvConDensation*
|
40
|
+
CVCONDENSATION(VALUE object)
|
41
|
+
{
|
42
|
+
CvConDensation *ptr;
|
43
|
+
Data_Get_Struct(object, CvConDensation, ptr);
|
44
|
+
return ptr;
|
45
|
+
}
|
46
|
+
|
47
|
+
__NAMESPACE_END_OPENCV
|
48
|
+
|
49
|
+
#endif // RUBY_OPENCV_CVCONDENSATION_H
|
@@ -0,0 +1,143 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
cvconnectedcomp.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2007 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "cvconnectedcomp.h"
|
11
|
+
/*
|
12
|
+
* Document-class: OpenCV::CvConnectedComp
|
13
|
+
*
|
14
|
+
* see CvMat#flood_fill
|
15
|
+
*
|
16
|
+
* C structure is here.
|
17
|
+
* typedef struct CvConnectedComp
|
18
|
+
* {
|
19
|
+
* double area;
|
20
|
+
* CvScalar value;
|
21
|
+
* CvRect rect;
|
22
|
+
* CvSeq* contour;
|
23
|
+
* } CvConnectedComp;
|
24
|
+
*/
|
25
|
+
__NAMESPACE_BEGIN_OPENCV
|
26
|
+
__NAMESPACE_BEGIN_CVCONNECTEDCOMP
|
27
|
+
|
28
|
+
VALUE rb_klass;
|
29
|
+
|
30
|
+
VALUE
|
31
|
+
rb_class()
|
32
|
+
{
|
33
|
+
return rb_klass;
|
34
|
+
}
|
35
|
+
|
36
|
+
void
|
37
|
+
define_ruby_class()
|
38
|
+
{
|
39
|
+
if (rb_klass)
|
40
|
+
return;
|
41
|
+
/*
|
42
|
+
* opencv = rb_define_module("OpenCV");
|
43
|
+
*
|
44
|
+
* note: this comment is used by rdoc.
|
45
|
+
*/
|
46
|
+
VALUE opencv = rb_module_opencv();
|
47
|
+
|
48
|
+
rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
|
49
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
50
|
+
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
51
|
+
rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
|
52
|
+
rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
|
53
|
+
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
|
54
|
+
rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
|
55
|
+
rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE
|
59
|
+
rb_allocate(VALUE klass)
|
60
|
+
{
|
61
|
+
CvConnectedComp *ptr;
|
62
|
+
return Data_Make_Struct(klass, CvConnectedComp, 0, -1, ptr);
|
63
|
+
}
|
64
|
+
|
65
|
+
VALUE
|
66
|
+
rb_initialize(int argc, VALUE *argv, VALUE self)
|
67
|
+
{
|
68
|
+
VALUE area, value, rect, contour;
|
69
|
+
rb_scan_args(argc, argv, "04", &area, &value, &rect, &contour);
|
70
|
+
|
71
|
+
if (!NIL_P(area))
|
72
|
+
CVCONNECTEDCOMP(self)->area = NUM2DBL(area);
|
73
|
+
if (!NIL_P(value))
|
74
|
+
CVCONNECTEDCOMP(self)->value = *CVSCALAR(value);
|
75
|
+
if (!NIL_P(rect))
|
76
|
+
CVCONNECTEDCOMP(self)->rect = *CVRECT(rect);
|
77
|
+
if (!NIL_P(contour))
|
78
|
+
CVCONNECTEDCOMP(self)->contour = CVSEQ(contour);
|
79
|
+
return self;
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* Return area of connected component.
|
84
|
+
*/
|
85
|
+
VALUE
|
86
|
+
rb_area(VALUE self)
|
87
|
+
{
|
88
|
+
return rb_float_new(CVCONNECTEDCOMP(self)->area);
|
89
|
+
}
|
90
|
+
|
91
|
+
/*
|
92
|
+
* Return average color of the connected component.
|
93
|
+
*/
|
94
|
+
VALUE
|
95
|
+
rb_value(VALUE self)
|
96
|
+
{
|
97
|
+
return REFER_OBJECT(cCvScalar::rb_class(), &CVCONNECTEDCOMP(self)->value, self);
|
98
|
+
}
|
99
|
+
|
100
|
+
/*
|
101
|
+
* Return ROI of the component.
|
102
|
+
*/
|
103
|
+
VALUE
|
104
|
+
rb_rect(VALUE self)
|
105
|
+
{
|
106
|
+
return REFER_OBJECT(cCvRect::rb_class(), &CVCONNECTEDCOMP(self)->rect, self);
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* Set ROI of the component.
|
111
|
+
*/
|
112
|
+
VALUE
|
113
|
+
rb_set_rect(VALUE self, VALUE rect)
|
114
|
+
{
|
115
|
+
CVCONNECTEDCOMP(self)->rect = VALUE_TO_CVRECT(rect);
|
116
|
+
return self;
|
117
|
+
}
|
118
|
+
|
119
|
+
/*
|
120
|
+
* Return optional component boundary
|
121
|
+
*/
|
122
|
+
VALUE
|
123
|
+
rb_contour(VALUE self)
|
124
|
+
{
|
125
|
+
return REFER_OBJECT(cCvContour::rb_class(), &CVCONNECTEDCOMP(self)->contour, self);
|
126
|
+
}
|
127
|
+
|
128
|
+
VALUE
|
129
|
+
new_object()
|
130
|
+
{
|
131
|
+
return rb_allocate(rb_klass);
|
132
|
+
}
|
133
|
+
|
134
|
+
VALUE
|
135
|
+
new_object(CvConnectedComp comp)
|
136
|
+
{
|
137
|
+
VALUE object = rb_allocate(rb_klass);
|
138
|
+
*CVCONNECTEDCOMP(object) = comp;
|
139
|
+
return object;
|
140
|
+
}
|
141
|
+
|
142
|
+
__NAMESPACE_END_CVCONNECTEDCOMP
|
143
|
+
__NAMESPACE_END_OPENCV
|