From 4f1c87bcabbb9c5f2691f716c869e9d6fed96bc7 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 20 Jan 2013 04:29:37 +0900 Subject: [PATCH] update tests of CvMat#pyr_up --- test/helper.rb | 10 ++++++++++ test/test_cvmat_imageprocessing.rb | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 6704d72..b861181 100755 --- a/test/helper.rb +++ b/test/helper.rb @@ -152,5 +152,15 @@ class OpenCVTestCase < Test::Unit::TestCase } n end + + def color_hists(mat) + hists = [0] * mat.channel + (mat.rows * mat.cols).times { |i| + hists.size.times { |c| + hists[c] += mat[i][c] + } + } + hists + end end diff --git a/test/test_cvmat_imageprocessing.rb b/test/test_cvmat_imageprocessing.rb index 76bf7b6..096052d 100755 --- a/test/test_cvmat_imageprocessing.rb +++ b/test/test_cvmat_imageprocessing.rb @@ -1138,8 +1138,18 @@ class TestCvMat_imageprocessing < OpenCVTestCase mat1 = mat0.pyr_up mat2 = mat0.pyr_up(:gaussian_5x5) - assert_equal('02430c6cf143d3d104e25bc829f1fa93', hash_img(mat1)) - assert_equal('02430c6cf143d3d104e25bc829f1fa93', hash_img(mat2)) + [mat1, mat2].each { |mat| + assert_equal(mat0.cols * 2, mat.cols) + assert_equal(mat0.rows * 2, mat.rows) + assert_equal(mat0.depth, mat.depth) + assert_equal(mat0.channel, mat.channel) + b, g, r = color_hists(mat) + assert_in_delta(27500000, b, 1000000) + assert_in_delta(26000000, g, 1000000) + assert_in_delta(47000000, r, 1000000) + } + # Uncomment the following lines to show the result + # snap mat0, mat1, mat2 assert_raise(TypeError) { mat0.pyr_up(DUMMY_OBJ)