ruby-opencv 0.0.8.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. data/Gemfile +8 -0
  2. data/History.txt +5 -0
  3. data/License.txt +30 -0
  4. data/Manifest.txt +229 -0
  5. data/README.rdoc +149 -0
  6. data/Rakefile +32 -0
  7. data/examples/alpha_blend.rb +21 -0
  8. data/examples/box.png +0 -0
  9. data/examples/box_in_scene.png +0 -0
  10. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  11. data/examples/contours/bitmap-contours.png +0 -0
  12. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  13. data/examples/contours/contour_retrieval_modes.rb +139 -0
  14. data/examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg +0 -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/GPATH +0 -0
  36. data/ext/opencv/GSYMS +0 -0
  37. data/ext/opencv/curve.cpp +112 -0
  38. data/ext/opencv/curve.h +34 -0
  39. data/ext/opencv/cvavgcomp.cpp +67 -0
  40. data/ext/opencv/cvavgcomp.h +39 -0
  41. data/ext/opencv/cvbox2d.cpp +197 -0
  42. data/ext/opencv/cvbox2d.h +61 -0
  43. data/ext/opencv/cvcapture.cpp +499 -0
  44. data/ext/opencv/cvcapture.h +72 -0
  45. data/ext/opencv/cvchain.cpp +233 -0
  46. data/ext/opencv/cvchain.h +46 -0
  47. data/ext/opencv/cvcircle32f.cpp +116 -0
  48. data/ext/opencv/cvcircle32f.h +52 -0
  49. data/ext/opencv/cvcondensation.cpp +282 -0
  50. data/ext/opencv/cvcondensation.h +49 -0
  51. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  52. data/ext/opencv/cvconnectedcomp.h +49 -0
  53. data/ext/opencv/cvcontour.cpp +296 -0
  54. data/ext/opencv/cvcontour.h +48 -0
  55. data/ext/opencv/cvcontourtree.cpp +91 -0
  56. data/ext/opencv/cvcontourtree.h +41 -0
  57. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  58. data/ext/opencv/cvconvexitydefect.h +42 -0
  59. data/ext/opencv/cverror.cpp +159 -0
  60. data/ext/opencv/cverror.h +28 -0
  61. data/ext/opencv/cvfeaturetree.cpp +125 -0
  62. data/ext/opencv/cvfeaturetree.h +55 -0
  63. data/ext/opencv/cvfont.cpp +208 -0
  64. data/ext/opencv/cvfont.h +64 -0
  65. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  66. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  67. data/ext/opencv/cvhistogram.cpp +546 -0
  68. data/ext/opencv/cvhistogram.h +73 -0
  69. data/ext/opencv/cvhumoments.cpp +139 -0
  70. data/ext/opencv/cvhumoments.h +51 -0
  71. data/ext/opencv/cvline.cpp +154 -0
  72. data/ext/opencv/cvline.h +54 -0
  73. data/ext/opencv/cvmat.cpp +5848 -0
  74. data/ext/opencv/cvmat.h +284 -0
  75. data/ext/opencv/cvmatnd.cpp +44 -0
  76. data/ext/opencv/cvmatnd.h +28 -0
  77. data/ext/opencv/cvmemstorage.cpp +68 -0
  78. data/ext/opencv/cvmemstorage.h +53 -0
  79. data/ext/opencv/cvmoments.cpp +287 -0
  80. data/ext/opencv/cvmoments.h +75 -0
  81. data/ext/opencv/cvpoint.cpp +228 -0
  82. data/ext/opencv/cvpoint.h +64 -0
  83. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  84. data/ext/opencv/cvpoint2d32f.h +63 -0
  85. data/ext/opencv/cvpoint3d32f.cpp +245 -0
  86. data/ext/opencv/cvpoint3d32f.h +66 -0
  87. data/ext/opencv/cvrect.cpp +333 -0
  88. data/ext/opencv/cvrect.h +79 -0
  89. data/ext/opencv/cvscalar.cpp +236 -0
  90. data/ext/opencv/cvscalar.h +71 -0
  91. data/ext/opencv/cvseq.cpp +599 -0
  92. data/ext/opencv/cvseq.h +74 -0
  93. data/ext/opencv/cvsize.cpp +221 -0
  94. data/ext/opencv/cvsize.h +65 -0
  95. data/ext/opencv/cvsize2d32f.cpp +209 -0
  96. data/ext/opencv/cvsize2d32f.h +64 -0
  97. data/ext/opencv/cvslice.cpp +120 -0
  98. data/ext/opencv/cvslice.h +61 -0
  99. data/ext/opencv/cvsparsemat.cpp +44 -0
  100. data/ext/opencv/cvsparsemat.h +28 -0
  101. data/ext/opencv/cvsurfparams.cpp +199 -0
  102. data/ext/opencv/cvsurfparams.h +58 -0
  103. data/ext/opencv/cvsurfpoint.cpp +223 -0
  104. data/ext/opencv/cvsurfpoint.h +52 -0
  105. data/ext/opencv/cvtermcriteria.cpp +192 -0
  106. data/ext/opencv/cvtermcriteria.h +71 -0
  107. data/ext/opencv/cvtwopoints.cpp +116 -0
  108. data/ext/opencv/cvtwopoints.h +51 -0
  109. data/ext/opencv/cvutils.cpp +194 -0
  110. data/ext/opencv/cvutils.h +29 -0
  111. data/ext/opencv/cvvideowriter.cpp +137 -0
  112. data/ext/opencv/cvvideowriter.h +43 -0
  113. data/ext/opencv/gui.cpp +68 -0
  114. data/ext/opencv/gui.h +30 -0
  115. data/ext/opencv/iplconvkernel.cpp +192 -0
  116. data/ext/opencv/iplconvkernel.h +71 -0
  117. data/ext/opencv/iplimage.cpp +644 -0
  118. data/ext/opencv/iplimage.h +73 -0
  119. data/ext/opencv/lib/opencv.rb +3 -0
  120. data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
  121. data/ext/opencv/lib/opencv/version.rb +3 -0
  122. data/ext/opencv/mouseevent.cpp +181 -0
  123. data/ext/opencv/mouseevent.h +56 -0
  124. data/ext/opencv/opencv.cpp +722 -0
  125. data/ext/opencv/opencv.h +400 -0
  126. data/ext/opencv/pointset.cpp +274 -0
  127. data/ext/opencv/pointset.h +68 -0
  128. data/ext/opencv/trackbar.cpp +121 -0
  129. data/ext/opencv/trackbar.h +69 -0
  130. data/ext/opencv/window.cpp +357 -0
  131. data/ext/opencv/window.h +66 -0
  132. data/extconf.rb +75 -0
  133. data/images/CvMat_sobel.png +0 -0
  134. data/images/CvMat_sub_rect.png +0 -0
  135. data/images/CvSeq_relationmap.png +0 -0
  136. data/images/face_detect_from_lena.jpg +0 -0
  137. data/ruby-opencv.gemspec +43 -0
  138. data/test/helper.rb +166 -0
  139. data/test/log.txt +55 -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. data/test/videowriter_result.avi +0 -0
  230. metadata +394 -0
