ruby-opencv 0.0.11 → 0.0.12.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.yardopts +3 -0
  4. data/Gemfile +1 -0
  5. data/Manifest.txt +2 -14
  6. data/README.md +1 -1
  7. data/Rakefile +10 -1
  8. data/examples/facerec/facerec_lbph.rb +1 -1
  9. data/ext/opencv/algorithm.cpp +6 -1
  10. data/ext/opencv/algorithm.h +1 -1
  11. data/ext/opencv/curve.cpp +48 -33
  12. data/ext/opencv/curve.h +1 -1
  13. data/ext/opencv/cvavgcomp.cpp +22 -25
  14. data/ext/opencv/cvavgcomp.h +1 -1
  15. data/ext/opencv/cvbox2d.cpp +56 -58
  16. data/ext/opencv/cvbox2d.h +1 -1
  17. data/ext/opencv/cvcapture.cpp +210 -109
  18. data/ext/opencv/cvcapture.h +1 -1
  19. data/ext/opencv/cvchain.cpp +71 -71
  20. data/ext/opencv/cvchain.h +1 -1
  21. data/ext/opencv/cvcircle32f.cpp +37 -27
  22. data/ext/opencv/cvcircle32f.h +1 -1
  23. data/ext/opencv/cvconnectedcomp.cpp +49 -36
  24. data/ext/opencv/cvconnectedcomp.h +1 -1
  25. data/ext/opencv/cvcontour.cpp +117 -81
  26. data/ext/opencv/cvcontour.h +1 -1
  27. data/ext/opencv/cvcontourtree.cpp +37 -32
  28. data/ext/opencv/cvcontourtree.h +1 -1
  29. data/ext/opencv/cvconvexitydefect.cpp +33 -44
  30. data/ext/opencv/cvconvexitydefect.h +1 -1
  31. data/ext/opencv/cverror.cpp +22 -66
  32. data/ext/opencv/cverror.h +1 -1
  33. data/ext/opencv/cvfeaturetree.cpp +31 -33
  34. data/ext/opencv/cvfeaturetree.h +1 -1
  35. data/ext/opencv/cvfont.cpp +98 -78
  36. data/ext/opencv/cvfont.h +1 -1
  37. data/ext/opencv/cvhaarclassifiercascade.cpp +39 -59
  38. data/ext/opencv/cvhaarclassifiercascade.h +1 -1
  39. data/ext/opencv/cvhistogram.cpp +259 -90
  40. data/ext/opencv/cvhistogram.h +1 -1
  41. data/ext/opencv/cvhumoments.cpp +99 -60
  42. data/ext/opencv/cvhumoments.h +1 -1
  43. data/ext/opencv/cvline.cpp +45 -40
  44. data/ext/opencv/cvline.h +1 -1
  45. data/ext/opencv/cvmat.cpp +1894 -1829
  46. data/ext/opencv/cvmat.h +2 -3
  47. data/ext/opencv/cvmemstorage.cpp +19 -14
  48. data/ext/opencv/cvmemstorage.h +1 -1
  49. data/ext/opencv/cvmoments.cpp +51 -45
  50. data/ext/opencv/cvmoments.h +1 -1
  51. data/ext/opencv/cvpoint.cpp +32 -26
  52. data/ext/opencv/cvpoint.h +1 -1
  53. data/ext/opencv/cvpoint2d32f.cpp +31 -26
  54. data/ext/opencv/cvpoint2d32f.h +1 -1
  55. data/ext/opencv/cvpoint3d32f.cpp +36 -29
  56. data/ext/opencv/cvpoint3d32f.h +1 -1
  57. data/ext/opencv/cvrect.cpp +38 -33
  58. data/ext/opencv/cvrect.h +1 -1
  59. data/ext/opencv/cvscalar.cpp +50 -45
  60. data/ext/opencv/cvscalar.h +1 -1
  61. data/ext/opencv/cvseq.cpp +53 -47
  62. data/ext/opencv/cvseq.h +1 -1
  63. data/ext/opencv/cvsize.cpp +32 -26
  64. data/ext/opencv/cvsize.h +1 -1
  65. data/ext/opencv/cvsize2d32f.cpp +31 -25
  66. data/ext/opencv/cvsize2d32f.h +1 -1
  67. data/ext/opencv/cvslice.cpp +28 -22
  68. data/ext/opencv/cvslice.h +1 -1
  69. data/ext/opencv/cvsurfparams.cpp +37 -28
  70. data/ext/opencv/cvsurfparams.h +1 -1
  71. data/ext/opencv/cvsurfpoint.cpp +76 -53
  72. data/ext/opencv/cvsurfpoint.h +1 -1
  73. data/ext/opencv/cvtermcriteria.cpp +32 -26
  74. data/ext/opencv/cvtermcriteria.h +1 -1
  75. data/ext/opencv/cvtwopoints.cpp +28 -22
  76. data/ext/opencv/cvtwopoints.h +1 -1
  77. data/ext/opencv/cvvideowriter.cpp +25 -20
  78. data/ext/opencv/cvvideowriter.h +1 -1
  79. data/ext/opencv/eigenfaces.cpp +10 -2
  80. data/ext/opencv/eigenfaces.h +1 -1
  81. data/ext/opencv/facerecognizer.cpp +15 -8
  82. data/ext/opencv/facerecognizer.h +2 -2
  83. data/ext/opencv/fisherfaces.cpp +10 -2
  84. data/ext/opencv/fisherfaces.h +1 -1
  85. data/ext/opencv/gui.cpp +26 -23
  86. data/ext/opencv/gui.h +1 -1
  87. data/ext/opencv/iplconvkernel.cpp +30 -24
  88. data/ext/opencv/iplconvkernel.h +1 -1
  89. data/ext/opencv/iplimage.cpp +49 -42
  90. data/ext/opencv/iplimage.h +1 -1
  91. data/ext/opencv/lbph.cpp +10 -2
  92. data/ext/opencv/lbph.h +1 -1
  93. data/ext/opencv/mouseevent.cpp +30 -25
  94. data/ext/opencv/mouseevent.h +1 -1
  95. data/ext/opencv/opencv.cpp +59 -60
  96. data/ext/opencv/opencv.h +1 -5
  97. data/ext/opencv/pointset.cpp +31 -25
  98. data/ext/opencv/pointset.h +1 -1
  99. data/ext/opencv/trackbar.cpp +27 -21
  100. data/ext/opencv/trackbar.h +1 -1
  101. data/ext/opencv/window.cpp +77 -57
  102. data/ext/opencv/window.h +1 -1
  103. data/lib/opencv/version.rb +2 -1
  104. data/ruby-opencv.gemspec +19 -18
  105. data/test/test_opencv.rb +5 -3
  106. data/yard_extension.rb +5 -0
  107. metadata +13 -27
  108. data/examples/matching_to_many_images/matching_to_many_images.rb +0 -16
  109. data/examples/matching_to_many_images/query.png +0 -0
  110. data/examples/matching_to_many_images/train/1.png +0 -0
  111. data/examples/matching_to_many_images/train/2.png +0 -0
  112. data/examples/matching_to_many_images/train/3.png +0 -0
  113. data/examples/matching_to_many_images/train/trainImages.txt +0 -3
  114. data/ext/opencv/cvcondensation.cpp +0 -282
  115. data/ext/opencv/cvcondensation.h +0 -49
  116. data/ext/opencv/cvmatnd.cpp +0 -44
  117. data/ext/opencv/cvmatnd.h +0 -28
  118. data/ext/opencv/cvsparsemat.cpp +0 -44
  119. data/ext/opencv/cvsparsemat.h +0 -28
  120. data/images/face_detect_from_lena.jpg +0 -0
  121. data/test/test_cvmat_matching.rb +0 -57
