ruby-opencv 0.0.8-x86-mingw32 → 0.0.9.pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/DEVELOPERS_NOTE.md +29 -12
  3. data/Gemfile +1 -2
  4. data/License.txt +30 -30
  5. data/Manifest.txt +5 -4
  6. data/README.md +1 -1
  7. data/Rakefile +62 -4
  8. data/config.yml +7 -0
  9. data/examples/alpha_blend.rb +21 -21
  10. data/examples/find_obj.rb +169 -169
  11. data/examples/match_kdtree.rb +88 -88
  12. data/ext/opencv/cvcapture.cpp +19 -12
  13. data/ext/opencv/cvutils.cpp +192 -194
  14. data/ext/opencv/cvutils.h +30 -29
  15. data/{extconf.rb → ext/opencv/extconf.rb} +12 -4
  16. data/lib/opencv.rb +12 -3
  17. data/lib/opencv/psyched_yaml.rb +22 -22
  18. data/lib/opencv/version.rb +1 -1
  19. data/ruby-opencv.gemspec +17 -16
  20. data/test/helper.rb +1 -1
  21. data/test/runner.rb +30 -30
  22. data/test/test_curve.rb +1 -1
  23. data/test/test_cvavgcomp.rb +24 -24
  24. data/test/test_cvbox2d.rb +76 -76
  25. data/test/test_cvcapture.rb +183 -183
  26. data/test/test_cvchain.rb +108 -108
  27. data/test/test_cvcircle32f.rb +41 -41
  28. data/test/test_cvconnectedcomp.rb +61 -61
  29. data/test/test_cvcontour.rb +150 -150
  30. data/test/test_cvcontourtree.rb +43 -43
  31. data/test/test_cverror.rb +1 -1
  32. data/test/test_cvfeaturetree.rb +65 -65
  33. data/test/test_cvfont.rb +58 -58
  34. data/test/test_cvhaarclassifiercascade.rb +63 -63
  35. data/test/test_cvhistogram.rb +1 -1
  36. data/test/test_cvhumoments.rb +83 -83
  37. data/test/test_cvline.rb +50 -50
  38. data/test/test_cvmat.rb +1 -1
  39. data/test/test_cvmat_drawing.rb +1 -1
  40. data/test/test_cvmat_dxt.rb +1 -1
  41. data/test/test_cvmat_imageprocessing.rb +1 -1
  42. data/test/test_cvmat_matching.rb +1 -1
  43. data/test/test_cvmoments.rb +180 -180
  44. data/test/test_cvpoint.rb +75 -75
  45. data/test/test_cvpoint2d32f.rb +75 -75
  46. data/test/test_cvpoint3d32f.rb +93 -93
  47. data/test/test_cvrect.rb +144 -144
  48. data/test/test_cvscalar.rb +113 -113
  49. data/test/test_cvseq.rb +295 -295
  50. data/test/test_cvsize.rb +75 -75
  51. data/test/test_cvsize2d32f.rb +75 -75
  52. data/test/test_cvslice.rb +31 -31
  53. data/test/test_cvsurfparams.rb +57 -57
  54. data/test/test_cvsurfpoint.rb +66 -66
  55. data/test/test_cvtermcriteria.rb +56 -56
  56. data/test/test_cvtwopoints.rb +40 -40
  57. data/test/test_cvvideowriter.rb +58 -58
  58. data/test/test_iplconvkernel.rb +54 -54
  59. data/test/test_iplimage.rb +1 -1
  60. data/test/test_mouseevent.rb +17 -17
  61. data/test/test_opencv.rb +1 -1
  62. data/test/test_pointset.rb +1 -1
  63. data/test/test_preliminary.rb +130 -130
  64. data/test/test_trackbar.rb +47 -47
  65. data/test/test_window.rb +115 -115
  66. metadata +26 -54
  67. data/ext/opencv/lib/opencv.rb +0 -3
  68. data/ext/opencv/lib/opencv/psyched_yaml.rb +0 -22
  69. data/ext/opencv/lib/opencv/version.rb +0 -3
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8-unix -*-
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
3
  require 'test/unit'