@@ -0,0 +1,126 @@
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::PointSet
10
+ class TestPointSet < OpenCVTestCase
11
+ def setup
12
+ mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i|
13
+ (j - 64) ** 2 + (i - 64) ** 2 <= (32 ** 2) ? CvColor::White : CvColor::Black
14
+ }
15
+ @contour1 = mat0.find_contours
16
+ @contour2 = CvContour.new
17
+ end
18
+
19
+ def test_contour_area
20
+ assert_equal(3118, @contour1.contour_area.to_i)
21
+
22
+ s = CvSlice.new(0, @contour1.size / 2)
23
+ assert_equal(1527, @contour1.contour_area(s).to_i)
24
+
25
+ assert_raise(TypeError) {
26
+ @contour1.contour_area(DUMMY_OBJ)
27
+ }
28
+ assert_raise(CvStsBadArg) {
29
+ @contour2.contour_area
30
+ }
31
+ end
32
+
33
+ def test_fit_ellipse2
34
+ box = @contour1.fit_ellipse2
35
+
36
+ center = box.center
37
+ assert_equal(64, center.x.to_i)
38
+ assert_equal(64, center.y.to_i)
39
+
40
+ size = box.size
41
+ assert_in_delta(63.116, size.width, 0.001)
42
+ assert_in_delta(63.116, size.height, 0.001)
43
+ assert_in_delta(180, box.angle, 0.001)
44
+
45
+ assert_raise(CvStsBadArg) {
46
+ @contour2.fit_ellipse2
47
+ }
48
+ end
49
+
50
+ def test_convex_hull2
51
+ [@contour1.convex_hull2, @contour1.convex_hull2(true)].each { |hull|
52
+ assert_equal(36, hull.size)
53
+ assert_equal(CvContour, hull.class)
54
+ assert_equal(CvPoint, hull[0].class)
55
+ assert_equal(32, hull[0].x)
56
+ assert_equal(64, hull[0].y)
57
+ }
58
+
59
+ hull = @contour1.convex_hull2(false)
60
+ assert_equal(36, hull.size)
61
+ assert_equal(CvContour, hull.class)
62
+ assert_equal(CvPoint, hull[0].class)
63
+ assert_equal(96, hull[0].x)
64
+ assert_equal(64, hull[0].y)
65
+
66
+ @contour1.convex_hull2(DUMMY_OBJ)
67
+ end
68
+
69
+ def test_check_contour_convexity
70
+ assert_false(@contour1.check_contour_convexity)
71
+ end
72
+
73
+ def test_convexity_defects
74
+ hull = @contour1.convex_hull2(true, false)
75
+ defects = @contour1.convexity_defects(hull)
76
+ assert_equal(CvSeq, defects.class)
77
+ assert_equal(CvConvexityDefect, defects[0].class)
78
+ assert_equal(32, defects.size)
79
+
80
+ d = defects[0]
81
+ assert_equal(33, d.start.x)
82
+ assert_equal(57, d.start.y)
83
+ assert_equal(33, d.depth_point.x)
84
+ assert_equal(63, d.depth_point.y)
85
+ assert_equal(32, d.end.x)
86
+ assert_equal(64, d.end.y)
87
+ assert_in_delta(0.8485, d.depth, 0.001)
88
+
89
+ assert_raise(TypeError) {
90
+ @contour1.convexity_defects(DUMMY_OBJ)
91
+ }
92
+ end
93
+
94
+ def test_min_area_rect2
95
+ box = @contour1.min_area_rect2
96
+
97
+ assert_equal(CvBox2D, box.class)
98
+ center = box.center
99
+ assert_equal(64, center.x.to_i)
100
+ assert_equal(64, center.y.to_i)
101
+
102
+ size = box.size
103
+ assert_in_delta(63.356, size.width, 0.001)
104
+ assert_in_delta(63.356, size.height, 0.001)
105
+ assert_in_delta(-8.130, box.angle, 0.001)
106
+
107
+ flunk('FIXME: Currently PointSet#min_area_rect2 causes segmentation fault when "self" is invalid.')
108
+ assert_raise(CvStsBadSize) {
109
+ @contour2.min_area_rect2
110
+ }
111
+ end
112
+
113
+ def test_min_enclosing_circle
114
+ circle = @contour1.min_enclosing_circle
115
+ assert_equal(CvCircle32f, circle.class)
116
+ center = circle.center
117
+ assert_equal(64, center.x.to_i)
118
+ assert_equal(64, center.y.to_i)
119
+ assert_in_delta(32.959, circle.radius, 0.001)
120
+
121
+ assert_raise(CvStsBadSize) {
122
+ @contour2.min_enclosing_circle
123
+ }
124
+ end
125
+ end
126
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
Binary file
metadata ADDED
@@ -0,0 +1,394 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-opencv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - lsxi
9
+ - ser1zw
10
+ - pcting
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-01-26 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rdoc
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: '3.10'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '3.10'
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake-compiler
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: hoe-gemspec
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: hoe
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '3.5'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '3.5'
80
+ description: OpenCV wrapper for Ruby
81
+ email:
82
+ - masakazu.yonekura@gmail.com
83
+ - azariahsawtikes@gmail.com
84
+ - pcting@gmail.com
85
+ executables: []
86
+ extensions:
87
+ - extconf.rb
88
+ extra_rdoc_files:
89
+ - History.txt
90
+ - License.txt
91
+ - Manifest.txt
92
+ - README.rdoc
93
+ - examples/matching_to_many_images/train/trainImages.txt
94
+ files:
95
+ - Gemfile
96
+ - History.txt
97
+ - License.txt
98
+ - Manifest.txt
99
+ - README.rdoc
100
+ - Rakefile
101
+ - examples/alpha_blend.rb
102
+ - examples/box.png
103
+ - examples/box_in_scene.png
104
+ - examples/contours/bitmap-contours-with-labels.png
105
+ - examples/contours/bitmap-contours.png
106
+ - examples/contours/bounding-box-detect-canny.rb
107
+ - examples/contours/contour_retrieval_modes.rb
108
+ - examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg
109
+ - examples/contours/rotated-boxes.jpg
110
+ - examples/convexhull.rb
111
+ - examples/face_detect.rb
112
+ - examples/find_obj.rb
113
+ - examples/houghcircle.rb
114
+ - examples/inpaint.png
115
+ - examples/inpaint.rb
116
+ - examples/lenna-rotated.jpg
117
+ - examples/lenna.jpg
118
+ - examples/match_kdtree.rb
119
+ - examples/matching_to_many_images.rb
120
+ - examples/matching_to_many_images/query.png
121
+ - examples/matching_to_many_images/train/1.png
122
+ - examples/matching_to_many_images/train/2.png
123
+ - examples/matching_to_many_images/train/3.png
124
+ - examples/matching_to_many_images/train/trainImages.txt
125
+ - examples/paint.rb
126
+ - examples/snake.rb
127
+ - examples/stuff.jpg
128
+ - examples/tiffany.jpg
129
+ - ext/opencv/GPATH
130
+ - ext/opencv/GSYMS
131
+ - ext/opencv/curve.cpp
132
+ - ext/opencv/curve.h
133
+ - ext/opencv/cvavgcomp.cpp
134
+ - ext/opencv/cvavgcomp.h
135
+ - ext/opencv/cvbox2d.cpp
136
+ - ext/opencv/cvbox2d.h
137
+ - ext/opencv/cvcapture.cpp
138
+ - ext/opencv/cvcapture.h
139
+ - ext/opencv/cvchain.cpp
140
+ - ext/opencv/cvchain.h
141
+ - ext/opencv/cvcircle32f.cpp
142
+ - ext/opencv/cvcircle32f.h
143
+ - ext/opencv/cvcondensation.cpp
144
+ - ext/opencv/cvcondensation.h
145
+ - ext/opencv/cvconnectedcomp.cpp
146
+ - ext/opencv/cvconnectedcomp.h
147
+ - ext/opencv/cvcontour.cpp
148
+ - ext/opencv/cvcontour.h
149
+ - ext/opencv/cvcontourtree.cpp
150
+ - ext/opencv/cvcontourtree.h
151
+ - ext/opencv/cvconvexitydefect.cpp
152
+ - ext/opencv/cvconvexitydefect.h
153
+ - ext/opencv/cverror.cpp
154
+ - ext/opencv/cverror.h
155
+ - ext/opencv/cvfeaturetree.cpp
156
+ - ext/opencv/cvfeaturetree.h
157
+ - ext/opencv/cvfont.cpp
158
+ - ext/opencv/cvfont.h
159
+ - ext/opencv/cvhaarclassifiercascade.cpp
160
+ - ext/opencv/cvhaarclassifiercascade.h
161
+ - ext/opencv/cvhistogram.cpp
162
+ - ext/opencv/cvhistogram.h
163
+ - ext/opencv/cvhumoments.cpp
164
+ - ext/opencv/cvhumoments.h
165
+ - ext/opencv/cvline.cpp
166
+ - ext/opencv/cvline.h
167
+ - ext/opencv/cvmat.cpp
168
+ - ext/opencv/cvmat.h
169
+ - ext/opencv/cvmatnd.cpp
170
+ - ext/opencv/cvmatnd.h
171
+ - ext/opencv/cvmemstorage.cpp
172
+ - ext/opencv/cvmemstorage.h
173
+ - ext/opencv/cvmoments.cpp
174
+ - ext/opencv/cvmoments.h
175
+ - ext/opencv/cvpoint.cpp
176
+ - ext/opencv/cvpoint.h
177
+ - ext/opencv/cvpoint2d32f.cpp
178
+ - ext/opencv/cvpoint2d32f.h
179
+ - ext/opencv/cvpoint3d32f.cpp
180
+ - ext/opencv/cvpoint3d32f.h
181
+ - ext/opencv/cvrect.cpp
182
+ - ext/opencv/cvrect.h
183
+ - ext/opencv/cvscalar.cpp
184
+ - ext/opencv/cvscalar.h
185
+ - ext/opencv/cvseq.cpp
186
+ - ext/opencv/cvseq.h
187
+ - ext/opencv/cvsize.cpp
188
+ - ext/opencv/cvsize.h
189
+ - ext/opencv/cvsize2d32f.cpp
190
+ - ext/opencv/cvsize2d32f.h
191
+ - ext/opencv/cvslice.cpp
192
+ - ext/opencv/cvslice.h
193
+ - ext/opencv/cvsparsemat.cpp
194
+ - ext/opencv/cvsparsemat.h
195
+ - ext/opencv/cvsurfparams.cpp
196
+ - ext/opencv/cvsurfparams.h
197
+ - ext/opencv/cvsurfpoint.cpp
198
+ - ext/opencv/cvsurfpoint.h
199
+ - ext/opencv/cvtermcriteria.cpp
200
+ - ext/opencv/cvtermcriteria.h
201
+ - ext/opencv/cvtwopoints.cpp
202
+ - ext/opencv/cvtwopoints.h
203
+ - ext/opencv/cvutils.cpp
204
+ - ext/opencv/cvutils.h
205
+ - ext/opencv/cvvideowriter.cpp
206
+ - ext/opencv/cvvideowriter.h
207
+ - ext/opencv/gui.cpp
208
+ - ext/opencv/gui.h
209
+ - ext/opencv/iplconvkernel.cpp
210
+ - ext/opencv/iplconvkernel.h
211
+ - ext/opencv/iplimage.cpp
212
+ - ext/opencv/iplimage.h
213
+ - ext/opencv/lib/opencv.rb
214
+ - ext/opencv/lib/opencv/psyched_yaml.rb
215
+ - ext/opencv/lib/opencv/version.rb
216
+ - ext/opencv/mouseevent.cpp
217
+ - ext/opencv/mouseevent.h
218
+ - ext/opencv/opencv.cpp
219
+ - ext/opencv/opencv.h
220
+ - ext/opencv/pointset.cpp
221
+ - ext/opencv/pointset.h
222
+ - ext/opencv/trackbar.cpp
223
+ - ext/opencv/trackbar.h
224
+ - ext/opencv/window.cpp
225
+ - ext/opencv/window.h
226
+ - extconf.rb
227
+ - images/CvMat_sobel.png
228
+ - images/CvMat_sub_rect.png
229
+ - images/CvSeq_relationmap.png
230
+ - images/face_detect_from_lena.jpg
231
+ - ruby-opencv.gemspec
232
+ - test/helper.rb
233
+ - test/log.txt
234
+ - test/runner.rb
235
+ - test/samples/airplane.jpg
236
+ - test/samples/baboon.jpg
237
+ - test/samples/baboon200.jpg
238
+ - test/samples/baboon200_rotated.jpg
239
+ - test/samples/blank0.jpg
240
+ - test/samples/blank1.jpg
241
+ - test/samples/blank2.jpg
242
+ - test/samples/blank3.jpg
243
+ - test/samples/blank4.jpg
244
+ - test/samples/blank5.jpg
245
+ - test/samples/blank6.jpg
246
+ - test/samples/blank7.jpg
247
+ - test/samples/blank8.jpg
248
+ - test/samples/blank9.jpg
249
+ - test/samples/cat.jpg
250
+ - test/samples/chessboard.jpg
251
+ - test/samples/contours.jpg
252
+ - test/samples/fruits.jpg
253
+ - test/samples/haarcascade_frontalface_alt.xml.gz
254
+ - test/samples/inpaint-mask.bmp
255
+ - test/samples/lena-256x256.jpg
256
+ - test/samples/lena-32x32.jpg
257
+ - test/samples/lena-eyes.jpg
258
+ - test/samples/lena-inpaint.jpg
259
+ - test/samples/lena.jpg
260
+ - test/samples/lines.jpg
261
+ - test/samples/messy0.jpg
262
+ - test/samples/messy1.jpg
263
+ - test/samples/movie_sample.avi
264
+ - test/samples/one_way_train_0000.jpg
265
+ - test/samples/one_way_train_0001.jpg
266
+ - test/samples/partially_blank0.jpg
267
+ - test/samples/partially_blank1.jpg
268
+ - test/samples/smooth0.jpg
269
+ - test/samples/smooth1.jpg
270
+ - test/samples/smooth2.jpg
271
+ - test/samples/smooth3.jpg
272
+ - test/samples/smooth4.jpg
273
+ - test/samples/smooth5.jpg
274
+ - test/samples/smooth6.jpg
275
+ - test/samples/str-cv-rotated.jpg
276
+ - test/samples/str-cv.jpg
277
+ - test/samples/str-ov.jpg
278
+ - test/samples/stuff.jpg
279
+ - test/test_curve.rb
280
+ - test/test_cvavgcomp.rb
281
+ - test/test_cvbox2d.rb
282
+ - test/test_cvcapture.rb
283
+ - test/test_cvchain.rb
284
+ - test/test_cvcircle32f.rb
285
+ - test/test_cvconnectedcomp.rb
286
+ - test/test_cvcontour.rb
287
+ - test/test_cvcontourtree.rb
288
+ - test/test_cverror.rb
289
+ - test/test_cvfeaturetree.rb
290
+ - test/test_cvfont.rb
291
+ - test/test_cvhaarclassifiercascade.rb
292
+ - test/test_cvhistogram.rb
293
+ - test/test_cvhumoments.rb
294
+ - test/test_cvline.rb
295
+ - test/test_cvmat.rb
296
+ - test/test_cvmat_drawing.rb
297
+ - test/test_cvmat_dxt.rb
298
+ - test/test_cvmat_imageprocessing.rb
299
+ - test/test_cvmat_matching.rb
300
+ - test/test_cvmoments.rb
301
+ - test/test_cvpoint.rb
302
+ - test/test_cvpoint2d32f.rb
303
+ - test/test_cvpoint3d32f.rb
304
+ - test/test_cvrect.rb
305
+ - test/test_cvscalar.rb
306
+ - test/test_cvseq.rb
307
+ - test/test_cvsize.rb
308
+ - test/test_cvsize2d32f.rb
309
+ - test/test_cvslice.rb
310
+ - test/test_cvsurfparams.rb
311
+ - test/test_cvsurfpoint.rb
312
+ - test/test_cvtermcriteria.rb
313
+ - test/test_cvtwopoints.rb
314
+ - test/test_cvvideowriter.rb
315
+ - test/test_iplconvkernel.rb
316
+ - test/test_iplimage.rb
317
+ - test/test_mouseevent.rb
318
+ - test/test_opencv.rb
319
+ - test/test_pointset.rb
320
+ - test/test_preliminary.rb
321
+ - test/test_trackbar.rb
322
+ - test/test_window.rb
323
+ - test/videowriter_result.avi
324
+ homepage: https://github.com/ruby-opencv/ruby-opencv/
325
+ licenses: []
326
+ post_install_message:
327
+ rdoc_options:
328
+ - --main
329
+ - README.rdoc
330
+ require_paths:
331
+ - lib
332
+ required_ruby_version: !ruby/object:Gem::Requirement
333
+ none: false
334
+ requirements:
335
+ - - ! '>='
336
+ - !ruby/object:Gem::Version
337
+ version: '0'
338
+ required_rubygems_version: !ruby/object:Gem::Requirement
339
+ none: false
340
+ requirements:
341
+ - - ! '>'
342
+ - !ruby/object:Gem::Version
343
+ version: 1.3.1
344
+ requirements: []
345
+ rubyforge_project: ruby-opencv
346
+ rubygems_version: 1.8.24
347
+ signing_key:
348
+ specification_version: 3
349
+ summary: OpenCV wrapper for Ruby
350
+ test_files:
351
+ - test/test_cvcontourtree.rb
352
+ - test/test_iplconvkernel.rb
353
+ - test/test_cvsize2d32f.rb
354
+ - test/test_cvconnectedcomp.rb
355
+ - test/test_cvcontour.rb
356
+ - test/test_cvslice.rb
357
+ - test/test_cvmat_matching.rb
358
+ - test/test_trackbar.rb
359
+ - test/test_cvpoint3d32f.rb
360
+ - test/test_cvpoint2d32f.rb
361
+ - test/test_cvcapture.rb
362
+ - test/test_cvfont.rb
363
+ - test/test_cvhumoments.rb
364
+ - test/test_cvmat_dxt.rb
365
+ - test/test_cvbox2d.rb
366
+ - test/test_iplimage.rb
367
+ - test/test_preliminary.rb
368
+ - test/test_cvmat_drawing.rb
369
+ - test/test_cvsurfparams.rb
370
+ - test/test_cvcircle32f.rb
371
+ - test/test_pointset.rb
372
+ - test/test_cvmat.rb
373
+ - test/test_cvhistogram.rb
374
+ - test/test_cverror.rb
375
+ - test/test_cvtermcriteria.rb
376
+ - test/test_cvmoments.rb
377
+ - test/test_cvchain.rb
378
+ - test/test_cvpoint.rb
379
+ - test/test_cvavgcomp.rb
380
+ - test/test_cvrect.rb
381
+ - test/test_cvvideowriter.rb
382
+ - test/test_curve.rb
383
+ - test/test_window.rb
384
+ - test/test_cvline.rb
385
+ - test/test_opencv.rb
386
+ - test/test_cvfeaturetree.rb
387
+ - test/test_cvseq.rb
388
+ - test/test_cvsize.rb
389
+ - test/test_mouseevent.rb
390
+ - test/test_cvmat_imageprocessing.rb
391
+ - test/test_cvtwopoints.rb
392
+ - test/test_cvscalar.rb
393
+ - test/test_cvsurfpoint.rb
394
+ - test/test_cvhaarclassifiercascade.rb