@@ -9,14 +9,14 @@ include OpenCV
9
9
  class TestOpenCV < OpenCVTestCase
10
10
  def test_constants
11
11
  # OpenCV version
12
- assert_equal('2.4.7', CV_VERSION)
12
+ assert_equal('2.4.8', CV_VERSION)
13
13
  assert_equal(2, CV_MAJOR_VERSION)
14
14
  assert_equal(4, CV_MINOR_VERSION)
15
- assert_equal(7, CV_SUBMINOR_VERSION)
15
+ assert_equal(8, CV_SUBMINOR_VERSION)
16
16
 
17
17
  assert_equal(2, CV_VERSION_EPOCH)
18
18
  assert_equal(4, CV_VERSION_MAJOR)
19
- assert_equal(7, CV_VERSION_MINOR)
19
+ assert_equal(8, CV_VERSION_MINOR)
20
20
  assert_equal(0, CV_VERSION_REVISION)
21
21
 
22
22
  # Depths
@@ -149,7 +149,9 @@ class TestOpenCV < OpenCVTestCase
149
149
  assert_equal(4, CV_FM_LMEDS)
150
150
 
151
151
  # Flags of window
152
+ assert_equal(0, CV_WINDOW_NORMAL)
152
153
  assert_equal(1, CV_WINDOW_AUTOSIZE)
