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,43 +1,43 @@
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::CvContourTree
10
- class TestCvContourTree < OpenCVTestCase
11
- def setup
12
- @tree = CvContourTree.new(CvPoint)
13
- end
14
-
15
- def test_initialize
16
- tree = CvContourTree.new(CvPoint)
17
- assert_equal(CvContourTree, tree.class)
18
- assert(tree.is_a? CvSeq)
19
- end
20
-
21
- def test_p1
22
- assert_equal(CvPoint, @tree.p1.class)
23
- end
24
-
25
- def test_p2
26
- assert_equal(CvPoint, @tree.p2.class)
27
- end
28
-
29
- def test_contour
30
- mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
31
- (j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
32
- }
33
- contour = mat0.find_contours
34
- tree = contour.create_tree
35
- contour = tree.contour(CvTermCriteria.new(100, 0.01))
36
- assert_equal(CvContour, contour.class)
37
-
38
- assert_raise(CvStsBadArg) {
39
- tree.contour(CvTermCriteria.new(0, 0))
40
- }
41
- end
42
- end
43
-
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
+
9
+ # Tests for OpenCV::CvContourTree
10
+ class TestCvContourTree < OpenCVTestCase
11
+ def setup
12
+ @tree = CvContourTree.new(CvPoint)
13
+ end
14
+
15
+ def test_initialize
16
+ tree = CvContourTree.new(CvPoint)
17
+ assert_equal(CvContourTree, tree.class)
18
+ assert(tree.is_a? CvSeq)
19
+ end
20
+
21
+ def test_p1
22
+ assert_equal(CvPoint, @tree.p1.class)
23
+ end
24
+
25
+ def test_p2
26
+ assert_equal(CvPoint, @tree.p2.class)
27
+ end
28
+
29
+ def test_contour
30
+ mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
31
+ (j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
32
+ }
33
+ contour = mat0.find_contours
34
+ tree = contour.create_tree
35
+ contour = tree.contour(CvTermCriteria.new(100, 0.01))
36
+ assert_equal(CvContour, contour.class)
37
+
38
+ assert_raise(CvStsBadArg) {
39
+ tree.contour(CvTermCriteria.new(0, 0))
40
+ }
41
+ end
42
+ end
43
+
@@ -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,65 +1,65 @@
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::CvFeatureTree
10
- class TestCvFeatureTree < OpenCVTestCase
11
- def test_initialize
12
- desc = CvMat.new(1, 1, :cv32f, 1)
13
- ft = CvFeatureTree.new(desc)
14
- assert_equal(CvFeatureTree, ft.class)
15
-
16
- assert_raise(TypeError) {
17
- CvFeatureTree.new(DUMMY_OBJ)
18
- }
19
- end
20
-
21
- def test_find_feature
22
- dim = 2
23
- points = []
24
- points << [99, 51]
25
- points << [52, 57]
26
- points << [57, 42]
27
- points << [13, 39]
28
- points << [15, 68]
29
- points << [75, 11]
30
- points << [69, 62]
31
- points << [52, 46]
32
- points << [0, 64]
33
- points << [67, 16]
34
-
35
- desc1 = CvMat.new(points.size, dim, :cv32f, 1)
36
- desc1.set_data(points)
37
-
38
- pt = [[50, 50], [11, 40]]
39
- desc2 = CvMat.new(pt.size, dim, :cv32f, 1)
40
- desc2.set_data(pt)
41
-
42
- ft = CvFeatureTree.new(desc1)
43
- results, dist = ft.find_features(desc2, 1, 10)
44
-
45
- assert_equal(CvMat, results.class)
46
- assert_equal(CvMat, dist.class)
47
-
48
- assert_equal(7, results[0][0].to_i)
49
- assert_in_delta(4.472, dist[0][0], 0.001)
50
-
51
- assert_equal(3, results[1][0].to_i)
52
- assert_in_delta(2.236, dist[1][0], 0.001)
53
-
54
- assert_raise(TypeError) {
55
- ft.find_features(DUMMY_OBJ, 1, 10)
56
- }
57
- assert_raise(TypeError) {
58
- ft.find_features(desc2, DUMMY_OBJ, 10)
59
- }
60
- assert_raise(TypeError) {
61
- ft.find_features(desc2, 1, DUMMY_OBJ)
62
- }
63
- end
64
- end
65
-
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
+
9
+ # Tests for OpenCV::CvFeatureTree
10
+ class TestCvFeatureTree < OpenCVTestCase
11
+ def test_initialize
12
+ desc = CvMat.new(1, 1, :cv32f, 1)
13
+ ft = CvFeatureTree.new(desc)
14
+ assert_equal(CvFeatureTree, ft.class)
15
+
16
+ assert_raise(TypeError) {
17
+ CvFeatureTree.new(DUMMY_OBJ)
18
+ }
19
+ end
20
+
21
+ def test_find_feature
22
+ dim = 2
23
+ points = []
24
+ points << [99, 51]
25
+ points << [52, 57]
26
+ points << [57, 42]
27
+ points << [13, 39]
28
+ points << [15, 68]
29
+ points << [75, 11]
30
+ points << [69, 62]
31
+ points << [52, 46]
32
+ points << [0, 64]
33
+ points << [67, 16]
34
+
35
+ desc1 = CvMat.new(points.size, dim, :cv32f, 1)
36
+ desc1.set_data(points)
37
+
38
+ pt = [[50, 50], [11, 40]]
39
+ desc2 = CvMat.new(pt.size, dim, :cv32f, 1)
40
+ desc2.set_data(pt)
41
+
42
+ ft = CvFeatureTree.new(desc1)
43
+ results, dist = ft.find_features(desc2, 1, 10)
44
+
45
+ assert_equal(CvMat, results.class)
46
+ assert_equal(CvMat, dist.class)
47
+
48
+ assert_equal(7, results[0][0].to_i)
49
+ assert_in_delta(4.472, dist[0][0], 0.001)
50
+
51
+ assert_equal(3, results[1][0].to_i)
52
+ assert_in_delta(2.236, dist[1][0], 0.001)
53
+
54
+ assert_raise(TypeError) {
55
+ ft.find_features(DUMMY_OBJ, 1, 10)
56
+ }
57
+ assert_raise(TypeError) {
58
+ ft.find_features(desc2, DUMMY_OBJ, 10)
59
+ }
60
+ assert_raise(TypeError) {
61
+ ft.find_features(desc2, 1, DUMMY_OBJ)
62
+ }
63
+ end
64
+ end
65
+
@@ -1,58 +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::CvFont
10
- class TestCvFont < OpenCVTestCase
11
- def test_FACE
12
- assert_equal(0, CvFont::FACE[:simplex])
13
- assert_equal(1, CvFont::FACE[:plain])
14
- assert_equal(2, CvFont::FACE[:duplex])
15
- assert_equal(4, CvFont::FACE[:triplex])
16
- assert_equal(5, CvFont::FACE[:complex_small])
17
- assert_equal(6, CvFont::FACE[:script_simplex])
18
- assert_equal(7, CvFont::FACE[:script_complex])
19
- end
20
-
21
- def test_FONT_OPTION
22
- assert_equal(1.0, CvFont::FONT_OPTION[:hscale])
23
- assert_equal(1.0, CvFont::FONT_OPTION[:vscale])
24
- assert_equal(0, CvFont::FONT_OPTION[:shear])
25
- assert_equal(1, CvFont::FONT_OPTION[:thickness])
26
- assert_equal(8, CvFont::FONT_OPTION[:line_type])
27
- end
28
-
29
- def test_initialize
30
- font = CvFont.new(:simplex)
31
- assert_equal(0, font.face)
32
- assert_equal(1.0, font.hscale)
33
- assert_equal(1.0, font.vscale)
34
- assert_equal(0, font.shear)
35
- assert_equal(1, font.thickness)
36
- assert_equal(8, font.line_type)
37
- assert_false(font.italic)
38
-
39
- font = CvFont.new(:plain, :hscale => 2.5, :vscale => 3.5,
40
- :shear => 0.5, :thickness => 3, :line_type => 2, :italic => false)
41
- assert_equal(1, font.face)
42
- assert_equal(2.5, font.hscale)
43
- assert_equal(3.5, font.vscale)
44
- assert_equal(0.5, font.shear)
45
- assert_equal(3, font.thickness)
46
- assert_equal(2, font.line_type)
47
- assert_false(font.italic)
48
-
49
- font = CvFont.new(:simplex, :italic => true)
50
- assert_equal(16, font.face)
51
- assert(font.italic)
52
-
53
- assert_raise(ArgumentError) {
54
- CvFont.new(:foo)
55
- }
56
- end
57
- end
58
-
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
+
9
+ # Tests for OpenCV::CvFont
10
+ class TestCvFont < OpenCVTestCase
11
+ def test_FACE
12
+ assert_equal(0, CvFont::FACE[:simplex])
13
+ assert_equal(1, CvFont::FACE[:plain])
14
+ assert_equal(2, CvFont::FACE[:duplex])
15
+ assert_equal(4, CvFont::FACE[:triplex])
16
+ assert_equal(5, CvFont::FACE[:complex_small])
17
+ assert_equal(6, CvFont::FACE[:script_simplex])
18
+ assert_equal(7, CvFont::FACE[:script_complex])
19
+ end
20
+
21
+ def test_FONT_OPTION
22
+ assert_equal(1.0, CvFont::FONT_OPTION[:hscale])
23
+ assert_equal(1.0, CvFont::FONT_OPTION[:vscale])
24
+ assert_equal(0, CvFont::FONT_OPTION[:shear])
25
+ assert_equal(1, CvFont::FONT_OPTION[:thickness])
26
+ assert_equal(8, CvFont::FONT_OPTION[:line_type])
27
+ end
28
+
29
+ def test_initialize
30
+ font = CvFont.new(:simplex)
31
+ assert_equal(0, font.face)
32
+ assert_equal(1.0, font.hscale)
33
+ assert_equal(1.0, font.vscale)
34
+ assert_equal(0, font.shear)
35
+ assert_equal(1, font.thickness)
36
+ assert_equal(8, font.line_type)
37
+ assert_false(font.italic)
38
+
39
+ font = CvFont.new(:plain, :hscale => 2.5, :vscale => 3.5,
40
+ :shear => 0.5, :thickness => 3, :line_type => 2, :italic => false)
41
+ assert_equal(1, font.face)
42
+ assert_equal(2.5, font.hscale)
43
+ assert_equal(3.5, font.vscale)
44
+ assert_equal(0.5, font.shear)
45
+ assert_equal(3, font.thickness)
46
+ assert_equal(2, font.line_type)
47
+ assert_false(font.italic)
48
+
49
+ font = CvFont.new(:simplex, :italic => true)
50
+ assert_equal(16, font.face)
51
+ assert(font.italic)
52
+
53
+ assert_raise(ArgumentError) {
54
+ CvFont.new(:foo)
55
+ }
56
+ end
57
+ end
58
+
@@ -1,63 +1,63 @@
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::CvHaarClassifierCascade
10
- class TestCvHaarClassifierCascade < OpenCVTestCase
11
- def setup
12
- @cascade = CvHaarClassifierCascade.load(HAARCASCADE_FRONTALFACE_ALT)
13
- end
14
-
15
- def test_load
16
- assert_equal(CvHaarClassifierCascade, @cascade.class)
17
- assert_raise(ArgumentError) {
18
- CvHaarClassifierCascade.load('not/exist.xml')
19
- }
20
- end
21
-
22
- def test_detect_objects
23
- img = CvMat.load(FILENAME_LENA256x256)
24
-
25
- detected = @cascade.detect_objects(img)
26
- assert_equal(CvSeq, detected.class)
27
- assert_equal(1, detected.size)
28
- assert_equal(CvAvgComp, detected[0].class)
29
- assert_equal(106, detected[0].x)
30
- assert_equal(100, detected[0].y)
31
- assert_equal(89, detected[0].width)
32
- assert_equal(89, detected[0].height)
33
- assert_equal(48, detected[0].neighbors)
34
-
35
- detected = @cascade.detect_objects(img) { |face|
36
- assert_equal(106, face.x)
37
- assert_equal(100, face.y)
38
- assert_equal(89, face.width)
39
- assert_equal(89, face.height)
40
- assert_equal(48, face.neighbors)
41
- }
42
- assert_equal(CvSeq, detected.class)
43
- assert_equal(1, detected.size)
44
- assert_equal(CvAvgComp, detected[0].class)
45
-
46
- detected = @cascade.detect_objects(img, :scale_factor => 2.0, :flags => CV_HAAR_DO_CANNY_PRUNING,
47
- :min_neighbors => 5, :min_size => CvSize.new(10, 10),
48
- :max_size => CvSize.new(100, 100))
49
- assert_equal(CvSeq, detected.class)
50
- assert_equal(1, detected.size)
51
- assert_equal(CvAvgComp, detected[0].class)
52
- assert_equal(109, detected[0].x)
53
- assert_equal(102, detected[0].y)
54
- assert_equal(80, detected[0].width)
55
- assert_equal(80, detected[0].height)
56
- assert_equal(7, detected[0].neighbors)
57
-
58
- assert_raise(TypeError) {
59
- @cascade.detect_objects('foo')
60
- }
61
- end
62
- end
63
-
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
+
9
+ # Tests for OpenCV::CvHaarClassifierCascade
10
+ class TestCvHaarClassifierCascade < OpenCVTestCase
11
+ def setup
12
+ @cascade = CvHaarClassifierCascade.load(HAARCASCADE_FRONTALFACE_ALT)
13
+ end
14
+
15
+ def test_load
16
+ assert_equal(CvHaarClassifierCascade, @cascade.class)
17
+ assert_raise(ArgumentError) {
18
+ CvHaarClassifierCascade.load('not/exist.xml')
19
+ }
20
+ end
21
+
22
+ def test_detect_objects
23
+ img = CvMat.load(FILENAME_LENA256x256)
24
+
25
+ detected = @cascade.detect_objects(img)
26
+ assert_equal(CvSeq, detected.class)
27
+ assert_equal(1, detected.size)
28
+ assert_equal(CvAvgComp, detected[0].class)
29
+ assert_equal(106, detected[0].x)
30
+ assert_equal(100, detected[0].y)
31
+ assert_equal(89, detected[0].width)
32
+ assert_equal(89, detected[0].height)
33
+ assert_equal(48, detected[0].neighbors)
34
+
35
+ detected = @cascade.detect_objects(img) { |face|
36
+ assert_equal(106, face.x)
37
+ assert_equal(100, face.y)
38
+ assert_equal(89, face.width)
39
+ assert_equal(89, face.height)
40
+ assert_equal(48, face.neighbors)
41
+ }
42
+ assert_equal(CvSeq, detected.class)
43
+ assert_equal(1, detected.size)
44
+ assert_equal(CvAvgComp, detected[0].class)
45
+
46
+ detected = @cascade.detect_objects(img, :scale_factor => 2.0, :flags => CV_HAAR_DO_CANNY_PRUNING,
47
+ :min_neighbors => 5, :min_size => CvSize.new(10, 10),
48
+ :max_size => CvSize.new(100, 100))
49
+ assert_equal(CvSeq, detected.class)
50
+ assert_equal(1, detected.size)
51
+ assert_equal(CvAvgComp, detected[0].class)
52
+ assert_equal(109, detected[0].x)
53
+ assert_equal(102, detected[0].y)
54
+ assert_equal(80, detected[0].width)
55
+ assert_equal(80, detected[0].height)
56
+ assert_equal(7, detected[0].neighbors)
57
+
58
+ assert_raise(TypeError) {
59
+ @cascade.detect_objects('foo')
60
+ }
61
+ end
62
+ end
63
+