ruby-opencv 0.0.10-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +26 -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 +727 -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/1.9/opencv.so +0 -0
  136. data/lib/2.0/opencv.so +0 -0
  137. data/lib/opencv.rb +12 -0
  138. data/lib/opencv/psyched_yaml.rb +22 -0
  139. data/lib/opencv/version.rb +3 -0
  140. data/ruby-opencv.gemspec +44 -0
  141. data/test/helper.rb +166 -0
  142. data/test/runner.rb +30 -0
  143. data/test/samples/airplane.jpg +0 -0
  144. data/test/samples/baboon.jpg +0 -0
  145. data/test/samples/baboon200.jpg +0 -0
  146. data/test/samples/baboon200_rotated.jpg +0 -0
  147. data/test/samples/blank0.jpg +0 -0
  148. data/test/samples/blank1.jpg +0 -0
  149. data/test/samples/blank2.jpg +0 -0
  150. data/test/samples/blank3.jpg +0 -0
  151. data/test/samples/blank4.jpg +0 -0
  152. data/test/samples/blank5.jpg +0 -0
  153. data/test/samples/blank6.jpg +0 -0
  154. data/test/samples/blank7.jpg +0 -0
  155. data/test/samples/blank8.jpg +0 -0
  156. data/test/samples/blank9.jpg +0 -0
  157. data/test/samples/cat.jpg +0 -0
  158. data/test/samples/chessboard.jpg +0 -0
  159. data/test/samples/contours.jpg +0 -0
  160. data/test/samples/fruits.jpg +0 -0
  161. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  162. data/test/samples/inpaint-mask.bmp +0 -0
  163. data/test/samples/lena-256x256.jpg +0 -0
  164. data/test/samples/lena-32x32.jpg +0 -0
  165. data/test/samples/lena-eyes.jpg +0 -0
  166. data/test/samples/lena-inpaint.jpg +0 -0
  167. data/test/samples/lena.jpg +0 -0
  168. data/test/samples/lines.jpg +0 -0
  169. data/test/samples/messy0.jpg +0 -0
  170. data/test/samples/messy1.jpg +0 -0
  171. data/test/samples/movie_sample.avi +0 -0
  172. data/test/samples/one_way_train_0000.jpg +0 -0
  173. data/test/samples/one_way_train_0001.jpg +0 -0
  174. data/test/samples/partially_blank0.jpg +0 -0
  175. data/test/samples/partially_blank1.jpg +0 -0
  176. data/test/samples/smooth0.jpg +0 -0
  177. data/test/samples/smooth1.jpg +0 -0
  178. data/test/samples/smooth2.jpg +0 -0
  179. data/test/samples/smooth3.jpg +0 -0
  180. data/test/samples/smooth4.jpg +0 -0
  181. data/test/samples/smooth5.jpg +0 -0
  182. data/test/samples/smooth6.jpg +0 -0
  183. data/test/samples/str-cv-rotated.jpg +0 -0
  184. data/test/samples/str-cv.jpg +0 -0
  185. data/test/samples/str-ov.jpg +0 -0
  186. data/test/samples/stuff.jpg +0 -0
  187. data/test/test_curve.rb +43 -0
  188. data/test/test_cvavgcomp.rb +24 -0
  189. data/test/test_cvbox2d.rb +76 -0
  190. data/test/test_cvcapture.rb +183 -0
  191. data/test/test_cvchain.rb +108 -0
  192. data/test/test_cvcircle32f.rb +41 -0
  193. data/test/test_cvconnectedcomp.rb +61 -0
  194. data/test/test_cvcontour.rb +150 -0
  195. data/test/test_cvcontourtree.rb +43 -0
  196. data/test/test_cverror.rb +50 -0
  197. data/test/test_cvfeaturetree.rb +65 -0
  198. data/test/test_cvfont.rb +58 -0
  199. data/test/test_cvhaarclassifiercascade.rb +63 -0
  200. data/test/test_cvhistogram.rb +271 -0
  201. data/test/test_cvhumoments.rb +83 -0
  202. data/test/test_cvline.rb +50 -0
  203. data/test/test_cvmat.rb +2947 -0
  204. data/test/test_cvmat_drawing.rb +349 -0
  205. data/test/test_cvmat_dxt.rb +150 -0
  206. data/test/test_cvmat_imageprocessing.rb +2015 -0
  207. data/test/test_cvmat_matching.rb +57 -0
  208. data/test/test_cvmoments.rb +180 -0
  209. data/test/test_cvpoint.rb +75 -0
  210. data/test/test_cvpoint2d32f.rb +75 -0
  211. data/test/test_cvpoint3d32f.rb +93 -0
  212. data/test/test_cvrect.rb +144 -0
  213. data/test/test_cvscalar.rb +113 -0
  214. data/test/test_cvseq.rb +295 -0
  215. data/test/test_cvsize.rb +75 -0
  216. data/test/test_cvsize2d32f.rb +75 -0
  217. data/test/test_cvslice.rb +31 -0
  218. data/test/test_cvsurfparams.rb +57 -0
  219. data/test/test_cvsurfpoint.rb +66 -0
  220. data/test/test_cvtermcriteria.rb +56 -0
  221. data/test/test_cvtwopoints.rb +40 -0
  222. data/test/test_cvvideowriter.rb +58 -0
  223. data/test/test_iplconvkernel.rb +54 -0
  224. data/test/test_iplimage.rb +236 -0
  225. data/test/test_mouseevent.rb +17 -0
  226. data/test/test_opencv.rb +329 -0
  227. data/test/test_pointset.rb +126 -0
  228. data/test/test_preliminary.rb +130 -0
  229. data/test/test_trackbar.rb +47 -0
  230. data/test/test_window.rb +115 -0
  231. metadata +386 -0
