opencv-ffi 0.0.1

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 (130) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +15 -0
  3. data/README.md +126 -0
  4. data/Rakefile +52 -0
  5. data/docs/DocsIndex.md +1 -0
  6. data/docs/examples/load_image.rb +25 -0
  7. data/ext/Rakefile +13 -0
  8. data/ext/aishack-sift/.gitignore +4 -0
  9. data/ext/aishack-sift/Descriptor.h +34 -0
  10. data/ext/aishack-sift/KeyPoint.h +38 -0
  11. data/ext/aishack-sift/README +20 -0
  12. data/ext/aishack-sift/SIFT.cpp +1036 -0
  13. data/ext/aishack-sift/SIFT.h +84 -0
  14. data/ext/aishack-sift/example/.gitignore +2 -0
  15. data/ext/aishack-sift/example/Makefile +24 -0
  16. data/ext/aishack-sift/example/MySIFT.cpp +29 -0
  17. data/ext/aishack-sift/mkrf_conf.rb +13 -0
  18. data/ext/aishack-sift/siftlib.cpp +85 -0
  19. data/ext/eigen/.gitignore +4 -0
  20. data/ext/eigen/eigen_polynomial.cpp +41 -0
  21. data/ext/eigen/eigen_svd.cpp +100 -0
  22. data/ext/eigen/mkrf_conf.rb +14 -0
  23. data/ext/mkrf-monkey.rb +85 -0
  24. data/ext/mkrf-rakehelper-monkey.rb +52 -0
  25. data/ext/mkrf_conf.rb +3 -0
  26. data/ext/opencv-ffi/.gitignore +4 -0
  27. data/ext/opencv-ffi/matcher_helper.cpp +56 -0
  28. data/ext/opencv-ffi/mkrf_conf.rb +12 -0
  29. data/ext/opencv-ffi/vector_math.cpp +39 -0
  30. data/ext/opensurf/.gitignore +4 -0
  31. data/ext/opensurf/README +38 -0
  32. data/ext/opensurf/fasthessian.cpp +376 -0
  33. data/ext/opensurf/fasthessian.h +108 -0
  34. data/ext/opensurf/integral.cpp +58 -0
  35. data/ext/opensurf/integral.h +55 -0
  36. data/ext/opensurf/ipoint.cpp +108 -0
  37. data/ext/opensurf/ipoint.h +76 -0
  38. data/ext/opensurf/kmeans.h +172 -0
  39. data/ext/opensurf/mkrf_conf.rb +10 -0
  40. data/ext/opensurf/responselayer.h +92 -0
  41. data/ext/opensurf/surf.cpp +317 -0
  42. data/ext/opensurf/surf.h +66 -0
  43. data/ext/opensurf/surflib.cpp +98 -0
  44. data/ext/opensurf/surflib.h +96 -0
  45. data/ext/opensurf/utils.cpp +357 -0
  46. data/ext/opensurf/utils.h +63 -0
  47. data/lib/.gitignore +1 -0
  48. data/lib/opencv-ffi-ext/eigen.rb +84 -0
  49. data/lib/opencv-ffi-ext/features2d.rb +4 -0
  50. data/lib/opencv-ffi-ext/matcher_helper.rb +24 -0
  51. data/lib/opencv-ffi-ext/opensurf.rb +217 -0
  52. data/lib/opencv-ffi-ext/sift.rb +118 -0
  53. data/lib/opencv-ffi-ext/vector_math.rb +115 -0
  54. data/lib/opencv-ffi-wrappers.rb +7 -0
  55. data/lib/opencv-ffi-wrappers/core.rb +24 -0
  56. data/lib/opencv-ffi-wrappers/core/iplimage.rb +50 -0
  57. data/lib/opencv-ffi-wrappers/core/mat.rb +268 -0
  58. data/lib/opencv-ffi-wrappers/core/misc_draw.rb +44 -0
  59. data/lib/opencv-ffi-wrappers/core/point.rb +286 -0
  60. data/lib/opencv-ffi-wrappers/core/rect.rb +40 -0
  61. data/lib/opencv-ffi-wrappers/core/scalar.rb +104 -0
  62. data/lib/opencv-ffi-wrappers/core/size.rb +88 -0
  63. data/lib/opencv-ffi-wrappers/enumerable.rb +10 -0
  64. data/lib/opencv-ffi-wrappers/features2d.rb +17 -0
  65. data/lib/opencv-ffi-wrappers/features2d/image_patch.rb +322 -0
  66. data/lib/opencv-ffi-wrappers/features2d/star.rb +111 -0
  67. data/lib/opencv-ffi-wrappers/features2d/surf.rb +115 -0
  68. data/lib/opencv-ffi-wrappers/highgui.rb +10 -0
  69. data/lib/opencv-ffi-wrappers/imgproc.rb +4 -0
  70. data/lib/opencv-ffi-wrappers/imgproc/features.rb +35 -0
  71. data/lib/opencv-ffi-wrappers/imgproc/geometric.rb +39 -0
  72. data/lib/opencv-ffi-wrappers/matcher.rb +297 -0
  73. data/lib/opencv-ffi-wrappers/matrix.rb +37 -0
  74. data/lib/opencv-ffi-wrappers/misc.rb +41 -0
  75. data/lib/opencv-ffi-wrappers/misc/params.rb +34 -0
  76. data/lib/opencv-ffi-wrappers/sequence.rb +37 -0
  77. data/lib/opencv-ffi-wrappers/vectors.rb +38 -0
  78. data/lib/opencv-ffi.rb +12 -0
  79. data/lib/opencv-ffi/calib3d.rb +26 -0
  80. data/lib/opencv-ffi/core.rb +15 -0
  81. data/lib/opencv-ffi/core/draw.rb +68 -0
  82. data/lib/opencv-ffi/core/dynamic.rb +13 -0
  83. data/lib/opencv-ffi/core/library.rb +5 -0
  84. data/lib/opencv-ffi/core/operations.rb +122 -0
  85. data/lib/opencv-ffi/core/point.rb +22 -0
  86. data/lib/opencv-ffi/core/types.rb +172 -0
  87. data/lib/opencv-ffi/cvffi.rb +8 -0
  88. data/lib/opencv-ffi/features2d.rb +7 -0
  89. data/lib/opencv-ffi/features2d/library.rb +6 -0
  90. data/lib/opencv-ffi/features2d/star.rb +30 -0
  91. data/lib/opencv-ffi/features2d/surf.rb +38 -0
  92. data/lib/opencv-ffi/highgui.rb +31 -0
  93. data/lib/opencv-ffi/imgproc.rb +9 -0
  94. data/lib/opencv-ffi/imgproc/features.rb +37 -0
  95. data/lib/opencv-ffi/imgproc/geometric.rb +42 -0
  96. data/lib/opencv-ffi/imgproc/library.rb +6 -0
  97. data/lib/opencv-ffi/imgproc/misc.rb +39 -0
  98. data/lib/opencv-ffi/version.rb +3 -0
  99. data/opencv-ffi.gemspec +26 -0
  100. data/test/core/test_draw.rb +46 -0
  101. data/test/core/test_operations.rb +135 -0
  102. data/test/core/test_size.rb +14 -0
  103. data/test/core/test_text.rb +52 -0
  104. data/test/ext/test_eigen.rb +105 -0
  105. data/test/ext/test_opensurf.rb +35 -0
  106. data/test/ext/test_sift.rb +26 -0
  107. data/test/ext/test_vector_math.rb +85 -0
  108. data/test/features2d/test_surf.rb +63 -0
  109. data/test/imgproc/test_goodfeatures.rb +18 -0
  110. data/test/setup.rb +65 -0
  111. data/test/test_calib3d.rb +38 -0
  112. data/test/test_core.rb +26 -0
  113. data/test/test_ext.rb +8 -0
  114. data/test/test_features2d.rb +9 -0
  115. data/test/test_files/images/IMG_7088.JPG +0 -0
  116. data/test/test_files/images/IMG_7088_small.JPG +0 -0
  117. data/test/test_files/images/IMG_7089.JPG +0 -0
  118. data/test/test_highgui.rb +26 -0
  119. data/test/test_imgproc.rb +35 -0
  120. data/test/test_wrappers.rb +8 -0
  121. data/test/wrappers/core/test_draw.rb +41 -0
  122. data/test/wrappers/core/test_mat.rb +40 -0
  123. data/test/wrappers/core/test_operations.rb +35 -0
  124. data/test/wrappers/core/test_types.rb +235 -0
  125. data/test/wrappers/features2d/test_image_patch.rb +108 -0
  126. data/test/wrappers/test_imgproc.rb +87 -0
  127. data/test/wrappers/test_matcher.rb +96 -0
  128. data/test/wrappers/test_star.rb +28 -0
  129. data/test/wrappers/test_surf.rb +36 -0
  130. metadata +234 -0