154
+ assert_equal(4096, CV_WINDOW_OPENGL)
153
155
 
154
156
  # Object detection mode
155
157
  assert_equal(1, CV_HAAR_DO_CANNY_PRUNING)
@@ -0,0 +1,5 @@
1
+ require 'yard'
2
+
3
+ YARD::Tags::Library.define_tag('OpenCV function', :opencv_func)
4
+ YARD::Tags::Library.visible_tags.place(:opencv_func).before(:abstract)
5
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-opencv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - lsxi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-08 00:00:00.000000000 Z
13
+ date: 2014-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdoc
@@ -30,28 +30,28 @@ dependencies:
30
30
  name: rake-compiler
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ">="
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ">="
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: hoe-gemspec
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">="
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '3.7'
63
+ version: '3.8'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '3.7'
70
+ version: '3.8'
71
71
  description: ruby-opencv is a wrapper of OpenCV for Ruby. It helps you to write computer
72
72
  vision programs (e.g. detecting faces from pictures) with Ruby.
73
73
  email:
@@ -84,9 +84,9 @@ extra_rdoc_files:
84
84
  - Manifest.txt
85
85
  - README.md
86
86
  - examples/facerec/readme.md
87
- - examples/matching_to_many_images/train/trainImages.txt
88
87
  files:
89
88
  - ".gitignore"
89
+ - ".yardopts"
90
90
  - DEVELOPERS_NOTE.md
91
91
  - Gemfile
92
92
  - History.txt
@@ -122,12 +122,6 @@ files:
122
122
  - examples/inpaint.rb
123
123
  - examples/match_kdtree.rb
124
124
  - examples/match_template.rb
125
- - examples/matching_to_many_images/matching_to_many_images.rb
126
- - examples/matching_to_many_images/query.png
127
- - examples/matching_to_many_images/train/1.png
128
- - examples/matching_to_many_images/train/2.png
129
- - examples/matching_to_many_images/train/3.png
130
- - examples/matching_to_many_images/train/trainImages.txt
131
125
  - examples/paint.rb
132
126
  - examples/snake.rb
133
127
  - ext/opencv/algorithm.cpp
@@ -144,8 +138,6 @@ files:
144
138
  - ext/opencv/cvchain.h
145
139
  - ext/opencv/cvcircle32f.cpp
146
140
  - ext/opencv/cvcircle32f.h
147
- - ext/opencv/cvcondensation.cpp
148
- - ext/opencv/cvcondensation.h
149
141
  - ext/opencv/cvconnectedcomp.cpp
150
142
  - ext/opencv/cvconnectedcomp.h
151
143
  - ext/opencv/cvcontour.cpp
@@ -170,8 +162,6 @@ files:
170
162
  - ext/opencv/cvline.h
171
163
  - ext/opencv/cvmat.cpp
172
164
  - ext/opencv/cvmat.h
173
- - ext/opencv/cvmatnd.cpp
174
- - ext/opencv/cvmatnd.h
175
165
  - ext/opencv/cvmemstorage.cpp
176
166
  - ext/opencv/cvmemstorage.h
177
167
  - ext/opencv/cvmoments.cpp
@@ -194,8 +184,6 @@ files:
194
184
  - ext/opencv/cvsize2d32f.h
195
185
  - ext/opencv/cvslice.cpp
196
186
  - ext/opencv/cvslice.h
197
- - ext/opencv/cvsparsemat.cpp
198
- - ext/opencv/cvsparsemat.h
199
187
  - ext/opencv/cvsurfparams.cpp
200
188
  - ext/opencv/cvsurfparams.h
201
189
  - ext/opencv/cvsurfpoint.cpp
@@ -236,7 +224,6 @@ files:
236
224
  - images/CvMat_sobel.png
237
225
  - images/CvMat_sub_rect.png
238
226
  - images/CvSeq_relationmap.png
239
- - images/face_detect_from_lena.jpg
240
227
  - lib/opencv.rb
241
228
  - lib/opencv/psyched_yaml.rb
242
229
  - lib/opencv/version.rb
@@ -310,7 +297,6 @@ files:
310
297
  - test/test_cvmat_drawing.rb
311
298
  - test/test_cvmat_dxt.rb
312
299
  - test/test_cvmat_imageprocessing.rb
313
- - test/test_cvmat_matching.rb
314
300
  - test/test_cvmoments.rb
315
301
  - test/test_cvpoint.rb
316
302
  - test/test_cvpoint2d32f.rb
@@ -337,6 +323,7 @@ files:
337
323
  - test/test_preliminary.rb
338
324
  - test/test_trackbar.rb
339
325
  - test/test_window.rb
326
+ - yard_extension.rb
340
327
  homepage: https://github.com/ruby-opencv/ruby-opencv/
341
328
  licenses:
342
329
  - The BSD License
@@ -354,12 +341,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
354
341
  version: '0'
355
342
  required_rubygems_version: !ruby/object:Gem::Requirement
356
343
  requirements:
357
- - - ">="
344
+ - - ">"
358
345
  - !ruby/object:Gem::Version
359
- version: '0'
346
+ version: 1.3.1
360
347
  requirements: []
361
348
  rubyforge_project: ruby-opencv
362
- rubygems_version: 2.1.11
349
+ rubygems_version: 2.2.1
363
350
  signing_key:
364
351
  specification_version: 4
365
352
  summary: OpenCV wrapper for Ruby
@@ -400,7 +387,6 @@ test_files:
400
387
  - test/test_cvchain.rb
401
388
  - test/test_cvmat.rb
402
389
  - test/test_fisherfaces.rb
403
- - test/test_cvmat_matching.rb
404
390
  - test/test_cverror.rb
405
391
  - test/test_cvpoint.rb
406
392
  - test/test_cvsize2d32f.rb
@@ -1,16 +0,0 @@
1
- require 'opencv'
2
- require 'benchmark'
3
- include OpenCV
4
-
5
- data = File.dirname(__FILE__)
6
-
7
- query = CvMat.load File.join(data, 'query.png'), CV_LOAD_IMAGE_GRAYSCALE
8
- image_files = ['1.png', '2.png', '3.png'].map{|f| File.join(data, 'train', f)}
9
- images = image_files.map{|f| CvMat.load f, CV_LOAD_IMAGE_GRAYSCALE}
10
-
11
-
12
- matchs = query.match_descriptors(images)
13
-
14
- match_index, count = matchs.max_by {|image_index, count| count}
15
-
16
- puts "max match: #{image_files[match_index]}"
@@ -1,3 +0,0 @@
1
- 1.png
2
- 2.png
3
- 3.png
@@ -1,282 +0,0 @@
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