ruby-opencv 0.0.10-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +227 -0
- data/README.md +98 -0
- data/Rakefile +90 -0
- data/config.yml +7 -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/matching_to_many_images.rb +16 -0
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +3 -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 +506 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +233 -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 +296 -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 +5848 -0
- data/ext/opencv/cvmat.h +284 -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 +245 -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 +74 -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 +192 -0
- data/ext/opencv/cvutils.h +30 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/extconf.rb +83 -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 +644 -0
- data/ext/opencv/iplimage.h +73 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +727 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +274 -0
- data/ext/opencv/pointset.h +68 -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/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/lib/1.9/opencv.so +0 -0
- data/lib/2.0/opencv.so +0 -0
- data/lib/opencv.rb +12 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +44 -0
- data/test/helper.rb +166 -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/chessboard.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 +2947 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2015 -0
- data/test/test_cvmat_matching.rb +57 -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 +236 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +329 -0
- data/test/test_pointset.rb +126 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +386 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/test_curve.rb
ADDED
@@ -0,0 +1,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::Curve
|
10
|
+
class TestCurve < OpenCVTestCase
|
11
|
+
def setup
|
12
|
+
@contour1 = CvContour.new
|
13
|
+
|
14
|
+
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
|
15
|
+
(j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
|
16
|
+
}
|
17
|
+
@contour2 = mat0.find_contours
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_closed
|
21
|
+
assert_false(@contour1.closed?)
|
22
|
+
assert(@contour2.closed?)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_convex
|
26
|
+
assert_false(@contour1.convex?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_hole
|
30
|
+
assert_false(@contour1.hole?)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_simple
|
34
|
+
assert(@contour1.simple?)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_arc_length
|
38
|
+
assert_in_delta(211.480, @contour2.arc_length, 0.001)
|
39
|
+
assert_in_delta(32.181, @contour2.arc_length(CvSlice.new(0, 9), true), 0.001)
|
40
|
+
assert_in_delta(32.181, @contour2.arc_length(0..10, true), 0.001)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,24 @@
|
|
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::CvAvgComp
|
10
|
+
class TestCvAvgComp < OpenCVTestCase
|
11
|
+
def setup
|
12
|
+
@avgcomp = CvAvgComp.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initialize
|
16
|
+
assert_equal(CvAvgComp, @avgcomp.class)
|
17
|
+
assert(@avgcomp.is_a? CvRect)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_neighbors
|
21
|
+
assert_equal(Fixnum, @avgcomp.neighbors.class)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,76 @@
|
|
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::CvBox2D
|
10
|
+
class TestCvBox2D < OpenCVTestCase
|
11
|
+
class MyPoint; end
|
12
|
+
def test_initialize
|
13
|
+
box = CvBox2D.new
|
14
|
+
assert_in_delta(0, box.center.x, 0.001)
|
15
|
+
assert_in_delta(0, box.center.y, 0.001)
|
16
|
+
assert_in_delta(0, box.size.width, 0.001)
|
17
|
+
assert_in_delta(0, box.size.height, 0.001)
|
18
|
+
assert_in_delta(0, box.angle, 0.001)
|
19
|
+
|
20
|
+
box = CvBox2D.new(CvPoint2D32f.new(1.1, 2.2), CvSize2D32f.new(3.3, 4.4), 5.5)
|
21
|
+
assert_in_delta(1.1, box.center.x, 0.001)
|
22
|
+
assert_in_delta(2.2, box.center.y, 0.001)
|
23
|
+
assert_in_delta(3.3, box.size.width, 0.001)
|
24
|
+
assert_in_delta(4.4, box.size.height, 0.001)
|
25
|
+
assert_in_delta(5.5, box.angle, 0.001)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_center
|
29
|
+
box = CvBox2D.new
|
30
|
+
box.center = CvPoint2D32f.new(1.1, 2.2)
|
31
|
+
assert_in_delta(1.1, box.center.x, 0.001)
|
32
|
+
assert_in_delta(2.2, box.center.y, 0.001)
|
33
|
+
|
34
|
+
box.center.x = 3.3
|
35
|
+
box.center.y = 4.4
|
36
|
+
assert_in_delta(3.3, box.center.x, 0.001)
|
37
|
+
assert_in_delta(4.4, box.center.y, 0.001)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_size
|
41
|
+
box = CvBox2D.new
|
42
|
+
box.size = CvSize2D32f.new(1.1, 2.2)
|
43
|
+
assert_in_delta(1.1, box.size.width, 0.001)
|
44
|
+
assert_in_delta(2.2, box.size.height, 0.001)
|
45
|
+
|
46
|
+
box.size.width = 3.3
|
47
|
+
box.size.height = 4.4
|
48
|
+
assert_in_delta(3.3, box.size.width, 0.001)
|
49
|
+
assert_in_delta(4.4, box.size.height, 0.001)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_angle
|
53
|
+
box = CvBox2D.new
|
54
|
+
box.angle = 1.1
|
55
|
+
assert_in_delta(1.1, box.angle, 0.001)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_points
|
59
|
+
box = CvBox2D.new
|
60
|
+
box.center = CvPoint2D32f.new(10, 20)
|
61
|
+
box.size = CvSize2D32f.new(5, 7)
|
62
|
+
pt = box.points
|
63
|
+
|
64
|
+
assert_equal(4, pt.size)
|
65
|
+
assert_in_delta(7.5, pt[0].x, 0.001)
|
66
|
+
assert_in_delta(23.5, pt[0].y, 0.001)
|
67
|
+
assert_in_delta(7.5, pt[1].x, 0.001)
|
68
|
+
assert_in_delta(16.5, pt[1].y, 0.001)
|
69
|
+
assert_in_delta(12.5, pt[2].x, 0.001)
|
70
|
+
assert_in_delta(16.5, pt[2].y, 0.001)
|
71
|
+
assert_in_delta(12.5, pt[3].x, 0.001)
|
72
|
+
assert_in_delta(23.5, pt[3].y, 0.001)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
@@ -0,0 +1,183 @@
|
|
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::CvCapture
|
10
|
+
class TestCvCapture < OpenCVTestCase
|
11
|
+
def setup
|
12
|
+
@cap = CvCapture.open(AVI_SAMPLE)
|
13
|
+
@cap.query
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
@cap = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_INTERFACE
|
21
|
+
assert_equal(CvCapture::INTERFACE[:any], 0)
|
22
|
+
assert_equal(CvCapture::INTERFACE[:mil], 100)
|
23
|
+
assert_equal(CvCapture::INTERFACE[:vfw], 200)
|
24
|
+
assert_equal(CvCapture::INTERFACE[:v4l], 200)
|
25
|
+
assert_equal(CvCapture::INTERFACE[:v4l2], 200)
|
26
|
+
assert_equal(CvCapture::INTERFACE[:fireware], 300)
|
27
|
+
assert_equal(CvCapture::INTERFACE[:ieee1394], 300)
|
28
|
+
assert_equal(CvCapture::INTERFACE[:dc1394], 300)
|
29
|
+
assert_equal(CvCapture::INTERFACE[:cmu1394], 300)
|
30
|
+
assert_equal(CvCapture::INTERFACE[:stereo], 400)
|
31
|
+
assert_equal(CvCapture::INTERFACE[:tyzx], 400)
|
32
|
+
assert_equal(CvCapture::INTERFACE[:tyzx_left], 400)
|
33
|
+
assert_equal(CvCapture::INTERFACE[:tyzx_right], 401)
|
34
|
+
assert_equal(CvCapture::INTERFACE[:tyzx_color], 402)
|
35
|
+
assert_equal(CvCapture::INTERFACE[:tyzx_z], 403)
|
36
|
+
assert_equal(CvCapture::INTERFACE[:qt], 500)
|
37
|
+
assert_equal(CvCapture::INTERFACE[:quicktime], 500)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_open
|
41
|
+
cap1 = CvCapture.open(AVI_SAMPLE)
|
42
|
+
assert_equal(CvCapture, cap1.class)
|
43
|
+
|
44
|
+
# Uncomment the following lines to test capturing from camera
|
45
|
+
# cap2 = CvCapture.open(0)
|
46
|
+
# assert_equal(CvCapture, cap2.class)
|
47
|
+
# CvCapture::INTERFACE.each { |k, v|
|
48
|
+
# cap3 = CvCapture.open(k)
|
49
|
+
# assert_equal(CvCapture, cap3.class)
|
50
|
+
# }
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_grab
|
54
|
+
assert(@cap.grab)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_retrieve
|
58
|
+
@cap.grab
|
59
|
+
img = @cap.retrieve
|
60
|
+
assert_equal(IplImage, img.class)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_query
|
64
|
+
img = @cap.query
|
65
|
+
assert_equal(IplImage, img.class)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_millisecond
|
69
|
+
@cap.millisecond = 10
|
70
|
+
assert(@cap.millisecond.is_a? Numeric)
|
71
|
+
# assert_equal(10, @cap.millisecond)
|
72
|
+
@cap.millisecond = 20
|
73
|
+
assert(@cap.millisecond.is_a? Numeric)
|
74
|
+
# assert_equal(20, @cap.millisecond)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_frames
|
78
|
+
@cap.frames = 10
|
79
|
+
assert(@cap.frames.is_a? Numeric)
|
80
|
+
# assert_equal(10, @cap.frames)
|
81
|
+
@cap.frames = 20
|
82
|
+
assert(@cap.frames.is_a? Numeric)
|
83
|
+
# assert_equal(20, @cap.frames)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_avi_ratio
|
87
|
+
@cap.avi_ratio = 0.1
|
88
|
+
assert(@cap.avi_ratio.is_a? Numeric)
|
89
|
+
# assert_equal(0.1, @cap.avi_ratio)
|
90
|
+
@cap.avi_ratio = 0.8
|
91
|
+
assert(@cap.avi_ratio.is_a? Numeric)
|
92
|
+
# assert_equal(0.8, @cap.avi_ratio)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_size
|
96
|
+
@cap.size = CvSize.new(320, 240)
|
97
|
+
assert_equal(CvSize, @cap.size.class)
|
98
|
+
# assert_equal(320, @cap.size.width)
|
99
|
+
# assert_equal(240, @cap.size.height)
|
100
|
+
|
101
|
+
@cap.size = CvSize.new(640, 480)
|
102
|
+
assert_equal(CvSize, @cap.size.class)
|
103
|
+
# assert_equal(640, @cap.size.width)
|
104
|
+
# assert_equal(480, @cap.size.height)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_width
|
108
|
+
@cap.width = 320
|
109
|
+
assert(@cap.width.is_a? Numeric)
|
110
|
+
# assert_equal(320, @cap.width)
|
111
|
+
@cap.width = 640
|
112
|
+
assert(@cap.width.is_a? Numeric)
|
113
|
+
# assert_equal(640, @cap.width)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_height
|
117
|
+
@cap.height = 240
|
118
|
+
assert(@cap.height.is_a? Numeric)
|
119
|
+
# assert_equal(240, @cap.height)
|
120
|
+
@cap.height = 480
|
121
|
+
assert(@cap.height.is_a? Numeric)
|
122
|
+
# assert_equal(480, @cap.height)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_fps
|
126
|
+
@cap.fps = 15
|
127
|
+
assert(@cap.fps.is_a? Numeric)
|
128
|
+
# assert_equal(15, @cap.fps)
|
129
|
+
@cap.fps = 30
|
130
|
+
assert(@cap.fps.is_a? Numeric)
|
131
|
+
# assert_equal(30, @cap.fps)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_fourcc
|
135
|
+
assert_equal(String, @cap.fourcc.class)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_frame_count
|
139
|
+
assert(@cap.frame_count.is_a? Numeric)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_format
|
143
|
+
assert(@cap.format.is_a? Numeric)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_mode
|
147
|
+
assert(@cap.mode.is_a? Numeric)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_brightness
|
151
|
+
assert(@cap.brightness.is_a? Numeric)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_contrast
|
155
|
+
assert(@cap.contrast.is_a? Numeric)
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_saturation
|
159
|
+
assert(@cap.saturation.is_a? Numeric)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_hue
|
163
|
+
assert(@cap.hue.is_a? Numeric)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_gain
|
167
|
+
assert(@cap.gain.is_a? Numeric)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_exposure
|
171
|
+
assert(@cap.exposure.is_a? Numeric)
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_convert_rgb
|
175
|
+
assert((@cap.convert_rgb == true) ||
|
176
|
+
(@cap.convert_rgb == false))
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_rectification
|
180
|
+
assert(@cap.rectification.is_a? Numeric)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
@@ -0,0 +1,108 @@
|
|
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::CvChain
|
10
|
+
class TestCvChain < OpenCVTestCase
|
11
|
+
def test_APPROX_OPTION
|
12
|
+
assert_equal(:approx_simple, CvChain::APPROX_CHAIN_OPTION[:method])
|
13
|
+
assert_equal(0, CvChain::APPROX_CHAIN_OPTION[:parameter])
|
14
|
+
assert_equal(0, CvChain::APPROX_CHAIN_OPTION[:minimal_perimeter])
|
15
|
+
assert_false(CvChain::APPROX_CHAIN_OPTION[:recursive])
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_initialize
|
19
|
+
chain = CvChain.new
|
20
|
+
assert_not_nil(chain)
|
21
|
+
assert_equal(CvChain, chain.class)
|
22
|
+
assert(chain.is_a? CvSeq)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_origin
|
26
|
+
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
|
27
|
+
(j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
|
28
|
+
}
|
29
|
+
chain = mat0.find_contours(:mode => CV_RETR_EXTERNAL, :method => CV_CHAIN_CODE)
|
30
|
+
assert_equal(CvChain, chain.class)
|
31
|
+
assert_equal(64, chain.origin.x)
|
32
|
+
assert_equal(32, chain.origin.y)
|
33
|
+
|
34
|
+
chain.origin = CvPoint.new(32, 64)
|
35
|
+
assert_equal(32, chain.origin.x)
|
36
|
+
assert_equal(64, chain.origin.y)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_codes
|
40
|
+
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
|
41
|
+
(j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
|
42
|
+
}
|
43
|
+
chain = mat0.find_contours(:mode => CV_RETR_EXTERNAL, :method => CV_CHAIN_CODE)
|
44
|
+
assert_equal(Array, chain.codes.class)
|
45
|
+
assert(chain.codes.all? { |a| (a.class == Fixnum) and (a >= 0 and a <= 7) })
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_points
|
49
|
+
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
|
50
|
+
(j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
|
51
|
+
}
|
52
|
+
chain = mat0.find_contours(:mode => CV_RETR_EXTERNAL, :method => CV_CHAIN_CODE)
|
53
|
+
assert_equal(Array, chain.points.class)
|
54
|
+
assert(chain.points.all? { |a| a.class == CvPoint })
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_approx_chains
|
58
|
+
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
|
59
|
+
(j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
|
60
|
+
}
|
61
|
+
chain = mat0.find_contours(:mode => CV_RETR_EXTERNAL, :method => CV_CHAIN_CODE)
|
62
|
+
|
63
|
+
contours = chain.approx_chains
|
64
|
+
assert_equal(CvChain, contours.class)
|
65
|
+
assert(contours.size > 0)
|
66
|
+
assert(contours.all? { |c| c.class == CvPoint })
|
67
|
+
|
68
|
+
[CV_CHAIN_APPROX_NONE, CV_CHAIN_APPROX_SIMPLE,
|
69
|
+
CV_CHAIN_APPROX_TC89_L1, CV_CHAIN_APPROX_TC89_KCOS,
|
70
|
+
:approx_none, :approx_simple, :approx_tc89_l1, :approx_tc89_kcos].each { |method|
|
71
|
+
contours = chain.approx_chains(:method => method)
|
72
|
+
assert_equal(CvChain, contours.class)
|
73
|
+
assert(contours.size > 0)
|
74
|
+
assert(contours.all? { |c| c.class == CvPoint })
|
75
|
+
}
|
76
|
+
|
77
|
+
contours = chain.approx_chains(:minimal_parameter => 10)
|
78
|
+
assert_equal(CvChain, contours.class)
|
79
|
+
assert(contours.size > 0)
|
80
|
+
assert(contours.all? { |c| c.class == CvPoint })
|
81
|
+
|
82
|
+
contours = chain.approx_chains(:minimal_perimeter => (32 * 2 * Math::PI).ceil)
|
83
|
+
assert_nil(contours)
|
84
|
+
|
85
|
+
[true, false].each { |recursive|
|
86
|
+
contours = chain.approx_chains(:recursive => recursive)
|
87
|
+
assert_equal(CvChain, contours.class)
|
88
|
+
assert(contours.size > 0)
|
89
|
+
assert(contours.all? { |c| c.class == CvPoint })
|
90
|
+
}
|
91
|
+
|
92
|
+
contours = chain.approx_chains(:method => :approx_simple,
|
93
|
+
:minimal_parameter => 100, :recursive => false)
|
94
|
+
assert_equal(CvChain, contours.class)
|
95
|
+
assert(contours.size > 0)
|
96
|
+
assert(contours.all? { |c| c.class == CvPoint })
|
97
|
+
|
98
|
+
# Uncomment the following lines to show the result
|
99
|
+
# contours = chain.approx_chains
|
100
|
+
# dst = mat0.clone.zero
|
101
|
+
# begin
|
102
|
+
# dst.draw_contours!(contours, CvColor::White, CvColor::Black, 2,
|
103
|
+
# :thickness => 1, :line_type => :aa)
|
104
|
+
# end while (contours = contours.h_next)
|
105
|
+
# snap dst
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|