A working solution
This commit is contained in:
parent
9016f8461e
commit
196957f3d0
8 changed files with 14213 additions and 10 deletions
49
integral_image_tests.cpp
Normal file
49
integral_image_tests.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <thirdparty/catch.hpp>
|
||||
|
||||
#include "integral_image.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
bool are_equal(const integral_image::Mat &lhv, const integral_image::Mat &rhv)
|
||||
{
|
||||
auto diff = (lhv != rhv);
|
||||
return cv::countNonZero(diff) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Integral image of an empty Mat is an empty Mat")
|
||||
{
|
||||
using namespace integral_image;
|
||||
|
||||
Mat input;
|
||||
auto output = integral_image_openmp(input);
|
||||
|
||||
REQUIRE(output.data == NULL);
|
||||
}
|
||||
|
||||
TEST_CASE("Integral image of a zero-valued Mat is the same sized zero-valued Mat")
|
||||
{
|
||||
using namespace integral_image;
|
||||
|
||||
Mat input = Mat::zeros(20, 18);
|
||||
auto output = integral_image_openmp(input);
|
||||
REQUIRE(are_equal(input, output));
|
||||
}
|
||||
|
||||
TEST_CASE("")
|
||||
{
|
||||
using namespace integral_image;
|
||||
|
||||
double input_values[] = {0, 1, 2, 3, 4, 5};
|
||||
double expected_output_values[] = {0., 1., 2., 6., 6., 15.};
|
||||
|
||||
Mat input(3, 2, input_values);
|
||||
Mat expected_output(3, 2, expected_output_values);
|
||||
|
||||
auto output = integral_image_openmp(input);
|
||||
REQUIRE(are_equal(expected_output, output));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue