From 8a4ecca49a6a502301d7efb69a17f0f6e5ebc6dd Mon Sep 17 00:00:00 2001 From: Guillaume HEUSCH <guillaume.heusch@idiap.ch> Date: Mon, 9 Jul 2018 11:25:19 +0200 Subject: [PATCH] [test] fixed unit tests --- bob/rppg/chrom/script/test.py | 2 +- bob/rppg/cvpr14/script/test.py | 16 ++++++++-------- bob/rppg/ssr/script/test.py | 21 ++------------------- bob/rppg/ssr/ssr_utils.py | 2 +- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/bob/rppg/chrom/script/test.py b/bob/rppg/chrom/script/test.py index 7f7e2ed..3a9b884 100644 --- a/bob/rppg/chrom/script/test.py +++ b/bob/rppg/chrom/script/test.py @@ -89,4 +89,4 @@ def test_project_chrominance(): r = g = b = 1 x,y = project_chrominance(r, g, b) assert x == 1.0 - assert y == 4.0 + assert y == 1.0 diff --git a/bob/rppg/cvpr14/script/test.py b/bob/rppg/cvpr14/script/test.py index 44cb013..f2b5947 100644 --- a/bob/rppg/cvpr14/script/test.py +++ b/bob/rppg/cvpr14/script/test.py @@ -94,10 +94,10 @@ def test_gftt(): from bob.rppg.cvpr14.extract_utils import get_good_features_to_track corners = get_good_features_to_track(image, 4) - assert numpy.array_equal(corners[0][0], numpy.array([20.0,20.0])), "1st corner" - assert numpy.array_equal(corners[1][0], numpy.array([79.0,20.0])), "2nd corner" - assert numpy.array_equal(corners[2][0], numpy.array([20.0,79.0])), "3rd corner" - assert numpy.array_equal(corners[3][0], numpy.array([79.0,79.0])), "4th corner" + assert numpy.array_equal(corners[0][0], numpy.array([79.0,79.0])), "1st corner" + assert numpy.array_equal(corners[1][0], numpy.array([20.0,79.0])), "2nd corner" + assert numpy.array_equal(corners[2][0], numpy.array([79.0,20.0])), "3rd corner" + assert numpy.array_equal(corners[3][0], numpy.array([20.0,20.0])), "4th corner" @opencv_available @@ -118,10 +118,10 @@ def test_track_features(): from bob.rppg.cvpr14.extract_utils import track_features points2 = track_features(image1, image2, points1) points2 = numpy.rint(points2) - assert numpy.array_equal(points2[0][0], numpy.array([21,21])), "1st corner" - assert numpy.array_equal(points2[1][0], numpy.array([80,21])), "2nd corner" - assert numpy.array_equal(points2[2][0], numpy.array([21,80])), "3rd corner" - assert numpy.array_equal(points2[3][0], numpy.array([80,80])), "4th corner" + assert numpy.array_equal(points2[0][0], numpy.array([80,80])), "1st corner" + assert numpy.array_equal(points2[1][0], numpy.array([21,80])), "2nd corner" + assert numpy.array_equal(points2[2][0], numpy.array([80,21])), "3rd corner" + assert numpy.array_equal(points2[3][0], numpy.array([21,21])), "4th corner" @opencv_available diff --git a/bob/rppg/ssr/script/test.py b/bob/rppg/ssr/script/test.py index d3ae201..d3584b0 100644 --- a/bob/rppg/ssr/script/test.py +++ b/bob/rppg/ssr/script/test.py @@ -1,23 +1,6 @@ #!/usr/bin/env python # encoding: utf-8 -# Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ -# Written by Guillaume Heusch <guillaume.heusch@idiap.ch>, -# -# This file is part of bob.rpgg.base. -# -# bob.rppg.base is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# bob.rppg.base is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with bob.rppg.base. If not, see <http://www.gnu.org/licenses/>. - import nose.tools import pkgutil import os, sys @@ -68,8 +51,8 @@ def test_get_eigen(): a = numpy.array([[1, 0], [0, 1]]) from bob.rppg.ssr.ssr_utils import get_eigen - evals, evecs = get_eigen(a) - assert numpy.all(evals == numpy.array([0, 0])) + evals, evecs = get_eigen(a) + assert numpy.all(evals == numpy.array([0.5, 0.5])) assert numpy.all(evecs == numpy.array([[0, 1], [1, 0]])) a = numpy.array([[0, 0], [0, 0]]) diff --git a/bob/rppg/ssr/ssr_utils.py b/bob/rppg/ssr/ssr_utils.py index 63601aa..f14dc1f 100644 --- a/bob/rppg/ssr/ssr_utils.py +++ b/bob/rppg/ssr/ssr_utils.py @@ -86,7 +86,7 @@ def get_eigen(skin_pixels): """ # build the correlation matrix c = numpy.dot(skin_pixels, skin_pixels.T) - c /= skin_pixels.shape[1] + c = c / skin_pixels.shape[1] # get eigenvectors and sort them according to eigenvalues (largest first) evals, evecs = numpy.linalg.eig(c) -- GitLab