Commit b79a29f1 authored by Davis King's avatar Davis King

Fixed is_image_type template always reporting false. This also caused

have_same_dimensions() to be uncallable for images, so that's fixed now too.
parent f9556078
......@@ -138,10 +138,10 @@ namespace dlib
// Check if T has image_traits<T> defined for it.
template <typename T, typename enabled = void>
template <typename T, typename enabled = size_t>
struct is_image_type : public std::false_type{};
template <typename T>
struct is_image_type<T, image_traits<typename std::decay<T>::type>> : public std::true_type{};
struct is_image_type<T, decltype(sizeof(image_traits<typename std::decay<T>::type>))> : public std::true_type{};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
......
......@@ -3271,6 +3271,24 @@ namespace
dlog << LINFO << "NOW RUNNING TESTS WITH set_dnn_prefer_smallest_algorithms()";
set_dnn_prefer_smallest_algorithms();
run_tests();
{
resizable_tensor a(2,3,4,5);
resizable_tensor b(2,3,4,5);
DLIB_TEST(have_same_dimensions(a,b));
a.set_size(2,3,4,4);
DLIB_TEST(!have_same_dimensions(a,b));
a.set_size(2,3,3,5);
DLIB_TEST(!have_same_dimensions(a,b));
a.set_size(2,2,4,5);
DLIB_TEST(!have_same_dimensions(a,b));
a.set_size(1,3,4,5);
DLIB_TEST(!have_same_dimensions(a,b));
static_assert(!is_image_type<resizable_tensor>::value, "should be false");
}
}
} a;
}
......
......@@ -2070,6 +2070,21 @@ namespace
DLIB_TEST(sum(matrix_cast<int>(mat(img))) == 0);
}
{
matrix<int> a(3,4);
array2d<unsigned char> b(3,4);
DLIB_TEST(have_same_dimensions(a,b));
}
{
matrix<int> a(4,4);
array2d<unsigned char> b(3,4);
DLIB_TEST(!have_same_dimensions(a,b));
static_assert(is_image_type<matrix<int>>::value, "should be true");
static_assert(!is_image_type<int>::value, "should be false");
}
test_partition_pixels();
}
} a;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment