ruby-opencv 0.0.8.pre-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +8 -0
  3. data/History.txt +5 -0
  4. data/License.txt +30 -0
  5. data/Manifest.txt +225 -0
  6. data/README.rdoc +149 -0
  7. data/Rakefile +32 -0
  8. data/examples/alpha_blend.rb +21 -0
  9. data/examples/box.png +0 -0
  10. data/examples/box_in_scene.png +0 -0
  11. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  12. data/examples/contours/bitmap-contours.png +0 -0
  13. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  14. data/examples/contours/contour_retrieval_modes.rb +139 -0
  15. data/examples/contours/rotated-boxes.jpg +0 -0
  16. data/examples/convexhull.rb +47 -0
  17. data/examples/face_detect.rb +20 -0
  18. data/examples/find_obj.rb +169 -0
  19. data/examples/houghcircle.rb +22 -0
  20. data/examples/inpaint.png +0 -0
  21. data/examples/inpaint.rb +57 -0
  22. data/examples/lenna-rotated.jpg +0 -0
  23. data/examples/lenna.jpg +0 -0
  24. data/examples/match_kdtree.rb +88 -0
  25. data/examples/matching_to_many_images.rb +16 -0
  26. data/examples/matching_to_many_images/query.png +0 -0
  27. data/examples/matching_to_many_images/train/1.png +0 -0
  28. data/examples/matching_to_many_images/train/2.png +0 -0
  29. data/examples/matching_to_many_images/train/3.png +0 -0
  30. data/examples/matching_to_many_images/train/trainImages.txt +3 -0
  31. data/examples/paint.rb +70 -0
  32. data/examples/snake.rb +43 -0
  33. data/examples/stuff.jpg +0 -0
  34. data/examples/tiffany.jpg +0 -0
  35. data/ext/opencv/curve.cpp +112 -0
  36. data/ext/opencv/curve.h +34 -0
  37. data/ext/opencv/cvavgcomp.cpp +67 -0
  38. data/ext/opencv/cvavgcomp.h +39 -0
  39. data/ext/opencv/cvbox2d.cpp +197 -0
  40. data/ext/opencv/cvbox2d.h +61 -0
  41. data/ext/opencv/cvcapture.cpp +499 -0
  42. data/ext/opencv/cvcapture.h +72 -0
  43. data/ext/opencv/cvchain.cpp +233 -0
  44. data/ext/opencv/cvchain.h +46 -0
  45. data/ext/opencv/cvcircle32f.cpp +116 -0
  46. data/ext/opencv/cvcircle32f.h +52 -0
  47. data/ext/opencv/cvcondensation.cpp +282 -0
  48. data/ext/opencv/cvcondensation.h +49 -0
  49. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  50. data/ext/opencv/cvconnectedcomp.h +49 -0
  51. data/ext/opencv/cvcontour.cpp +296 -0
  52. data/ext/opencv/cvcontour.h +48 -0
  53. data/ext/opencv/cvcontourtree.cpp +91 -0
  54. data/ext/opencv/cvcontourtree.h +41 -0
  55. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  56. data/ext/opencv/cvconvexitydefect.h +42 -0
  57. data/ext/opencv/cverror.cpp +159 -0
  58. data/ext/opencv/cverror.h +28 -0
  59. data/ext/opencv/cvfeaturetree.cpp +125 -0
  60. data/ext/opencv/cvfeaturetree.h +55 -0
  61. data/ext/opencv/cvfont.cpp +208 -0
  62. data/ext/opencv/cvfont.h +64 -0
  63. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  64. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  65. data/ext/opencv/cvhistogram.cpp +546 -0
  66. data/ext/opencv/cvhistogram.h +73 -0
  67. data/ext/opencv/cvhumoments.cpp +139 -0
  68. data/ext/opencv/cvhumoments.h +51 -0
  69. data/ext/opencv/cvline.cpp +154 -0
  70. data/ext/opencv/cvline.h +54 -0
  71. data/ext/opencv/cvmat.cpp +5848 -0
  72. data/ext/opencv/cvmat.h +284 -0
  73. data/ext/opencv/cvmatnd.cpp +44 -0
  74. data/ext/opencv/cvmatnd.h +28 -0
  75. data/ext/opencv/cvmemstorage.cpp +68 -0
  76. data/ext/opencv/cvmemstorage.h +53 -0
  77. data/ext/opencv/cvmoments.cpp +287 -0
  78. data/ext/opencv/cvmoments.h +75 -0
  79. data/ext/opencv/cvpoint.cpp +228 -0
  80. data/ext/opencv/cvpoint.h +64 -0
  81. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  82. data/ext/opencv/cvpoint2d32f.h +63 -0
  83. data/ext/opencv/cvpoint3d32f.cpp +245 -0
  84. data/ext/opencv/cvpoint3d32f.h +66 -0
  85. data/ext/opencv/cvrect.cpp +333 -0
  86. data/ext/opencv/cvrect.h +79 -0
  87. data/ext/opencv/cvscalar.cpp +236 -0
  88. data/ext/opencv/cvscalar.h +71 -0
  89. data/ext/opencv/cvseq.cpp +599 -0
  90. data/ext/opencv/cvseq.h +74 -0
  91. data/ext/opencv/cvsize.cpp +221 -0
  92. data/ext/opencv/cvsize.h +65 -0
  93. data/ext/opencv/cvsize2d32f.cpp +209 -0
  94. data/ext/opencv/cvsize2d32f.h +64 -0
  95. data/ext/opencv/cvslice.cpp +120 -0
  96. data/ext/opencv/cvslice.h +61 -0
  97. data/ext/opencv/cvsparsemat.cpp +44 -0
  98. data/ext/opencv/cvsparsemat.h +28 -0
  99. data/ext/opencv/cvsurfparams.cpp +199 -0
  100. data/ext/opencv/cvsurfparams.h +58 -0
  101. data/ext/opencv/cvsurfpoint.cpp +223 -0
  102. data/ext/opencv/cvsurfpoint.h +52 -0
  103. data/ext/opencv/cvtermcriteria.cpp +192 -0
  104. data/ext/opencv/cvtermcriteria.h +71 -0
  105. data/ext/opencv/cvtwopoints.cpp +116 -0
  106. data/ext/opencv/cvtwopoints.h +51 -0
  107. data/ext/opencv/cvutils.cpp +194 -0
  108. data/ext/opencv/cvutils.h +29 -0
  109. data/ext/opencv/cvvideowriter.cpp +137 -0
  110. data/ext/opencv/cvvideowriter.h +43 -0
  111. data/ext/opencv/gui.cpp +68 -0
  112. data/ext/opencv/gui.h +30 -0
  113. data/ext/opencv/iplconvkernel.cpp +192 -0
  114. data/ext/opencv/iplconvkernel.h +71 -0
  115. data/ext/opencv/iplimage.cpp +644 -0
  116. data/ext/opencv/iplimage.h +73 -0
  117. data/ext/opencv/lib/opencv.rb +3 -0
  118. data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
  119. data/ext/opencv/lib/opencv/version.rb +3 -0
  120. data/ext/opencv/mouseevent.cpp +181 -0
  121. data/ext/opencv/mouseevent.h +56 -0
  122. data/ext/opencv/opencv.cpp +722 -0
  123. data/ext/opencv/opencv.h +400 -0
  124. data/ext/opencv/pointset.cpp +274 -0
  125. data/ext/opencv/pointset.h +68 -0
  126. data/ext/opencv/trackbar.cpp +121 -0
  127. data/ext/opencv/trackbar.h +69 -0
  128. data/ext/opencv/window.cpp +357 -0
  129. data/ext/opencv/window.h +66 -0
  130. data/extconf.rb +75 -0
  131. data/images/CvMat_sobel.png +0 -0
  132. data/images/CvMat_sub_rect.png +0 -0
  133. data/images/CvSeq_relationmap.png +0 -0
  134. data/images/face_detect_from_lena.jpg +0 -0
  135. data/lib/opencv.rb +3 -0
  136. data/lib/opencv/psyched_yaml.rb +22 -0
  137. data/lib/opencv/version.rb +3 -0
  138. data/ruby-opencv.gemspec +43 -0
  139. data/test/helper.rb +166 -0
  140. data/test/runner.rb +30 -0
  141. data/test/samples/airplane.jpg +0 -0
  142. data/test/samples/baboon.jpg +0 -0
  143. data/test/samples/baboon200.jpg +0 -0
  144. data/test/samples/baboon200_rotated.jpg +0 -0
  145. data/test/samples/blank0.jpg +0 -0
  146. data/test/samples/blank1.jpg +0 -0
  147. data/test/samples/blank2.jpg +0 -0
  148. data/test/samples/blank3.jpg +0 -0
  149. data/test/samples/blank4.jpg +0 -0
  150. data/test/samples/blank5.jpg +0 -0
  151. data/test/samples/blank6.jpg +0 -0
  152. data/test/samples/blank7.jpg +0 -0
  153. data/test/samples/blank8.jpg +0 -0
  154. data/test/samples/blank9.jpg +0 -0
  155. data/test/samples/cat.jpg +0 -0
  156. data/test/samples/chessboard.jpg +0 -0
  157. data/test/samples/contours.jpg +0 -0
  158. data/test/samples/fruits.jpg +0 -0
  159. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  160. data/test/samples/inpaint-mask.bmp +0 -0
  161. data/test/samples/lena-256x256.jpg +0 -0
  162. data/test/samples/lena-32x32.jpg +0 -0
  163. data/test/samples/lena-eyes.jpg +0 -0
  164. data/test/samples/lena-inpaint.jpg +0 -0
  165. data/test/samples/lena.jpg +0 -0
  166. data/test/samples/lines.jpg +0 -0
  167. data/test/samples/messy0.jpg +0 -0
  168. data/test/samples/messy1.jpg +0 -0
  169. data/test/samples/movie_sample.avi +0 -0
  170. data/test/samples/one_way_train_0000.jpg +0 -0
  171. data/test/samples/one_way_train_0001.jpg +0 -0
  172. data/test/samples/partially_blank0.jpg +0 -0
  173. data/test/samples/partially_blank1.jpg +0 -0
  174. data/test/samples/smooth0.jpg +0 -0
  175. data/test/samples/smooth1.jpg +0 -0
  176. data/test/samples/smooth2.jpg +0 -0
  177. data/test/samples/smooth3.jpg +0 -0
  178. data/test/samples/smooth4.jpg +0 -0
  179. data/test/samples/smooth5.jpg +0 -0
  180. data/test/samples/smooth6.jpg +0 -0
  181. data/test/samples/str-cv-rotated.jpg +0 -0
  182. data/test/samples/str-cv.jpg +0 -0
  183. data/test/samples/str-ov.jpg +0 -0
  184. data/test/samples/stuff.jpg +0 -0
  185. data/test/test_curve.rb +43 -0
  186. data/test/test_cvavgcomp.rb +24 -0
  187. data/test/test_cvbox2d.rb +76 -0
  188. data/test/test_cvcapture.rb +183 -0
  189. data/test/test_cvchain.rb +108 -0
  190. data/test/test_cvcircle32f.rb +41 -0
  191. data/test/test_cvconnectedcomp.rb +61 -0
  192. data/test/test_cvcontour.rb +150 -0
  193. data/test/test_cvcontourtree.rb +43 -0
  194. data/test/test_cverror.rb +50 -0
  195. data/test/test_cvfeaturetree.rb +65 -0
  196. data/test/test_cvfont.rb +58 -0
  197. data/test/test_cvhaarclassifiercascade.rb +63 -0
  198. data/test/test_cvhistogram.rb +271 -0
  199. data/test/test_cvhumoments.rb +83 -0
  200. data/test/test_cvline.rb +50 -0
  201. data/test/test_cvmat.rb +2947 -0
  202. data/test/test_cvmat_drawing.rb +349 -0
  203. data/test/test_cvmat_dxt.rb +150 -0
  204. data/test/test_cvmat_imageprocessing.rb +2025 -0
  205. data/test/test_cvmat_matching.rb +57 -0
  206. data/test/test_cvmoments.rb +180 -0
  207. data/test/test_cvpoint.rb +75 -0
  208. data/test/test_cvpoint2d32f.rb +75 -0
  209. data/test/test_cvpoint3d32f.rb +93 -0
  210. data/test/test_cvrect.rb +144 -0
  211. data/test/test_cvscalar.rb +113 -0
  212. data/test/test_cvseq.rb +295 -0
  213. data/test/test_cvsize.rb +75 -0
  214. data/test/test_cvsize2d32f.rb +75 -0
  215. data/test/test_cvslice.rb +31 -0
  216. data/test/test_cvsurfparams.rb +57 -0
  217. data/test/test_cvsurfpoint.rb +66 -0
  218. data/test/test_cvtermcriteria.rb +56 -0
  219. data/test/test_cvtwopoints.rb +40 -0
  220. data/test/test_cvvideowriter.rb +58 -0
  221. data/test/test_iplconvkernel.rb +54 -0
  222. data/test/test_iplimage.rb +236 -0
  223. data/test/test_mouseevent.rb +17 -0
  224. data/test/test_opencv.rb +324 -0
  225. data/test/test_pointset.rb +126 -0
  226. data/test/test_preliminary.rb +130 -0
  227. data/test/test_trackbar.rb +47 -0
  228. data/test/test_window.rb +115 -0
  229. metadata +414 -0
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSize
10
+ class TestCvSize < OpenCVTestCase
11
+ class MySize; end
12
+
13
+ def test_width
14
+ size = CvSize.new
15
+ size.width = 100
16
+ assert_equal(100, size.width)
17
+ size.width = 200
18
+ assert_equal(200, size.width)
19
+ end
20
+
21
+ def test_height
22
+ size = CvSize.new
23
+ size.height = 100
24
+ assert_equal(100, size.height)
25
+ size.height = 200
26
+ assert_equal(200, size.height)
27
+ end
28
+
29
+ def test_compatible
30
+ assert(!(CvSize.compatible? MySize.new))
31
+ MySize.class_eval { def width; end }
32
+ assert(!(CvSize.compatible? MySize.new))
33
+ MySize.class_eval { def height; end }
34
+ assert(CvSize.compatible? MySize.new)
35
+ assert(CvSize.compatible? CvSize.new)
36
+ end
37
+
38
+ def test_initialize
39
+ size = CvSize.new
40
+ assert_equal(0, size.width)
41
+ assert_equal(0, size.height)
42
+
43
+ size = CvSize.new(10, 20)
44
+ assert_equal(10, size.width)
45
+ assert_equal(20, size.height)
46
+
47
+ size = CvSize.new(CvSize.new(10, 20))
48
+ assert_equal(10, size.width)
49
+ assert_equal(20, size.height)
50
+
51
+ assert_raise(TypeError) {
52
+ CvSize.new(DUMMY_OBJ)
53
+ }
54
+ assert_raise(ArgumentError) {
55
+ CvSize.new(1, 2, 3)
56
+ }
57
+ end
58
+
59
+ def test_to_s
60
+ size = CvSize.new(10, 20)
61
+ assert_equal('<OpenCV::CvSize:10x20>', size.to_s)
62
+ end
63
+
64
+ def test_to_ary
65
+ a = CvSize.new(10, 20).to_ary
66
+ assert_equal(10, a[0])
67
+ assert_equal(20, a[1])
68
+
69
+ # Alias
70
+ a = CvSize.new(10, 20).to_a
71
+ assert_equal(10, a[0])
72
+ assert_equal(20, a[1])
73
+ end
74
+ end
75
+
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSize2D32f
10
+ class TestCvSize2D32f < OpenCVTestCase
11
+ class MySize; end
12
+
13
+ def test_width
14
+ size = CvSize2D32f.new
15
+ size.width = 1.1
16
+ assert_in_delta(1.1, size.width, 0.001)
17
+ size.width = 2.2
18
+ assert_in_delta(2.2, size.width, 0.001)
19
+ end
20
+
21
+ def test_height
22
+ size = CvSize2D32f.new
23
+ size.height = 1.1
24
+ assert_in_delta(1.1, size.height, 0.001)
25
+ size.height = 2.2
26
+ assert_in_delta(2.2, size.height, 0.001)
27
+ end
28
+
29
+ def test_compatible
30
+ assert(!(CvSize2D32f.compatible? MySize.new))
31
+ MySize.class_eval { def width; end }
32
+ assert(!(CvSize2D32f.compatible? MySize.new))
33
+ MySize.class_eval { def height; end }
34
+ assert(CvSize2D32f.compatible? MySize.new)
35
+ assert(CvSize2D32f.compatible? CvSize2D32f.new)
36
+ end
37
+
38
+ def test_initialize
39
+ size = CvSize2D32f.new
40
+ assert_in_delta(0, size.width, 0.001)
41
+ assert_in_delta(0, size.height, 0.001)
42
+
43
+ size = CvSize2D32f.new(1.1, 2.2)
44
+ assert_in_delta(1.1, size.width, 0.001)
45
+ assert_in_delta(2.2, size.height, 0.001)
46
+
47
+ size = CvSize2D32f.new(CvSize2D32f.new(1.1, 2.2))
48
+ assert_in_delta(1.1, size.width, 0.001)
49
+ assert_in_delta(2.2, size.height, 0.001)
50
+
51
+ assert_raise(TypeError) {
52
+ CvSize2D32f.new(DUMMY_OBJ)
53
+ }
54
+ assert_raise(ArgumentError) {
55
+ CvSize2D32f.new(1, 2, 3)
56
+ }
57
+ end
58
+
59
+ def test_to_s
60
+ size = CvSize2D32f.new(1.1, 2.2)
61
+ assert_equal('<OpenCV::CvSize2D32f:1.1x2.2>', size.to_s)
62
+ end
63
+
64
+ def test_to_ary
65
+ a = CvSize2D32f.new(1.1, 2.2).to_ary
66
+ assert_in_delta(1.1, a[0], 0.001)
67
+ assert_in_delta(2.2, a[1], 0.001)
68
+
69
+ # Alias
70
+ a = CvSize2D32f.new(1.1, 2.2).to_a
71
+ assert_in_delta(1.1, a[0], 0.001)
72
+ assert_in_delta(2.2, a[1], 0.001)
73
+ end
74
+ end
75
+
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSlice
10
+ class TestCvSlice < OpenCVTestCase
11
+ def setup
12
+ @slice = CvSlice.new(2, 4)
13
+ end
14
+
15
+ def test_initialize
16
+ assert_equal(CvSlice, @slice.class)
17
+ end
18
+
19
+ def test_start_index
20
+ assert_equal(2, @slice.start_index)
21
+ @slice.start_index = 3
22
+ assert_equal(3, @slice.start_index)
23
+ end
24
+
25
+ def test_end_index
26
+ assert_equal(4, @slice.end_index)
27
+ @slice.end_index = 5
28
+ assert_equal(5, @slice.end_index)
29
+ end
30
+ end
31
+
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSURFParams
10
+ class TestCvSURFParams < OpenCVTestCase
11
+ def setup
12
+ @surf_param1 = CvSURFParams.new(345.6)
13
+ end
14
+
15
+ def test_initialize
16
+ sp1 = CvSURFParams.new(345.6)
17
+ assert_equal(false, sp1.extended)
18
+ assert_in_delta(345.6, sp1.hessian_threshold, 0.001)
19
+ assert_equal(3, sp1.n_octaves)
20
+ assert_equal(4, sp1.n_octave_layers)
21
+
22
+ sp2 = CvSURFParams.new(456.7, true, 4, 5)
23
+ assert_equal(true, sp2.extended)
24
+ assert_in_delta(456.7, sp2.hessian_threshold, 0.001)
25
+ assert_equal(4, sp2.n_octaves)
26
+ assert_equal(5, sp2.n_octave_layers)
27
+ end
28
+
29
+ def test_extended
30
+ assert_equal(false, @surf_param1.extended)
31
+
32
+ @surf_param1.extended = true
33
+ assert_equal(true, @surf_param1.extended)
34
+ end
35
+
36
+ def test_hessian_threshold
37
+ assert_in_delta(345.6, @surf_param1.hessian_threshold, 0.001)
38
+
39
+ @surf_param1.hessian_threshold = 456.7
40
+ assert_in_delta(456.7, @surf_param1.hessian_threshold, 0.001)
41
+ end
42
+
43
+ def test_n_octaves
44
+ assert_equal(3, @surf_param1.n_octaves)
45
+
46
+ @surf_param1.n_octaves = 4
47
+ assert_equal(4, @surf_param1.n_octaves)
48
+ end
49
+
50
+ def test_n_octave_layers
51
+ assert_equal(4, @surf_param1.n_octave_layers)
52
+
53
+ @surf_param1.n_octave_layers = 5
54
+ assert_equal(5, @surf_param1.n_octave_layers)
55
+ end
56
+ end
57
+
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSURFPoint
10
+ class TestCvSURFPoint < OpenCVTestCase
11
+ def setup
12
+ @surf_point1 = CvSURFPoint.new(CvPoint2D32f.new(0, 0), 0, 0, 0, 0)
13
+ end
14
+
15
+ def test_initialize
16
+ sp1 = CvSURFPoint.new(CvPoint2D32f.new(1.1, 2.2), 1, 10, 12.3, 45.6)
17
+ assert_in_delta(1.1, sp1.pt.x, 0.001)
18
+ assert_in_delta(2.2, sp1.pt.y, 0.001)
19
+ assert_equal(1, sp1.laplacian)
20
+ assert_equal(10, sp1.size)
21
+ assert_in_delta(12.3, sp1.dir, 0.001)
22
+ assert_in_delta(45.6, sp1.hessian, 0.001)
23
+ end
24
+
25
+ def test_pt
26
+ assert_in_delta(0, @surf_point1.pt.x, 0.001)
27
+ assert_in_delta(0, @surf_point1.pt.y, 0.001)
28
+
29
+ @surf_point1.pt = CvPoint2D32f.new(12.3, 45.6)
30
+ assert_in_delta(12.3, @surf_point1.pt.x, 0.001)
31
+ assert_in_delta(45.6, @surf_point1.pt.y, 0.001)
32
+
33
+ assert_raise(TypeError) {
34
+ @surf_point1.pt = DUMMY_OBJ
35
+ }
36
+ end
37
+
38
+ def test_laplacian
39
+ assert_equal(0, @surf_point1.laplacian)
40
+
41
+ @surf_point1.laplacian = -1
42
+ assert_equal(-1, @surf_point1.laplacian)
43
+ end
44
+
45
+ def test_size
46
+ assert_equal(0, @surf_point1.size)
47
+
48
+ @surf_point1.size = 10
49
+ assert_equal(10, @surf_point1.size)
50
+ end
51
+
52
+ def test_dir
53
+ assert_in_delta(0, @surf_point1.dir, 0.001)
54
+
55
+ @surf_point1.dir = 23.4
56
+ assert_in_delta(23.4, @surf_point1.dir, 0.001)
57
+ end
58
+
59
+ def test_hessian
60
+ assert_in_delta(0, @surf_point1.hessian, 0.001)
61
+
62
+ @surf_point1.hessian = 2.1
63
+ assert_in_delta(2.1, @surf_point1.hessian, 0.001)
64
+ end
65
+ end
66
+
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvTermCriteria
10
+ class TestCvTermCriteria < OpenCVTestCase
11
+ def setup
12
+ @criteria1 = CvTermCriteria.new
13
+ @criteria2 = CvTermCriteria.new(100)
14
+ @criteria3 = CvTermCriteria.new(nil, 0.01)
15
+ @criteria4 = CvTermCriteria.new(100, 0.01)
16
+ end
17
+
18
+ def test_initialize
19
+ assert_not_nil(@criteria1)
20
+ assert_equal(CvTermCriteria, @criteria1.class)
21
+ assert_not_nil(@criteria2)
22
+ assert_equal(CvTermCriteria, @criteria2.class)
23
+ assert_not_nil(@criteria3)
24
+ assert_equal(CvTermCriteria, @criteria3.class)
25
+ assert_not_nil(@criteria4)
26
+ assert_equal(CvTermCriteria, @criteria4.class)
27
+ end
28
+
29
+ def test_type
30
+ assert_equal(0, @criteria1.type)
31
+ assert_equal(CV_TERMCRIT_ITER, @criteria2.type)
32
+ assert_equal(CV_TERMCRIT_EPS, @criteria3.type)
33
+ assert_equal(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, @criteria4.type)
34
+ end
35
+
36
+ def test_max
37
+ assert_nil(@criteria1.max)
38
+ assert_equal(100, @criteria2.max)
39
+ assert_nil(@criteria3.max)
40
+ assert_equal(100, @criteria4.max)
41
+
42
+ @criteria1.max = 999
43
+ assert_equal(999, @criteria1.max)
44
+ end
45
+
46
+ def test_eps
47
+ assert_nil(@criteria1.eps)
48
+ assert_nil(@criteria2.eps)
49
+ assert_in_delta(0.01, @criteria3.eps, 0.001)
50
+ assert_in_delta(0.01, @criteria4.eps, 0.001)
51
+
52
+ @criteria1.eps = 3.14
53
+ assert_in_delta(3.14, @criteria1.eps, 0.001)
54
+ end
55
+ end
56
+
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvTwoPoints
10
+ class TestCvTwoPoints < OpenCVTestCase
11
+ def setup
12
+ @twopoints = CvTwoPoints.new
13
+ end
14
+
15
+ def test_initialize
16
+ assert_not_nil(@twopoints)
17
+ assert_equal(CvTwoPoints, @twopoints.class)
18
+ end
19
+
20
+ def test_point
21
+ assert_not_nil(@twopoints.point1)
22
+ assert_not_nil(@twopoints.point2)
23
+ assert_equal(CvPoint, @twopoints.point1.class)
24
+ assert_equal(CvPoint, @twopoints.point2.class)
25
+ end
26
+
27
+ def test_aref
28
+ assert_not_nil(@twopoints[0])
29
+ assert_not_nil(@twopoints[1])
30
+ assert_equal(CvPoint, @twopoints[0].class)
31
+ assert_equal(CvPoint, @twopoints[1].class)
32
+ end
33
+
34
+ def test_to_ary
35
+ assert_equal(Array, @twopoints.to_ary.class)
36
+ assert_equal(2, @twopoints.to_ary.size)
37
+ assert_equal(2, @twopoints.to_a.size)
38
+ end
39
+ end
40
+
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvVideoWriter
10
+ class TestCvVideoWriter < OpenCVTestCase
11
+ OUTPUT_FILENAME = 'videowriter_result.avi'
12
+
13
+ def test_initialize
14
+ vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240))
15
+ assert_equal(CvVideoWriter, vw.class)
16
+ vw.close
17
+
18
+ vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240), false)
19
+ assert_equal(CvVideoWriter, vw.class)
20
+ vw.close
21
+
22
+ ## Supported only Windows(?)
23
+ # vw = CvVideoWriter.new(OUTPUT_FILENAME, nil, 15, CvSize.new(320, 240), false)
24
+ # assert_equal(CvVideoWriter, vw.class)
25
+ # vw.close
26
+
27
+ CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240)) { |vw|
28
+ assert_equal(CvVideoWriter, vw.class)
29
+ }
30
+
31
+ assert_raise(TypeError) {
32
+ vw = CvVideoWriter.new(123, 'MJPG', 15, CvSize.new(320, 240), false)
33
+ }
34
+ end
35
+
36
+ def test_write
37
+ img = IplImage.load(FILENAME_LENA256x256)
38
+ vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256))
39
+ vw.write img
40
+ vw.close
41
+
42
+ CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256)) { |vw|
43
+ vw.write img
44
+ }
45
+
46
+ assert_raise(TypeError) {
47
+ CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256)) { |vw|
48
+ vw.write DUMMY_OBJ
49
+ }
50
+ }
51
+ end
52
+
53
+ def test_close
54
+ vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240))
55
+ vw.close
56
+ end
57
+ end
58
+