ruby-opencv 0.0.8.pre-x86-mingw32

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