mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
update tests of CvMat#corner_harris
This commit is contained in:
parent
d68e7ddf1b
commit
7fe82c5cc8
2 changed files with 17 additions and 4 deletions
|
@ -143,5 +143,14 @@ class OpenCVTestCase < Test::Unit::TestCase
|
|||
}
|
||||
puts s.join("\n")
|
||||
end
|
||||
|
||||
def count_threshold(mat, threshold, &block)
|
||||
n = 0
|
||||
block = lambda { |a, b| a > b } unless block_given?
|
||||
(mat.rows * mat.cols).times { |i|
|
||||
n += 1 if block.call(mat[i][0], threshold)
|
||||
}
|
||||
n
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -165,10 +165,14 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
mat3 = mat0.corner_harris(3, 3, 0.04)
|
||||
mat4 = mat0.corner_harris(3, 7, 0.01)
|
||||
|
||||
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat1))
|
||||
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat2))
|
||||
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat3))
|
||||
assert_equal('6515d75f6223806f077cebc7b3927a13', hash_img(mat4))
|
||||
[mat1, mat2, mat3].each { |mat|
|
||||
assert_equal(mat0.rows, mat.rows)
|
||||
assert_equal(mat0.cols, mat.cols)
|
||||
assert_in_delta(0, count_threshold(mat, 10), 10)
|
||||
}
|
||||
assert_equal(mat0.rows, mat4.rows)
|
||||
assert_equal(mat0.cols, mat4.cols)
|
||||
assert_in_delta(90, count_threshold(mat4, 10), 10)
|
||||
|
||||
# Uncomment the following lines to show the images
|
||||
# snap(['original', mat0], ['corner_harris(3)', mat1], ['corner_harris(3,3)', mat2],
|
||||
|
|
Loading…
Add table
Reference in a new issue