@@ -0,0 +1,35 @@
1
+
2
+ require 'test/setup'
3
+ require 'opencv-ffi-wrappers/core'
4
+
5
+
6
+ class TestCoreWrapperOperations < Test::Unit::TestCase
7
+
8
+ WHITE = CVFFI::CvScalar.new( {:w=>255, :x=>255, :y=>255, :z=>0} )
9
+ BLACK = CVFFI::CvScalar.new( {:w=>0, :x=>0, :y=>0, :z=>0} )
10
+
11
+ def setup
12
+ end
13
+
14
+ def test_solve_cubic
15
+ # The roots of x^3 - 6x^2 + 11x - 6
16
+ # are 1,2,3
17
+ c = Vector[1,-6,11,-6]
18
+ r = CVFFI::solveCubic( c )
19
+
20
+ p r
21
+ assert r.is_a?(Vector)
22
+ assert_equal 3, r.size
23
+
24
+ # For simplicity, dump to an array I can sort
25
+ r = r.covector.sort
26
+
27
+ 3.times { |i|
28
+ assert_in_delta i+1, r[i], 1e-06
29
+ }
30
+ end
31
+
32
+
33
+
34
+
35
+ end
@@ -0,0 +1,235 @@
1
+
2
+ require 'test/setup'
3
+ require 'opencv-ffi/core'
4
+ require 'opencv-ffi-wrappers/core'
5
+
6
+ class TestCoreTypesWrappers < Test::Unit::TestCase
7
+
8
+ def test_cvSizeWrappers
9
+ p = CVFFI::CvSize.new( {:width => 1, :height => 2} )
10
+
11
+ assert_equal 1, p.x
12
+ assert_equal 2, p.y
13
+
14
+ assert_equal 1, p.width
15
+ assert_equal 2, p.height
16
+
17
+ p.x = 3
18
+
19
+ assert_equal 3, p.width
20
+ assert_equal 2, p.height
21
+ assert_equal 3, p.x
22
+ assert_equal 2, p.y
23
+
24
+ r = p.to_CvSize
25
+ assert_equal p,r
26
+
27
+ q = p.to_CvSize2D32f
28
+ assert_in_delta 3.0, q.width, TestSetup::EPSILON
29
+ assert_in_delta 2.0, q.height, TestSetup::EPSILON
30
+ end
31
+
32
+ def test_point
33
+ p = CVFFI::Point.new( 4.0, 5.0 )
34
+ assert_equal 4.0, p.x
35
+ assert_equal 5.0, p.y
36
+
37
+ q = p.to_CvPoint
38
+ assert_equal 4.0, q.x
39
+ assert_equal 5.0, q.y
40
+
41
+ a = p.to_a
42
+ assert a.is_a?(Array)
43
+ assert_equal 3, a.length
44
+ assert_equal 4.0, a[0]
45
+ assert_equal 5.0, a[1]
46
+ assert_equal 1.0, a[2]
47
+
48
+ a = p.to_a(false)
49
+ assert a.is_a?(Array)
50
+ assert_equal 2, a.length
51
+ assert_equal 4.0, a[0]
52
+ assert_equal 5.0, a[1]
53
+
54
+ end
55
+
56
+ def test_size
57
+ p = CVFFI::Size.new( [4.0, 5.0] )
58
+
59
+ assert_equal 4.0, p.width
60
+ assert_equal 5.0, p.height
61
+
62
+ assert_in_delta 20.0, p.area, TestSetup::EPSILON
63
+
64
+ q = p.to_CvSize2D32f
65
+ assert q.is_a?( CVFFI::CvSize2D32f )
66
+ assert_in_delta 4.0, q.width, TestSetup::EPSILON
67
+ assert_in_delta 5.0, q.height, TestSetup::EPSILON
68
+
69
+ r = CVFFI::Size.new p
70
+ assert_equal 4.0, r.width
71
+ assert_equal 5.0, r.height
72
+
73
+ s = p/2.0
74
+ assert_equal 2.0, s.width
75
+ assert_equal 2.5, s.height
76
+
77
+ p *= 2.0
78
+ assert_equal 8.0, p.width
79
+ assert_equal 10.0, p.height
80
+ end
81
+
82
+ def test_point
83
+ p = CVFFI::Point.new( 10.0, 0.0 )
84
+ r = CVFFI::Point.new( 0.0, 0.0 )
85
+
86
+ assert_equal 10.0, p.x
87
+ assert_equal 0.0, p.y
88
+
89
+ q = p.rotate( 0.0 )
90
+ assert_equal 10.0, q.x
91
+ assert_equal 0.0, q.y
92
+
93
+ q = p.rotate( Math::PI/2.0 )
94
+ assert_in_delta 0.0, q.x, TestSetup::EPSILON
95
+ assert_in_delta 10.0, q.y, TestSetup::EPSILON
96
+
97
+ assert p.neighbor?( r, 10.01 )
98
+ assert p.neighbor?( r, 9.99 ) == false
99
+
100
+ assert p.neighbor_rsquared?( r, 100.01 )
101
+ assert p.neighbor_rsquared?( r, 99.9 ) == false
102
+
103
+ assert_in_delta 10.0, p.l2distance( r ), TestSetup::EPSILON
104
+ assert_in_delta 100.0, p.l2_squared_distance( r ), TestSetup::EPSILON
105
+
106
+ end
107
+
108
+ def test_iplimage
109
+ img = CVFFI::cvCreateImage( CVFFI::CvSize.new( :width=>100, :height=>100 ), 8, 1 )
110
+
111
+ size = img.image_size
112
+
113
+ assert_not_nil size
114
+ assert_equal 100, size.width
115
+ assert_equal 100, size.height
116
+
117
+ clone = img.clone
118
+
119
+
120
+ twin = img.twin
121
+ assert_equal img.image_size, twin.image_size
122
+ assert_equal img.depth, twin.depth
123
+ assert_equal img.nChannels, twin.nChannels
124
+
125
+ end
126
+
127
+ def test_rect
128
+ r = CVFFI::Rect.new( :center => CVFFI::Point.new( 0.0, 0.0 ),
129
+ :size => CVFFI::Size.new( 10.0, 10.0 ) )
130
+
131
+ assert_equal -5.0, r.origin.x
132
+ assert_equal -5.0, r.origin.y
133
+ assert_equal 10.0, r.size.width
134
+ assert_equal 10.0, r.size.height
135
+
136
+ cv = r.to_CvRect
137
+
138
+ assert_equal -5.0, cv.x
139
+ assert_equal -5.0, cv.y
140
+ assert_equal 10.0, cv.width
141
+ assert_equal 10.0, cv.height
142
+ end
143
+
144
+ def test_mat
145
+ m = CVFFI::CvMat.eye( 3 )
146
+
147
+ 3.times { |i|
148
+ 3.times { |j|
149
+ assert_equal m.at_f(i,j), ( i==j ? 1.0 : 0.0 )
150
+ }
151
+ }
152
+
153
+ mat = m.to_Matrix
154
+ assert_not_nil mat
155
+ assert_equal mat[0,0], 1.0
156
+ assert_equal mat[0,0], m.at_f(0,0)
157
+
158
+ r = m.clone
159
+ assert_equal m.height, r.height
160
+ assert_equal m.width, r.width
161
+ assert_equal m.type, r.type
162
+ assert_equal m.at_f(0,0), r.at_f(0,0)
163
+
164
+ q = m.twin
165
+ assert_equal m.height, q.height
166
+ assert_equal m.width, q.width
167
+ assert_equal m.type, q.type
168
+ assert_not_equal m.at_f(0,0), q.at_f(0,0)
169
+ end
170
+
171
+ def test_vector
172
+ m = CVFFI::cvCreateMat( 1, 5, :CV_32F )
173
+ n = CVFFI::cvCreateMat( 5, 1, :CV_32F )
174
+
175
+ 5.times { |i|
176
+ m.set_f(0,i,i)
177
+ n.set_f(i,0,i)
178
+ }
179
+
180
+ mv = m.to_Vector
181
+ nv = n.to_Vector
182
+
183
+ 5.times { |i|
184
+ assert_equal i, mv[i]
185
+ assert_equal i, nv[i]
186
+ }
187
+ end
188
+
189
+ def test_mat_transpose
190
+ m = CVFFI::cvCreateMat( 3,3,:CV_32F)
191
+ m.zero
192
+ m.set_f( 0, 2, 1.0 )
193
+
194
+ assert_equal m.at_f( 0, 2 ), 1.0
195
+ assert_equal m.at_f( 2, 0 ), 0.0
196
+
197
+ t = m.transpose
198
+ assert_equal m.at_f( 0, 2 ), 1.0
199
+ assert_equal m.at_f( 2, 0 ), 0.0
200
+
201
+ assert_equal t.at_f( 0, 2 ), 0.0
202
+ assert_equal t.at_f( 2, 0 ), 1.0
203
+ end
204
+
205
+ def test_mat_coercion
206
+ a = Matrix.rows( [ [ 1,0,0 ], [0,2,0], [0,0,3] ] )
207
+ b = CVFFI::CvMat.eye( 3 )
208
+
209
+ c = nil
210
+ assert_nothing_raised {
211
+ c = a*b
212
+ }
213
+ assert c.is_a?(Matrix)
214
+ assert_equal 1, c[0,0]
215
+ assert_equal 2, c[1,1]
216
+ assert_equal 3, c[2,2]
217
+ end
218
+
219
+ def test_scalar
220
+ # Test each expected initializer pattern
221
+ # Default ordering is BGRA
222
+ [ CVFFI::Scalar.new( 1,2,0,4 ),
223
+ CVFFI::Scalar.new( :w => 1, :x => 2, :z => 4),
224
+ CVFFI::Scalar.new( :A => 4, :g => 2, :B => 1) ].each { |m|
225
+
226
+ [ [1,2,0,4], [:w,:x,:y,:z], [:B,:G,:R,:A], [:b,:g,:r,:a ] ].transpose.each { |i,j,k,p|
227
+ assert_equal i, m[j], "m[:#{j.to_s}] != #{i} for #{m.to_s}"
228
+ assert_equal i, m[k], "m[:#{k.to_s}] != #{i} for #{m.to_s}"
229
+ assert_equal i, m[p], "m[:#{p.to_s}] != #{i} for #{m.to_s}"
230
+ }
231
+ }
232
+
233
+
234
+ end
235
+ end
@@ -0,0 +1,108 @@
1
+
2
+
3
+ require 'test/setup'
4
+
5
+ require 'opencv-ffi'
6
+ require 'opencv-ffi-wrappers'
7
+ require 'opencv-ffi-wrappers/features2d/image_patch'
8
+
9
+ class TestImagePatch < Test::Unit::TestCase
10
+
11
+ def setup
12
+ @img = TestSetup::test_image
13
+
14
+ # Generate an aritificial image, a 300x300 black field
15
+ # With a 100-wide grey stripe down the center
16
+ # and a white X corner-to-corner
17
+ img = CVFFI::cvCreateImage( CVFFI::CvSize.new( [ 300,300 ] ), 8, 1 )
18
+ CVFFI::cvSet( img, CVFFI::Scalar.new( 0,0,0,0 ).to_CvScalar, nil )
19
+ CVFFI::cvSetImageROI( img, CVFFI::Rect.new( [100,0,100,300] ).to_CvRect )
20
+ CVFFI::cvSet( img, CVFFI::Scalar.new( 128,0,0,0 ).to_CvScalar, nil )
21
+ CVFFI::cvResetImageROI( img )
22
+ CVFFI::draw_line( img, CVFFI::Point.new(0,0), CVFFI::Point.new(300,300),
23
+ { thickness: 2 } )
24
+ CVFFI::draw_line( img, CVFFI::Point.new(300,0), CVFFI::Point.new(0,300),
25
+ { thickness: 2 } )
26
+ @testimg = img
27
+ end
28
+
29
+
30
+ def test_cvExtractImagePatch
31
+
32
+ params = CVFFI::ImagePatch::Params.new( size: 9 )
33
+
34
+ puts "Image size = #{@img.width} x #{@img.height}"
35
+ # With a 9x9 patch, (4,4) should be OK, but (3,4) shouldn't
36
+ # Similarly width-5 should be OK, but width-4 shouldn't
37
+ kp = [ [100,100],
38
+ [150,150],
39
+ [100,100],
40
+ [4,4],
41
+ [3,4],
42
+ [@img.width-5,100],
43
+ [@img.width-4,100] ].map { |i| CVFFI::Point.new i }
44
+ duds = 2
45
+
46
+ patches = CVFFI::ImagePatch::describe( @img, kp, params )
47
+ assert_not_nil patches
48
+
49
+ assert_equal kp.length-duds, patches.length
50
+
51
+ # KPs 0 and 2 should be identical
52
+ assert_equal patches[0], patches[2]
53
+
54
+ patch_index = patches.draw_index_image
55
+ TestSetup::save_image( "test_cvExtractImagePatch", patch_index )
56
+ end
57
+
58
+ def test_cvExtractCircularOrientedImagePatch
59
+ kp = [ [100,100], [150,150], [199,199] ].map { |i| CVFFI::Point.new i }
60
+ orientation = [ 5.35, 5.497, 5.35 ]
61
+
62
+ params = CVFFI::ImagePatch::Params.new( size: 15,
63
+ oriented: true,
64
+ shape: :circle)
65
+
66
+ patches = CVFFI::ImagePatch.describe( @testimg, kp, params )
67
+
68
+ patches.each_with_index { |patch,i|
69
+ assert_in_delta patch.angle, orientation[i], 0.1, "For orientation #{i}"
70
+ }
71
+
72
+ # Expect the first and last to be roughly the same
73
+ assert_in_delta orientation.first, orientation.last, 0.1
74
+
75
+ patch_index = patches.draw_index_image
76
+ TestSetup::save_image( "test_cvExtractCircularOrientedImagePatch", patch_index )
77
+ end
78
+
79
+
80
+
81
+
82
+ def test_cvExtractOrientedImagePatch
83
+
84
+ TestSetup::save_image( "oriented_image_patch", @testimg )
85
+
86
+ kp = [ [100,100], [150,150], [199,199] ].map { |i| CVFFI::Point.new i }
87
+ orientation = [ 5.35, 4.712, 5.35 ]
88
+
89
+ params = CVFFI::ImagePatch::Params.new( size: 15,
90
+ oriented: true )
91
+
92
+ patches = CVFFI::ImagePatch.describe( @testimg, kp, params )
93
+
94
+ patches.each_with_index { |patch,i|
95
+ assert_in_delta patch.angle, orientation[i], 0.1, "For orientation #{i}"
96
+ }
97
+
98
+ # Expect the first and last to be roughly the same
99
+ assert_in_delta orientation.first, orientation.last, 0.1
100
+
101
+ # First and last should be relatively similar
102
+ puts "Distance = #{ patches.first.distance_to( patches.last ) }"
103
+
104
+ patch_index = patches.draw_index_image
105
+ TestSetup::save_image( "test_cvOrientedExtractImagePatch", patch_index )
106
+ end
107
+
108
+ end
@@ -0,0 +1,87 @@
1
+
2
+
3
+ require 'test/setup'
4
+ require 'opencv-ffi-wrappers/core'
5
+ require 'opencv-ffi-wrappers/imgproc'
6
+ require 'opencv-ffi-wrappers/misc'
7
+
8
+ class TestImgprocWrappers < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @img = TestSetup::test_image
12
+ end
13
+
14
+ def test_getAffineTransform
15
+ src = Array.new(5) { |i|
16
+ CVFFI::Point.new( 1.1, i*1.0 )
17
+ }
18
+ dst = Array.new(5) { |i|
19
+ CVFFI::Point.new( i*1.0, i* -1.0 )
20
+ }
21
+
22
+ result = CVFFI::get_affine_transform(src,dst)
23
+
24
+ assert_not_nil result
25
+
26
+ CVFFI::print_matrix(result, :format => :e)
27
+
28
+ end
29
+
30
+ def test_warpAffine
31
+ warp = CVFFI::CvMat.new CVFFI::cvCreateMat(2,3,:CV_32F)
32
+ CVFFI::cvSetReal2D(warp, 0,0,1.0)
33
+ CVFFI::cvSetReal2D(warp, 0,1,0.0)
34
+ CVFFI::cvSetReal2D(warp, 0,2,0.0)
35
+ CVFFI::cvSetReal2D(warp, 1,0,0.0)
36
+ CVFFI::cvSetReal2D(warp, 1,1,1.0)
37
+ CVFFI::cvSetReal2D(warp, 1,2,0.0)
38
+
39
+ dst = CVFFI::cvCreateImage( @img.image_size.to_CvSize, @img.depth, @img.nChannels )
40
+
41
+ out = CVFFI::warp_affine( @img.to_IplImage, dst, warp )
42
+
43
+ TestSetup::save_image("affineWarped.jpg", dst )
44
+
45
+ end
46
+
47
+
48
+ def corner_common_tests( corners, img, params = nil )
49
+
50
+ if params
51
+ assert corners.length <= params.max_corners
52
+ end
53
+
54
+ # Hm, what can I test?
55
+ corners.each { |c|
56
+ assert c.x >= 0.0
57
+ assert c.x < img.width
58
+ assert c.y >= 0.0
59
+ assert c.y < img.height
60
+ }
61
+ end
62
+
63
+ def test_goodFeaturesToTrack_default_params
64
+ corners = CVFFI::goodFeaturesToTrack( @img )
65
+ corner_common_tests( corners, @img )
66
+
67
+ params = CVFFI::GoodFeaturesParams.new( use_harris: true )
68
+ harris_corners = CVFFI::goodFeaturesToTrack( @img, params )
69
+ corner_common_tests( harris_corners, @img, params )
70
+
71
+ assert harris_corners != corners
72
+ end
73
+
74
+ def test_goodFeaturesToTrack_shitomasi_with_params
75
+ params = CVFFI::GoodFeaturesParams.new( quality_level: 0.7,
76
+ min_distance: 10 )
77
+ corners = CVFFI::goodFeaturesToTrack( @img, params )
78
+ corner_common_tests( corners, @img, params )
79
+ end
80
+
81
+ def test_goodFeaturesToTrack_harris_with_params
82
+ end
83
+
84
+
85
+
86
+
87
+ end