ruby-opencv 0.0.9-x86-mswin32

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