@@ -0,0 +1,57 @@
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 matching functions of OpenCV::CvMat
10
+ class TestCvMat_matching < OpenCVTestCase
11
+ def setup
12
+ @query = read_test_image('query.png')
13
+ @images = ['1.png', '2.png', '3.png'].map{|f| read_test_image('train', f)}
14
+ end
15
+
16
+ def data_dir
17
+ File.join(File.dirname(__FILE__), '..', 'examples', 'matching_to_many_images')
18
+ end
19
+
20
+ def read_test_image(*path)
21
+ IplImage.load File.join(data_dir, *path), CV_LOAD_IMAGE_GRAYSCALE
22
+ end
23
+
24
+ def test_match_descriptors
25
+ matchs = @query.match_descriptors(@images)
26
+ match_index, count = matchs.max_by {|image_index, count| count}
27
+ assert_equal 2, match_index
28
+ end
29
+
30
+ def test_match_descriptors_with_empty_image_array
31
+ assert_equal({}, @query.match_descriptors([]))
32
+ end
33
+
34
+ def test_match_descriptors_with_wrong_detector_type_argument
35
+ assert_raise ArgumentError do
36
+ @query.match_descriptors(@images, "Wrong")
37
+ end
38
+ end
39
+
40
+ def test_match_descriptors_with_wrong_descriptor_type_argument
41
+ assert_raise ArgumentError do
42
+ @query.match_descriptors(@images, "SURF", "wrong")
43
+ end
44
+ end
45
+
46
+ def test_match_descriptors_with_wrong_matcher_type_argument
47
+ assert_raise ArgumentError do
48
+ @query.match_descriptors(@images, "SURF", "SURF", "wrong")
49
+ end
50
+ end
51
+
52
+ def test_match_descriptors_with_invalid_image_array
53
+ assert_raise TypeError do
54
+ @query.match_descriptors([DUMMY_OBJ, DUMMY_OBJ])
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,180 @@
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::CvMoment
10
+ class TestCvMoments < OpenCVTestCase
11
+ def setup
12
+ @mat = create_cvmat(128, 128, :cv8u, 1) { |j, i|
13
+ if j >= 32 and j < 96 and i >= 16 and i < 112
14
+ CvScalar.new(0)
15
+ elsif j >= 16 and j < 112 and i >= 16 and i < 112
16
+ CvScalar.new(128)
17
+ else
18
+ CvScalar.new(255)
19
+ end
20
+ }
21
+ @moment1 = CvMoments.new
22
+ @moment2 = CvMoments.new(nil, true)
23
+ @moment3 = CvMoments.new(@mat)
24
+ @moment4 = CvMoments.new(@mat, true)
25
+ end
26
+
27
+ def test_initialize
28
+ [@moment1, @moment2, @moment3, @moment4].each { |m|
29
+ assert_not_nil(m)
30
+ assert_equal(CvMoments, m.class)
31
+ }
32
+
33
+ assert_raise(TypeError) {
34
+ CvMoments.new('foo')
35
+ }
36
+ end
37
+
38
+ def test_spatial
39
+ assert_in_delta(0, @moment1.spatial(0, 0), 0.1)
40
+ assert_in_delta(0, @moment2.spatial(0, 0), 0.1)
41
+ assert_in_delta(2221056, @moment3.spatial(0, 0), 0.1)
42
+ assert_in_delta(10240, @moment4.spatial(0, 0), 0.1)
43
+ end
44
+
45
+ def test_central
46
+ assert_in_delta(0, @moment1.central(0, 0), 0.1)
47
+ assert_in_delta(0, @moment2.central(0, 0), 0.1)
48
+ assert_in_delta(2221056, @moment3.central(0, 0), 0.1)
49
+ assert_in_delta(10240, @moment4.central(0, 0), 0.1)
50
+ end
51
+
52
+ def test_normalized_central
53
+ assert_in_delta(0, @moment1.normalized_central(0, 0), 0.1)
54
+ assert_in_delta(0, @moment2.normalized_central(0, 0), 0.1)
55
+ assert_in_delta(1, @moment3.normalized_central(0, 0), 0.1)
56
+ assert_in_delta(1, @moment4.normalized_central(0, 0), 0.1)
57
+ end
58
+
59
+ def test_hu
60
+ hu_moments = @moment1.hu
61
+ assert_equal(CvHuMoments, hu_moments.class)
62
+ hu_moments.to_a.each { |hu|
63
+ assert_in_delta(0.0, hu, 0.000001)
64
+ }
65
+
66
+ hu_moments = @moment2.hu
67
+ assert_equal(CvHuMoments, hu_moments.class)
68
+ hu_moments.to_a.each { |hu|
69
+ assert_in_delta(0.0, hu, 0.000001)
70
+ }
71
+
72
+ hu_moments = @moment3.hu
73
+ assert_equal(CvHuMoments, hu_moments.class)
74
+ assert_in_delta(0.001771, hu_moments.hu1, 0.000001)
75
+ hu_moments.to_a[1..7].each { |hu|
76
+ assert_in_delta(0.0, hu, 0.000001)
77
+ }
78
+
79
+ hu_moments = @moment4.hu
80
+ assert_equal(CvHuMoments, hu_moments.class)
81
+ assert_in_delta(0.361650, hu_moments.hu1, 0.000001)
82
+ assert_in_delta(0.000625, hu_moments.hu2, 0.000001)
83
+ hu_moments.to_a[2..7].each { |hu|
84
+ assert_in_delta(0.0, hu, 0.000001)
85
+ }
86
+ end
87
+
88
+ def test_gravity_center
89
+ center = @moment1.gravity_center
90
+ assert_equal(CvPoint2D32f, center.class)
91
+ assert(center.x.nan?)
92
+ assert(center.y.nan?)
93
+
94
+ center = @moment2.gravity_center
95
+ assert_equal(CvPoint2D32f, center.class)
96
+ assert(center.x.nan?)
97
+ assert(center.y.nan?)
98
+
99
+ center = @moment3.gravity_center
100
+ assert_equal(CvPoint2D32f, center.class)
101
+ assert_in_delta(63.5, center.x, 0.001)
102
+ assert_in_delta(63.5, center.y, 0.001)
103
+
104
+ center = @moment4.gravity_center
105
+ assert_equal(CvPoint2D32f, center.class)
106
+ assert_in_delta(63.5, center.x, 0.001)
107
+ assert_in_delta(63.5, center.y, 0.001)
108
+ end
109
+
110
+ def test_angle
111
+ [@moment1, @moment2].each { |m|
112
+ assert_nil(m.angle)
113
+ }
114
+ [@moment3, @moment4].each { |m|
115
+ assert_in_delta(0, m.angle, 0.001)
116
+ }
117
+ end
118
+
119
+ def test_mXX
120
+ [@moment1, @moment2].each { |m|
121
+ assert_in_delta(0, m.m00, 0.001)
122
+ assert_in_delta(0, m.m10, 0.001)
123
+ assert_in_delta(0, m.m01, 0.001)
124
+ assert_in_delta(0, m.m20, 0.001)
125
+ assert_in_delta(0, m.m11, 0.001)
126
+ assert_in_delta(0, m.m02, 0.001)
127
+ assert_in_delta(0, m.m30, 0.001)
128
+ assert_in_delta(0, m.m21, 0.001)
129
+ assert_in_delta(0, m.m12, 0.001)
130
+ assert_in_delta(0, m.m03, 0.001)
131
+ assert_in_delta(0, m.mu20, 0.001)
132
+ assert_in_delta(0, m.mu11, 0.001)
133
+ assert_in_delta(0, m.mu02, 0.001)
134
+ assert_in_delta(0, m.mu30, 0.001)
135
+ assert_in_delta(0, m.mu21, 0.001)
136
+ assert_in_delta(0, m.mu12, 0.001)
137
+ assert_in_delta(0, m.mu03, 0.001)
138
+ assert_in_delta(0, m.inv_sqrt_m00, 0.001)
139
+ }
140
+
141
+ assert_in_delta(2221056, @moment3.m00, 0.001)
142
+ assert_in_delta(141037056, @moment3.m10, 0.001)
143
+ assert_in_delta(141037056, @moment3.m01, 0.001)
144
+ assert_in_delta(13157049856, @moment3.m20, 0.001)
145
+ assert_in_delta(8955853056, @moment3.m11, 0.001)
146
+ assert_in_delta(13492594176, @moment3.m02, 0.001)
147
+ assert_in_delta(1369024659456, @moment3.m30, 0.001)
148
+ assert_in_delta(835472665856, @moment3.m21, 0.001)
149
+ assert_in_delta(856779730176, @moment3.m12, 0.001)
150
+ assert_in_delta(1432945852416, @moment3.m03, 0.001)
151
+ assert_in_delta(4201196800, @moment3.mu20, 0.001)
152
+ assert_in_delta(0, @moment3.mu11, 0.001)
153
+ assert_in_delta(4536741120, @moment3.mu02, 0.001)
154
+ assert_in_delta(0, @moment3.mu30, 0.001)
155
+ assert_in_delta(0, @moment3.mu21, 0.001)
156
+ assert_in_delta(0, @moment3.mu12, 0.001)
157
+ assert_in_delta(0, @moment3.mu03, 0.001)
158
+ assert_in_delta(0.000671, @moment3.inv_sqrt_m00, 0.000001)
159
+
160
+ assert_in_delta(10240, @moment4.m00, 0.001)
161
+ assert_in_delta(650240, @moment4.m10, 0.001)
162
+ assert_in_delta(650240, @moment4.m01, 0.001)
163
+ assert_in_delta(58940416, @moment4.m20, 0.001)
164
+ assert_in_delta(41290240, @moment4.m11, 0.001)
165
+ assert_in_delta(61561856, @moment4.m02, 0.001)
166
+ assert_in_delta(5984288768, @moment4.m30, 0.001)
167
+ assert_in_delta(3742716416, @moment4.m21, 0.001)
168
+ assert_in_delta(3909177856, @moment4.m12, 0.001)
169
+ assert_in_delta(6483673088, @moment4.m03, 0.001)
170
+ assert_in_delta(17650176, @moment4.mu20, 0.001)
171
+ assert_in_delta(0, @moment4.mu11, 0.001)
172
+ assert_in_delta(20271616, @moment4.mu02, 0.001)
173
+ assert_in_delta(0, @moment4.mu30, 0.001)
174
+ assert_in_delta(0, @moment4.mu21, 0.001)
175
+ assert_in_delta(0, @moment4.mu12, 0.001)
176
+ assert_in_delta(0, @moment4.mu03, 0.001)
177
+ assert_in_delta(0.009882, @moment4.inv_sqrt_m00, 0.000001)
178
+ end
179
+ end
180
+
@@ -0,0 +1,75 @@
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::CvPoint
10
+ class TestCvPoint < OpenCVTestCase
11
+ class MyPoint; end
12
+ def test_x
13
+ point = CvPoint.new
14
+ point.x = 100
15
+ assert_equal(100, point.x)
16
+ point.x = 200
17
+ assert_equal(200, point.x)
18
+ end
19
+
20
+ def test_y
21
+ point = CvPoint.new
22
+ point.y = 100
23
+ assert_equal(100, point.y)
24
+ point.y = 200
25
+ assert_equal(200, point.y)
26
+ end
27
+
28
+ def test_compatible
29
+ assert(!(CvPoint.compatible? MyPoint.new))
30
+ MyPoint.class_eval { def x; end }
31
+ assert(!(CvPoint.compatible? MyPoint.new))
32
+ MyPoint.class_eval { def y; end }
33
+ assert(CvPoint.compatible? MyPoint.new)
34
+ assert(CvPoint.compatible? CvPoint.new)
35
+ end
36
+
37
+ def test_initialize
38
+ point = CvPoint.new
39
+ assert_equal(0, point.x)
40
+ assert_equal(0, point.y)
41
+
42
+ point = CvPoint.new(10, 20)
43
+ assert_equal(10, point.x)
44
+ assert_equal(20, point.y)
45
+
46
+ point = CvPoint.new(CvPoint.new(10, 20))
47
+ assert_equal(10, point.x)
48
+ assert_equal(20, point.y)
49
+
50
+ assert_raise(TypeError) {
51
+ CvPoint.new(DUMMY_OBJ)
52
+ }
53
+ assert_raise(ArgumentError) {
54
+ CvPoint.new(1, 2, 3)
55
+ }
56
+ end
57
+
58
+ def test_to_s
59
+ point = CvPoint.new(10, 20)
60
+ assert_equal('<OpenCV::CvPoint:(10,20)>', point.to_s)
61
+ end
62
+
63
+ def test_to_ary
64
+ a = CvPoint.new(10, 20).to_ary
65
+ assert_equal(10, a[0])
66
+ assert_equal(20, a[1])
67
+
68
+ # Alias
69
+ a = CvPoint.new(10, 20).to_a
70
+ assert_equal(10, a[0])
71
+ assert_equal(20, a[1])
72
+ end
73
+ end
74
+
75
+
@@ -0,0 +1,75 @@
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::CvPoint2D32f
10
+ class TestCvPoint2D32f < OpenCVTestCase
11
+ class MyPoint; end
12
+ def test_x
13
+ point = CvPoint2D32f.new
14
+ point.x = 1.1
15
+ assert_in_delta(1.1, point.x, 0.001)
16
+ point.x = 2.2
17
+ assert_in_delta(2.2, point.x, 0.001)
18
+ end
19
+
20
+ def test_y
21
+ point = CvPoint2D32f.new
22
+ point.y = 1.1
23
+ assert_in_delta(1.1, point.y, 0.001)
24
+ point.y = 2.2
25
+ assert_in_delta(2.2, point.y, 0.001)
26
+ end
27
+
28
+ def test_compatible
29
+ assert(!(CvPoint2D32f.compatible? MyPoint.new))
30
+ MyPoint.class_eval { def x; end }
31
+ assert(!(CvPoint2D32f.compatible? MyPoint.new))
32
+ MyPoint.class_eval { def y; end }
33
+ assert(CvPoint2D32f.compatible? MyPoint.new)
34
+ assert(CvPoint2D32f.compatible? CvPoint2D32f.new)
35
+ end
36
+
37
+ def test_initialize
38
+ point = CvPoint2D32f.new
39
+ assert_in_delta(0, point.x, 0.001)
40
+ assert_in_delta(0, point.y, 0.001)
41
+
42
+ point = CvPoint2D32f.new(1.1, 2.2)
43
+ assert_in_delta(1.1, point.x, 0.001)
44
+ assert_in_delta(2.2, point.y, 0.001)
45
+
46
+ point = CvPoint2D32f.new(CvPoint2D32f.new(1.1, 2.2))
47
+ assert_in_delta(1.1, point.x, 0.001)
48
+ assert_in_delta(2.2, point.y, 0.001)
49
+
50
+ assert_raise(TypeError) {
51
+ CvPoint2D32f.new(DUMMY_OBJ)
52
+ }
53
+ assert_raise(ArgumentError) {
54
+ CvPoint2D32f.new(1, 2, 3)
55
+ }
56
+ end
57
+
58
+ def test_to_s
59
+ point = CvPoint2D32f.new(1.1, 2.2)
60
+ assert_equal('<OpenCV::CvPoint2D32f:(1.1,2.2)>', point.to_s)
61
+ end
62
+
63
+ def test_to_ary
64
+ a = CvPoint2D32f.new(1.1, 2.2).to_ary
65
+ assert_in_delta(1.1, a[0], 0.001)
66
+ assert_in_delta(2.2, a[1], 0.001)
67
+
68
+ # Alias
69
+ a = CvPoint2D32f.new(1.1, 2.2).to_a
70
+ assert_in_delta(1.1, a[0], 0.001)
71
+ assert_in_delta(2.2, a[1], 0.001)
72
+ end
73
+ end
74
+
75
+
@@ -0,0 +1,93 @@
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::CvPoint3D32f
10
+ class TestCvPoint3D32f < OpenCVTestCase
11
+ class MyPoint; end
12
+ def test_x
13
+ point = CvPoint3D32f.new
14
+ point.x = 1.1
15
+ assert_in_delta(1.1, point.x, 0.001)
16
+ point.x = 2.2
17
+ assert_in_delta(2.2, point.x, 0.001)
18
+ end
19
+
20
+ def test_y
21
+ point = CvPoint3D32f.new
22
+ point.y = 1.1
23
+ assert_in_delta(1.1, point.y, 0.001)
24
+ point.y = 2.2
25
+ assert_in_delta(2.2, point.y, 0.001)
26
+ end
27
+
28
+ def test_z
29
+ point = CvPoint3D32f.new
30
+ point.z = 1.1
31
+ assert_in_delta(1.1, point.z, 0.001)
32
+ point.z = 2.2
33
+ assert_in_delta(2.2, point.z, 0.001)
34
+ end
35
+
36
+ def test_compatible
37
+ assert(!(CvPoint3D32f.compatible? MyPoint.new))
38
+ MyPoint.class_eval { def x; end }
39
+ assert(!(CvPoint3D32f.compatible? MyPoint.new))
40
+ MyPoint.class_eval { def y; end }
41
+ assert(!(CvPoint3D32f.compatible? MyPoint.new))
42
+ MyPoint.class_eval { def z; end }
43
+ assert(CvPoint3D32f.compatible? MyPoint.new)
44
+ assert(CvPoint3D32f.compatible? CvPoint3D32f.new)
45
+ end
46
+
47
+ def test_initialize
48
+ point = CvPoint3D32f.new
49
+ assert_in_delta(0, point.x, 0.001)
50
+ assert_in_delta(0, point.y, 0.001)
51
+ assert_in_delta(0, point.z, 0.001)
52
+
53
+ point = CvPoint3D32f.new(1.1, 2.2, 3.3)
54
+ assert_in_delta(1.1, point.x, 0.001)
55
+ assert_in_delta(2.2, point.y, 0.001)
56
+ assert_in_delta(3.3, point.z, 0.001)
57
+
58
+ point = CvPoint3D32f.new(CvPoint3D32f.new(1.1, 2.2, 3.3))
59
+ assert_in_delta(1.1, point.x, 0.001)
60
+ assert_in_delta(2.2, point.y, 0.001)
61
+ assert_in_delta(3.3, point.z, 0.001)
62
+
63
+ assert_raise(TypeError) {
64
+ CvPoint3D32f.new(DUMMY_OBJ)
65
+ }
66
+ assert_raise(ArgumentError) {
67
+ CvPoint3D32f.new(1, 2)
68
+ }
69
+ assert_raise(ArgumentError) {
70
+ CvPoint3D32f.new(1, 2, 3, 4)
71
+ }
72
+ end
73
+
74
+ def test_to_s
75
+ point = CvPoint3D32f.new(1.1, 2.2, 3.3)
76
+ assert_equal('<OpenCV::CvPoint3D32f:(1.1,2.2,3.3)>', point.to_s)
77
+ end
78
+
79
+ def test_to_ary
80
+ a = CvPoint3D32f.new(1.1, 2.2, 3.3).to_ary
81
+ assert_in_delta(1.1, a[0], 0.001)
82
+ assert_in_delta(2.2, a[1], 0.001)
83
+ assert_in_delta(3.3, a[2], 0.001)
84
+
85
+ # Alias
86
+ a = CvPoint3D32f.new(1.1, 2.2, 3.3).to_a
87
+ assert_in_delta(1.1, a[0], 0.001)
88
+ assert_in_delta(2.2, a[1], 0.001)
89
+ assert_in_delta(3.3, a[2], 0.001)
90
+ end
91
+ end
92
+
93
+