afeld-opencv 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/Gemfile +6 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +217 -0
- data/README.rdoc +161 -0
- data/Rakefile +52 -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/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 +499 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +230 -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 +297 -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 +5627 -0
- data/ext/opencv/cvmat.h +280 -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 +246 -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 +72 -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 +194 -0
- data/ext/opencv/cvutils.h +29 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -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 +576 -0
- data/ext/opencv/iplimage.h +70 -0
- data/ext/opencv/lib/opencv.rb +3 -0
- data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
- data/ext/opencv/lib/opencv/version.rb +3 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +710 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +284 -0
- data/ext/opencv/pointset.h +69 -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/extconf.rb +65 -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/test/helper.rb +146 -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/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 +2752 -0
- data/test/test_cvmat_drawing.rb +318 -0
- data/test/test_cvmat_dxt.rb +147 -0
- data/test/test_cvmat_imageprocessing.rb +1943 -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 +156 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +340 -0
- data/test/test_pointset.rb +130 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +399 -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::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
|
+
|
@@ -0,0 +1,54 @@
|
|
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::IplConvKernel
|
10
|
+
class TestIplConvKernel < OpenCVTestCase
|
11
|
+
def test_initialize
|
12
|
+
[:rect, :cross, :ellipse, CV_SHAPE_RECT, CV_SHAPE_CROSS, CV_SHAPE_ELLIPSE].each { |shape|
|
13
|
+
kernel = IplConvKernel.new(5, 5, 2, 2, shape)
|
14
|
+
assert_not_nil(kernel)
|
15
|
+
}
|
16
|
+
|
17
|
+
values = [1] * 25
|
18
|
+
[:custom, CV_SHAPE_CUSTOM].each { |shape|
|
19
|
+
kernel = IplConvKernel.new(5, 5, 2, 2, shape, values)
|
20
|
+
assert_not_nil(kernel)
|
21
|
+
}
|
22
|
+
|
23
|
+
[:custom, CV_SHAPE_CUSTOM].each { |shape|
|
24
|
+
assert_raise(ArgumentError) {
|
25
|
+
IplConvKernel.new(5, 5, 2, 2, shape)
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
assert_raise(TypeError) {
|
30
|
+
IplConvKernel.new(5, 5, 2, 2, :foobar)
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_size
|
35
|
+
kernel = IplConvKernel.new(5, 4, 2, 2, :rect)
|
36
|
+
size = kernel.size
|
37
|
+
assert_equal(5, size.width)
|
38
|
+
assert_equal(4, size.height)
|
39
|
+
|
40
|
+
assert_equal(5, kernel.cols)
|
41
|
+
assert_equal(4, kernel.rows)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_anchor
|
45
|
+
kernel = IplConvKernel.new(5, 4, 3, 2, :rect)
|
46
|
+
a = kernel.anchor
|
47
|
+
assert_equal(3, a.x)
|
48
|
+
assert_equal(2, a.y)
|
49
|
+
|
50
|
+
assert_equal(3, kernel.anchor_x)
|
51
|
+
assert_equal(2, kernel.anchor_y)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,156 @@
|
|
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::IplImage
|
10
|
+
class TestIplImage < OpenCVTestCase
|
11
|
+
def should_classify_images_as(filename, classification)
|
12
|
+
assert_equal(OpenCV::IplImage::load(filename, OpenCV::CV_LOAD_IMAGE_GRAYSCALE).smoothness[0], classification)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initialize
|
16
|
+
img = IplImage.new(10, 20)
|
17
|
+
assert_equal(10, img.width)
|
18
|
+
assert_equal(20, img.height)
|
19
|
+
assert_equal(:cv8u, img.depth)
|
20
|
+
assert_equal(3, img.channel)
|
21
|
+
|
22
|
+
img = IplImage.new(30, 40, :cv32f, 1)
|
23
|
+
assert_equal(30, img.width)
|
24
|
+
assert_equal(40, img.height)
|
25
|
+
assert_equal(:cv32f, img.depth)
|
26
|
+
assert_equal(1, img.channel)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_load
|
30
|
+
img = IplImage.load(FILENAME_CAT)
|
31
|
+
assert_equal(IplImage, img.class)
|
32
|
+
assert_equal(375, img.width)
|
33
|
+
assert_equal(500, img.height)
|
34
|
+
assert_equal(:cv8u, img.depth)
|
35
|
+
assert_equal(3, img.channel)
|
36
|
+
assert_equal('f2e4dc5d6d3fc285203762ff53d150c7', hash_img(img))
|
37
|
+
|
38
|
+
img = IplImage.load(FILENAME_CAT, CV_LOAD_IMAGE_GRAYSCALE)
|
39
|
+
assert_equal(IplImage, img.class)
|
40
|
+
assert_equal(375, img.width)
|
41
|
+
assert_equal(500, img.height)
|
42
|
+
assert_equal(:cv8u, img.depth)
|
43
|
+
assert_equal(1, img.channel)
|
44
|
+
# The following test fails only when executed by test runner. (I don't know why...)
|
45
|
+
# $ ruby test/runner.rb #=> fail
|
46
|
+
# $ ruby test/test_iplimage.rb #=> pass
|
47
|
+
assert_equal('b1a0c1c5504961b62e15fa7d57a2e7e0', hash_img(img))
|
48
|
+
|
49
|
+
img = IplImage.load(FILENAME_CAT, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR)
|
50
|
+
assert_equal(IplImage, img.class)
|
51
|
+
assert_equal(375, img.width)
|
52
|
+
assert_equal(500, img.height)
|
53
|
+
assert_equal(:cv8u, img.depth)
|
54
|
+
assert_equal(3, img.channel)
|
55
|
+
assert_equal('f2e4dc5d6d3fc285203762ff53d150c7', hash_img(img))
|
56
|
+
|
57
|
+
assert_raise(ArgumentError) {
|
58
|
+
IplImage.load
|
59
|
+
}
|
60
|
+
assert_raise(TypeError) {
|
61
|
+
IplImage.load(123)
|
62
|
+
}
|
63
|
+
assert_raise(TypeError) {
|
64
|
+
IplImage.load(FILENAME_CAT, 'foobar')
|
65
|
+
}
|
66
|
+
assert_raise(StandardError) {
|
67
|
+
IplImage.load('file/does/not/exist')
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_roi
|
72
|
+
img = IplImage.new(20, 30)
|
73
|
+
rect = img.roi
|
74
|
+
assert_equal(0, rect.x)
|
75
|
+
assert_equal(0, rect.y)
|
76
|
+
assert_equal(img.width, rect.width)
|
77
|
+
assert_equal(img.height, rect.height)
|
78
|
+
|
79
|
+
img.set_roi(CvRect.new(2, 3, 10, 20))
|
80
|
+
rect = img.roi
|
81
|
+
assert_equal(2, rect.x)
|
82
|
+
assert_equal(3, rect.y)
|
83
|
+
assert_equal(10, rect.width)
|
84
|
+
assert_equal(20, rect.height)
|
85
|
+
|
86
|
+
img.reset_roi
|
87
|
+
rect = img.roi
|
88
|
+
assert_equal(0, rect.x)
|
89
|
+
assert_equal(0, rect.y)
|
90
|
+
assert_equal(img.width, rect.width)
|
91
|
+
assert_equal(img.height, rect.height)
|
92
|
+
|
93
|
+
img.set_roi(CvRect.new(1, 2, 5, 6)) {|image|
|
94
|
+
rect = image.roi
|
95
|
+
assert_equal(1, rect.x)
|
96
|
+
assert_equal(2, rect.y)
|
97
|
+
assert_equal(5, rect.width)
|
98
|
+
assert_equal(6, rect.height)
|
99
|
+
}
|
100
|
+
rect = img.roi
|
101
|
+
assert_equal(0, rect.x)
|
102
|
+
assert_equal(0, rect.y)
|
103
|
+
assert_equal(img.width, rect.width)
|
104
|
+
assert_equal(img.height, rect.height)
|
105
|
+
|
106
|
+
# Alias
|
107
|
+
img.roi = CvRect.new(4, 5, 11, 12)
|
108
|
+
rect = img.roi
|
109
|
+
assert_equal(4, rect.x)
|
110
|
+
assert_equal(5, rect.y)
|
111
|
+
assert_equal(11, rect.width)
|
112
|
+
assert_equal(12, rect.height)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_coi
|
116
|
+
img = IplImage.new(20, 30)
|
117
|
+
assert_equal(0, img.coi)
|
118
|
+
|
119
|
+
img.set_coi(1)
|
120
|
+
assert_equal(1, img.coi)
|
121
|
+
|
122
|
+
img.reset_coi
|
123
|
+
assert_equal(0, img.coi)
|
124
|
+
|
125
|
+
img.set_coi(2) {|image|
|
126
|
+
assert_equal(2, image.coi)
|
127
|
+
}
|
128
|
+
assert_equal(0, img.coi)
|
129
|
+
|
130
|
+
# Alias
|
131
|
+
img.coi = 1
|
132
|
+
assert_equal(1, img.coi)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_smoothness
|
136
|
+
asset_path = File.join(File.dirname(__FILE__), 'samples')
|
137
|
+
|
138
|
+
for image in Array.new(7) { |e| e = File.join(asset_path, "smooth%d.jpg") % e } do
|
139
|
+
should_classify_images_as image, :smooth
|
140
|
+
end
|
141
|
+
|
142
|
+
for image in Array.new(2) { |e| e = File.join(asset_path, "messy%d.jpg") % e } do
|
143
|
+
should_classify_images_as image, :messy
|
144
|
+
end
|
145
|
+
|
146
|
+
for image in Array.new(10) { |e| e = File.join(asset_path, "blank%d.jpg") % e } do
|
147
|
+
should_classify_images_as image, :blank
|
148
|
+
end
|
149
|
+
|
150
|
+
for image in Array.new(2) { |e| e = File.join(asset_path, "partially_blank%d.jpg") % e } do
|
151
|
+
should_classify_images_as image, :blank
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|