4
4
  require 'opencv'
5
5
  require File.expand_path(File.dirname(__FILE__)) + '/helper'
@@ -1,17 +1,17 @@
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
- include GUI
9
-
10
- # Tests for OpenCV::MouseEvent
11
- class TestMouseEvent < OpenCVTestCase
12
- def test_initialize
13
- assert_not_nil(MouseEvent.new)
14
- assert_equal(MouseEvent, MouseEvent.new.class)
15
- end
16
- end
17
-
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+ include GUI
9
+
10
+ # Tests for OpenCV::MouseEvent
11
+ class TestMouseEvent < OpenCVTestCase
12
+ def test_initialize
13
+ assert_not_nil(MouseEvent.new)
14
+ assert_equal(MouseEvent, MouseEvent.new.class)
15
+ end
16
+ end
17
+
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8-unix -*-
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
3
  require 'test/unit'
4
4
  require 'opencv'
5
5
  require File.expand_path(File.dirname(__FILE__)) + '/helper'
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8-unix -*-
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
3
  require 'test/unit'
4
4
  require 'opencv'
5
5
  require File.expand_path(File.dirname(__FILE__)) + '/helper'
@@ -1,130 +1,130 @@
1
- #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8-unix -*-
3
- require 'test/unit'
4
- require 'digest/md5'
5
- require 'opencv'
6
- require File.expand_path(File.dirname(__FILE__)) + '/helper'
7
-
8
- include OpenCV
9
-
10
- # Tests to run first; check the handful of basic operations that the later tests rely on
11
- class TestPreliminary < OpenCVTestCase
12
- def test_assert_array_equal
13
- assert_array_equal([1, 2, 3, 4], [1, 2, 3, 4])
14
-
15
- # Uncomment the following line to check the fail case
16
- # assert_array_equal([1, 2, 3, 4], [1, 2, 3, 0])
17
- end
18
-
19
- def test_assert_cvscalar_equal
20
- assert_cvscalar_equal(CvScalar.new(1, 2, 3, 4), CvScalar.new(1, 2, 3, 4))
21
- assert_cvscalar_equal(CvScalar.new(0.1, 0.2, 0.3, 0.4), CvScalar.new(0.1, 0.2, 0.3, 0.4))
22
-
23
- # Uncomment the following lines to check the fail cases
24
- # assert_cvscalar_equal(CvScalar.new(1, 2, 3, 4), CvScalar.new(1, 2, 3, 0))
25
- # assert_cvscalar_equal(CvScalar.new(0.1, 0.2, 0.3, 0.4), CvScalar.new(0.1, 0.2, 0.3, 0.0))
26
- end
27
-
28
- def test_assert_in_delta
29
- assert_in_delta(1, 0.9999, 0.1)
30
- assert_in_delta(CvScalar.new(1, 2, 3, 4), CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.1)
31
- assert_in_delta(CvScalar.new(1, 2, 3, 4), [1.01, 2.01, 3.01, 4.01], 0.1)
32
- assert_in_delta([1, 2, 3, 4], CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.1)
33
- assert_in_delta([1, 2, 3, 4], [1.01, 2.01, 3.01, 4.01], 0.1)
34
-
35
- # Uncomment the following lines to check the fail cases
36
- # assert_in_delta(1, 0.009, 0.1)
37
- # assert_in_delta(CvScalar.new(1, 2, 3, 4), CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.001)
38
- # assert_in_delta(CvScalar.new(1, 2, 3, 4), [1.01, 2.01, 3.01, 4.01], 0.001)
39
- # assert_in_delta([1, 2, 3, 4], CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.001)
40
- # assert_in_delta([1, 2, 3, 4], [1.01, 2.01, 3.01, 4.01], 0.001)
41
- end
42
-
43
- def test_assert_each_cvscalar
44
- mat1 = CvMat.new(5, 5, :cv32f, 4)
45
- mat2 = CvMat.new(5, 5, :cv32f, 4)
46
- c = 0
47
- mat1.height.times { |j|
48
- mat1.width.times { |i|
49
- mat1[j, i] = CvScalar.new(c * 0.1, c * 0.2, c * 0.3, c * 0.4)
50
- mat2[j, i] = CvScalar.new(c, c, c, c)
51
- c += 1
52
- }
53
- }
54
-
55
- assert_each_cvscalar(mat1, 0.001) { |j, i, n|
56
- CvScalar.new(n * 0.1, n * 0.2, n * 0.3, n * 0.4)
57
- }
58
- assert_each_cvscalar(mat2) { |j, i, n|
59
- CvScalar.new(n, n, n, n)
60
- }
61
-
62
- # Uncomment the following lines to check the fail cases
63
- # assert_each_cvscalar(mat1, 0.001) { |j, i, n|
64
- # CvScalar.new(n * 0.1, n * 0.2, n * 0.3, 0)
65
- # }
66
- # assert_each_cvscalar(mat1, 0.001) { |j, i, n|
67
- # CvScalar.new(1, 2, 3, 4)
68
- # }
69
- # assert_each_cvscalar(mat2) { |j, i, n|
70
- # CvScalar.new(n * 0.1, n * 0.2, n * 0.3, 0)
71
- # }
72
- # assert_each_cvscalar(mat2) { |j, i, n|
73
- # CvScalar.new(1, 2, 3, 0)
74
- # }
75
- end
76
-
77
-
78
- def test_create_cvmat
79
- mat = create_cvmat(3, 4)
80
- assert_equal(3, mat.height)
81
- assert_equal(4, mat.width)
82
- assert_equal(:cv8u, mat.depth)
83
- assert_equal(4, mat.channel)
84
- c = 0
85
- mat.height.times { |j|
86
- mat.width.times { |i|
87
- s = CvScalar.new(c + 1, c + 1, c + 1, c + 1)
88
- assert_cvscalar_equal(s, mat[j, i])
89
- c += 1
90
- }
91
- }
92
-
93
- mat = create_cvmat(2, 3, :cv16s, 2)
94
- assert_equal(2, mat.height)
95
- assert_equal(3, mat.width)
96
- assert_equal(:cv16s, mat.depth)
97
- assert_equal(2, mat.channel)
98
- c = 0
99
- mat.height.times { |j|
100
- mat.width.times { |i|
101
- s = CvScalar.new(c + 1, c + 1, 0, 0)
102
- assert_cvscalar_equal(s, mat[j, i])
103
- c += 1
104
- }
105
- }
106
-
107
- mat = create_cvmat(2, 3, :cv16u, 3) { |j, i, cnt|
108
- n = j + i + cnt
109
- CvScalar.new(n, n, n, 0)
110
- }
111
- assert_equal(2, mat.height)
112
- assert_equal(3, mat.width)
113
- assert_equal(:cv16u, mat.depth)
114
- assert_equal(3, mat.channel)
115
- c = 0
116
- mat.height.times { |j|
117
- mat.width.times { |i|
118
- n = j + i + c
119
- assert_cvscalar_equal(CvScalar.new(n, n, n, 0), mat[j, i])
120
- c += 1
121
- }
122
- }
123
- end
124
-
125
- def test_types
126
- assert_equal(IplImage.new(7, 5, CV_8U, 1).class, IplImage)
127
- assert_equal(CvMat.new(5, 7, CV_32F).class, CvMat)
128
- end
129
- end
130
-
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
+ require 'test/unit'
4
+ require 'digest/md5'
5
+ require 'opencv'
6
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
7
+
8
+ include OpenCV
9
+
10
+ # Tests to run first; check the handful of basic operations that the later tests rely on
11
+ class TestPreliminary < OpenCVTestCase
12
+ def test_assert_array_equal
13
+ assert_array_equal([1, 2, 3, 4], [1, 2, 3, 4])
14
+
15
+ # Uncomment the following line to check the fail case
16
+ # assert_array_equal([1, 2, 3, 4], [1, 2, 3, 0])
17
+ end
18
+
19
+ def test_assert_cvscalar_equal
20
+ assert_cvscalar_equal(CvScalar.new(1, 2, 3, 4), CvScalar.new(1, 2, 3, 4))
21
+ assert_cvscalar_equal(CvScalar.new(0.1, 0.2, 0.3, 0.4), CvScalar.new(0.1, 0.2, 0.3, 0.4))
22
+
23
+ # Uncomment the following lines to check the fail cases
24
+ # assert_cvscalar_equal(CvScalar.new(1, 2, 3, 4), CvScalar.new(1, 2, 3, 0))
25
+ # assert_cvscalar_equal(CvScalar.new(0.1, 0.2, 0.3, 0.4), CvScalar.new(0.1, 0.2, 0.3, 0.0))
26
+ end
27
+
28
+ def test_assert_in_delta
29
+ assert_in_delta(1, 0.9999, 0.1)
30
+ assert_in_delta(CvScalar.new(1, 2, 3, 4), CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.1)
31
+ assert_in_delta(CvScalar.new(1, 2, 3, 4), [1.01, 2.01, 3.01, 4.01], 0.1)
32
+ assert_in_delta([1, 2, 3, 4], CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.1)
33
+ assert_in_delta([1, 2, 3, 4], [1.01, 2.01, 3.01, 4.01], 0.1)
34
+
35
+ # Uncomment the following lines to check the fail cases
36
+ # assert_in_delta(1, 0.009, 0.1)
37
+ # assert_in_delta(CvScalar.new(1, 2, 3, 4), CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.001)
38
+ # assert_in_delta(CvScalar.new(1, 2, 3, 4), [1.01, 2.01, 3.01, 4.01], 0.001)
39
+ # assert_in_delta([1, 2, 3, 4], CvScalar.new(1.01, 2.01, 3.01, 4.01), 0.001)
40
+ # assert_in_delta([1, 2, 3, 4], [1.01, 2.01, 3.01, 4.01], 0.001)
41
+ end
42
+
43
+ def test_assert_each_cvscalar
44
+ mat1 = CvMat.new(5, 5, :cv32f, 4)
45
+ mat2 = CvMat.new(5, 5, :cv32f, 4)
46
+ c = 0
47
+ mat1.height.times { |j|
48
+ mat1.width.times { |i|
49
+ mat1[j, i] = CvScalar.new(c * 0.1, c * 0.2, c * 0.3, c * 0.4)
50
+ mat2[j, i] = CvScalar.new(c, c, c, c)
51
+ c += 1
52
+ }
53
+ }
54
+
55
+ assert_each_cvscalar(mat1, 0.001) { |j, i, n|
56
+ CvScalar.new(n * 0.1, n * 0.2, n * 0.3, n * 0.4)
57
+ }
58
+ assert_each_cvscalar(mat2) { |j, i, n|
59
+ CvScalar.new(n, n, n, n)
60
+ }
61
+
62
+ # Uncomment the following lines to check the fail cases
63
+ # assert_each_cvscalar(mat1, 0.001) { |j, i, n|
64
+ # CvScalar.new(n * 0.1, n * 0.2, n * 0.3, 0)
65
+ # }
66
+ # assert_each_cvscalar(mat1, 0.001) { |j, i, n|
67
+ # CvScalar.new(1, 2, 3, 4)
68
+ # }
69
+ # assert_each_cvscalar(mat2) { |j, i, n|
70
+ # CvScalar.new(n * 0.1, n * 0.2, n * 0.3, 0)
71
+ # }
72
+ # assert_each_cvscalar(mat2) { |j, i, n|
73
+ # CvScalar.new(1, 2, 3, 0)
74
+ # }
75
+ end
76
+
77
+
78
+ def test_create_cvmat
79
+ mat = create_cvmat(3, 4)
80
+ assert_equal(3, mat.height)
81
+ assert_equal(4, mat.width)
82
+ assert_equal(:cv8u, mat.depth)
83
+ assert_equal(4, mat.channel)
84
+ c = 0
85
+ mat.height.times { |j|
86
+ mat.width.times { |i|
87
+ s = CvScalar.new(c + 1, c + 1, c + 1, c + 1)
88
+ assert_cvscalar_equal(s, mat[j, i])
89
+ c += 1
90
+ }
91
+ }
92
+
93
+ mat = create_cvmat(2, 3, :cv16s, 2)
94
+ assert_equal(2, mat.height)
95
+ assert_equal(3, mat.width)
96
+ assert_equal(:cv16s, mat.depth)
97
+ assert_equal(2, mat.channel)
98
+ c = 0
99
+ mat.height.times { |j|
100
+ mat.width.times { |i|
101
+ s = CvScalar.new(c + 1, c + 1, 0, 0)
102
+ assert_cvscalar_equal(s, mat[j, i])
103
+ c += 1
104
+ }
105
+ }
106
+
107
+ mat = create_cvmat(2, 3, :cv16u, 3) { |j, i, cnt|
108
+ n = j + i + cnt
109
+ CvScalar.new(n, n, n, 0)
110
+ }
111
+ assert_equal(2, mat.height)
112
+ assert_equal(3, mat.width)
113
+ assert_equal(:cv16u, mat.depth)
114
+ assert_equal(3, mat.channel)
115
+ c = 0
116
+ mat.height.times { |j|
117
+ mat.width.times { |i|
118
+ n = j + i + c
119
+ assert_cvscalar_equal(CvScalar.new(n, n, n, 0), mat[j, i])
120
+ c += 1
121
+ }
122
+ }
123
+ end
124
+
125
+ def test_types
126
+ assert_equal(IplImage.new(7, 5, CV_8U, 1).class, IplImage)
127
+ assert_equal(CvMat.new(5, 7, CV_32F).class, CvMat)
128
+ end
129
+ end
130
+
@@ -1,47 +1,47 @@
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
- include GUI
9
-
10
- # Tests for OpenCV::Trackbar
11
- class TestTrackbar < OpenCVTestCase
12
- def setup
13
- @trackbar1 = Trackbar.new('trackbar1', 100) {}
14
- @trackbar2 = Trackbar.new('trackbar1', 100, 1) {}
15
- end
16
-
17
- def test_initialize
18
- assert_not_nil(Trackbar.new('trackbar', 100, 1) {})
19
- assert_not_nil(Trackbar.new('trackbar', 100) {})
20
- block = proc {}
21
- assert_not_nil(Trackbar.new('trackbar', 100, 1, &block))
22
- assert_not_nil(Trackbar.new('trackbar', 100, &block))
23
-
24
- assert_raise(TypeError) {
25
- Trackbar.new(123, 100, 1) {}
26
- }
27
- assert_raise(ArgumentError) {
28
- Trackbar.new('trackbar', 100, 1)
29
- }
30
- end
31
-
32
- def test_name
33
- assert_equal('trackbar1', @trackbar1.name)
34
- end
35
-
36
- def test_max
37
- assert_equal(100, @trackbar1.max)
38
- end
39
-
40
- def test_value
41
- assert_equal(0, @trackbar1.value)
42
- assert_equal(1, @trackbar2.value)
43
- @trackbar1.value = 50
44
- assert_equal(50, @trackbar1.value)
45
- end
46
- end
47
-
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+ include GUI
9
+
10
+ # Tests for OpenCV::Trackbar
11
+ class TestTrackbar < OpenCVTestCase
12
+ def setup
13
+ @trackbar1 = Trackbar.new('trackbar1', 100) {}
14
+ @trackbar2 = Trackbar.new('trackbar1', 100, 1) {}
15
+ end
16
+
17
+ def test_initialize
18
+ assert_not_nil(Trackbar.new('trackbar', 100, 1) {})
19
+ assert_not_nil(Trackbar.new('trackbar', 100) {})
20
+ block = proc {}
21
+ assert_not_nil(Trackbar.new('trackbar', 100, 1, &block))
22
+ assert_not_nil(Trackbar.new('trackbar', 100, &block))
23
+
24
+ assert_raise(TypeError) {
25
+ Trackbar.new(123, 100, 1) {}
26
+ }
27
+ assert_raise(ArgumentError) {
28
+ Trackbar.new('trackbar', 100, 1)
29
+ }
30
+ end
31
+
32
+ def test_name
33
+ assert_equal('trackbar1', @trackbar1.name)
34
+ end
35
+
36
+ def test_max
37
+ assert_equal(100, @trackbar1.max)
38
+ end
39
+
40
+ def test_value
41
+ assert_equal(0, @trackbar1.value)
42
+ assert_equal(1, @trackbar2.value)
43
+ @trackbar1.value = 50
44
+ assert_equal(50, @trackbar1.value)
45
+ end
46
+ end
47
+
@@ -1,115 +1,115 @@
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
- include GUI
9
-
10
- # Tests for OpenCV::Window
11
- class TestWindow < OpenCVTestCase
12
- def setup
13
- @window1 = Window.new('window1')
14
- @window2 = Window.new('window2', CV_WINDOW_AUTOSIZE)
15
- @window3 = Window.new('window3', 0)
16
- end
17
-
18
- def teardown
19
- Window::destroy_all
20
- end
21
-
22
- def test_initialize
23
- [Window.new('w1'), Window.new('w2', CV_WINDOW_AUTOSIZE), Window.new('w3', 0)].each { |w|
24
- assert_not_nil(w)
25
- assert_equal(Window, w.class)
26
- }
27
-
28
- assert_raise(TypeError) {
29
- Window.new('w4', 'foobar')
30
- }
31
-
32
- assert_raise(StandardError) {
33
- Window.new('w5')
34
- Window.new('w5')
35
- }
36
- end
37
-
38
- def test_alive
39
- assert(@window1.alive?)
40
- @window1.destroy
41
- assert(!(@window1.alive?))
42
- end
43
-
44
- def test_destroy
45
- @window1.destroy
46
- assert(!(@window1.alive?))
47
- end
48
-
49
- def test_destroy_all
50
- Window::destroy_all
51
- assert(!(@window1.alive?))
52
- assert(!(@window2.alive?))
53
- assert(!(@window3.alive?))
54
- end
55
-
56
- def test_resize
57
- @window1.resize(CvSize.new(10, 20))
58
- @window2.resize(100, 200)
59
- assert_raise(ArgumentError) {
60
- @window3.resize
61
- }
62
-
63
- # Uncomment the following lines to show the results
64
- # @window1.show(CvMat.new(10, 20))
65
- # @window1.resize(100, 200)
66
- # GUI::wait_key
67
- end
68
-
69
- def test_move
70
- @window1.move(CvPoint.new(10, 20))
71
- @window2.move(100, 200)
72
- assert_raise(ArgumentError) {
73
- @window3.move
74
- }
75
-
76
- # Uncomment the following lines to show the results
77
- # @window1.show(CvMat.new(10, 20))
78
- # @window2.show(CvMat.new(100, 200))
79
- # GUI::wait_key
80
- end
81
-
82
- def test_show_image
83
- img = IplImage.load(FILENAME_CAT, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR)
84
- @window1.show_image(img)
85
- @window2.show(img) # Alias
86
-
87
- # Uncomment the following lines to show the results
88
- # GUI::wait_key
89
- end
90
-
91
- def test_set_trackbar
92
- tr1 = @window1.set_trackbar('trackbar1', 100) { |value|
93
- puts value
94
- }
95
- assert_equal(Trackbar, tr1.class)
96
-
97
- trackbar2 = Trackbar.new('trackbar2', 10, 1) {}
98
- tr2 = @window2.set_trackbar(trackbar2)
99
- assert_equal(Trackbar, tr2.class)
100
- end
101
-
102
- def test_set_mouseevent
103
- @window1.set_mouse_callback { |mouse|
104
- e = "#{mouse.x}, #{mouse.y} : #{mouse.event} : "
105
- e << "<L>" if mouse.left_button?
106
- e << "<R>" if mouse.right_button?
107
- e << "<M>" if mouse.middle_button?
108
- e << "[CTRL]" if mouse.ctrl_key?
109
- e << "[SHIFT]" if mouse.shift_key?
110
- e << "[ALT]" if mouse.alt_key?
111
- puts e
112
- }
113
- end
114
- end
115
-
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+ include GUI
9
+
10
+ # Tests for OpenCV::Window
11
+ class TestWindow < OpenCVTestCase
12
+ def setup
13
+ @window1 = Window.new('window1')
14
+ @window2 = Window.new('window2', CV_WINDOW_AUTOSIZE)
15
+ @window3 = Window.new('window3', 0)
16
+ end
17
+
18
+ def teardown
19
+ Window::destroy_all
20
+ end
21
+
22
+ def test_initialize
23
+ [Window.new('w1'), Window.new('w2', CV_WINDOW_AUTOSIZE), Window.new('w3', 0)].each { |w|
24
+ assert_not_nil(w)
25
+ assert_equal(Window, w.class)
26
+ }
27
+
28
+ assert_raise(TypeError) {
29
+ Window.new('w4', 'foobar')
30
+ }
31
+
32
+ assert_raise(StandardError) {
33
+ Window.new('w5')
34
+ Window.new('w5')
35
+ }
36
+ end
37
+
38
+ def test_alive
39
+ assert(@window1.alive?)
40
+ @window1.destroy
41
+ assert(!(@window1.alive?))
42
+ end
43
+
44
+ def test_destroy
45
+ @window1.destroy
46
+ assert(!(@window1.alive?))
47
+ end
48
+
49
+ def test_destroy_all
50
+ Window::destroy_all
51
+ assert(!(@window1.alive?))
52
+ assert(!(@window2.alive?))
53
+ assert(!(@window3.alive?))
54
+ end
55
+
56
+ def test_resize
57
+ @window1.resize(CvSize.new(10, 20))
58
+ @window2.resize(100, 200)
59
+ assert_raise(ArgumentError) {
60
+ @window3.resize
61
+ }
62
+
63
+ # Uncomment the following lines to show the results
64
+ # @window1.show(CvMat.new(10, 20))
65
+ # @window1.resize(100, 200)
66
+ # GUI::wait_key
67
+ end
68
+
69
+ def test_move
70
+ @window1.move(CvPoint.new(10, 20))
71
+ @window2.move(100, 200)
72
+ assert_raise(ArgumentError) {
73
+ @window3.move
74
+ }
75
+
76
+ # Uncomment the following lines to show the results
77
+ # @window1.show(CvMat.new(10, 20))
78
+ # @window2.show(CvMat.new(100, 200))
79
+ # GUI::wait_key
80
+ end
81
+
82
+ def test_show_image
83
+ img = IplImage.load(FILENAME_CAT, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR)
84
+ @window1.show_image(img)
85
+ @window2.show(img) # Alias
86
+
87
+ # Uncomment the following lines to show the results
88
+ # GUI::wait_key
89
+ end
90
+
91
+ def test_set_trackbar
92
+ tr1 = @window1.set_trackbar('trackbar1', 100) { |value|
93
+ puts value
94
+ }
95
+ assert_equal(Trackbar, tr1.class)
96
+
97
+ trackbar2 = Trackbar.new('trackbar2', 10, 1) {}
98
+ tr2 = @window2.set_trackbar(trackbar2)
99
+ assert_equal(Trackbar, tr2.class)
100
+ end
101
+
102
+ def test_set_mouseevent
103
+ @window1.set_mouse_callback { |mouse|
104
+ e = "#{mouse.x}, #{mouse.y} : #{mouse.event} : "
105
+ e << "<L>" if mouse.left_button?
106
+ e << "<R>" if mouse.right_button?
107
+ e << "<M>" if mouse.middle_button?
108
+ e << "[CTRL]" if mouse.ctrl_key?
109
+ e << "[SHIFT]" if mouse.shift_key?
110
+ e << "[ALT]" if mouse.alt_key?
111
+ puts e
112
+ }
113
+ end
114
+ end
115
+