diff --git a/conformity/opencv/test_separable_filter_2d.cpp b/conformity/opencv/test_separable_filter_2d.cpp index 548967eb19bf2d9592e195e2562e4b0fb2adc335..89349369262e07eaf83899e901e4e4cf4b27ba88 100644 --- a/conformity/opencv/test_separable_filter_2d.cpp +++ b/conformity/opencv/test_separable_filter_2d.cpp @@ -34,9 +34,13 @@ cv::Mat exec_separable_filter_2d(cv::Mat& input) { cv::RNG rng(kernel_seed); cv::Mat kernel_x(KernelSize, 1, get_opencv_matrix_type()); - rng.fill(kernel_x, cv::RNG::UNIFORM, 0, 5); + // use the minimum value 1 for the kernels in order to properly work around + // the potential OpenCV bug (mentioned lower in "test_separable_filter_2d") + rng.fill(kernel_x, cv::RNG::UNIFORM, 1, + std::numeric_limits::max()); cv::Mat kernel_y(KernelSize, 1, get_opencv_matrix_type()); - rng.fill(kernel_y, cv::RNG::UNIFORM, 0, 5); + rng.fill(kernel_y, cv::RNG::UNIFORM, 1, + std::numeric_limits::max()); cv::Mat result; cv::sepFilter2D(input_mat, result, -1, kernel_x, kernel_y, cv::Point(-1, -1), @@ -88,7 +92,10 @@ bool test_separable_filter_2d(int index, RecreatedMessageQueue& request_queue, // One extra line allocated to be sure the kernel seed can be placed next // to the real input cv::Mat input(y + 1, x, get_opencv_matrix_type()); - rng.fill(input, cv::RNG::UNIFORM, 0, 7); + // use the minimum value 1 for the input in order to properly work around + // the potential OpenCV bug (mentioned lower) + rng.fill(input, cv::RNG::UNIFORM, 1, + std::numeric_limits::max()); uint32_t kernel_seed = rng.next(); @@ -101,6 +108,16 @@ bool test_separable_filter_2d(int index, RecreatedMessageQueue& request_queue, cv::Mat expected = get_expected_from_subordinate(index, request_queue, reply_queue, input); + // bypass OpenCV bug/inconsistency where the output matrix contains 0's, + // whereas this should not be possible mathematically + for (size_t i = 0; i < (y * Channels); ++i) { + for (size_t j = 0; j < (x * Channels); ++j) { + if (expected.at(i, j) == 0) + expected.at(i, j) = + std::numeric_limits::max(); + } + } + if (are_matrices_different(0, actual, expected)) { fail_print_matrices(y, x, input, actual, expected); return true;