mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include "opencv2/core/eigen.hpp"
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
class Core_ReduceTest : public cvtest::BaseTest
|
||||
@@ -1974,6 +1976,157 @@ TEST(Core_InputArray, fetch_MatExpr)
|
||||
}
|
||||
|
||||
|
||||
#ifdef CV_CXX11
|
||||
class TestInputArrayRangeChecking {
|
||||
static const char *kind2str(cv::_InputArray ia)
|
||||
{
|
||||
switch (ia.kind())
|
||||
{
|
||||
#define C(x) case cv::_InputArray::x: return #x
|
||||
C(MAT);
|
||||
C(UMAT);
|
||||
C(EXPR);
|
||||
C(MATX);
|
||||
C(STD_VECTOR);
|
||||
C(STD_ARRAY);
|
||||
C(NONE);
|
||||
C(STD_VECTOR_VECTOR);
|
||||
C(STD_BOOL_VECTOR);
|
||||
C(STD_VECTOR_MAT);
|
||||
C(STD_ARRAY_MAT);
|
||||
C(STD_VECTOR_UMAT);
|
||||
C(CUDA_GPU_MAT);
|
||||
C(STD_VECTOR_CUDA_GPU_MAT);
|
||||
#undef C
|
||||
default:
|
||||
return "<unsupported>";
|
||||
}
|
||||
}
|
||||
|
||||
static void banner(cv::_InputArray ia, const char *label, const char *name)
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< label << " = " << name << ", Kind: " << kind2str(ia)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
template<typename I, typename F>
|
||||
static void testA(I ia, F f, const char *mfname)
|
||||
{
|
||||
banner(ia, "f", mfname);
|
||||
EXPECT_THROW(f(ia, -1), cv::Exception)
|
||||
<< "f(ia, " << -1 << ") should throw cv::Exception";
|
||||
for (int i = 0; i < int(ia.size()); i++)
|
||||
{
|
||||
EXPECT_NO_THROW(f(ia, i))
|
||||
<< "f(ia, " << i << ") should not throw an exception";
|
||||
}
|
||||
EXPECT_THROW(f(ia, int(ia.size())), cv::Exception)
|
||||
<< "f(ia, " << ia.size() << ") should throw cv::Exception";
|
||||
}
|
||||
|
||||
template<typename I, typename F>
|
||||
static void testB(I ia, F f, const char *mfname)
|
||||
{
|
||||
banner(ia, "f", mfname);
|
||||
EXPECT_THROW(f(ia, -1), cv::Exception)
|
||||
<< "f(ia, " << -1 << ") should throw cv::Exception";
|
||||
for (int i = 0; i < int(ia.size()); i++)
|
||||
{
|
||||
EXPECT_NO_THROW(f(ia, i))
|
||||
<< "f(ia, " << i << ") should not throw an exception";
|
||||
}
|
||||
EXPECT_THROW(f(ia, int(ia.size())), cv::Exception)
|
||||
<< "f(ia, " << ia.size() << ") should throw cv::Exception";
|
||||
}
|
||||
|
||||
static void test_isContinuous()
|
||||
{
|
||||
auto f = [](cv::_InputArray ia, int i) { (void)ia.isContinuous(i); };
|
||||
|
||||
cv::Mat M;
|
||||
cv::UMat uM;
|
||||
|
||||
std::vector<cv::Mat> vec = {M, M};
|
||||
std::array<cv::Mat, 2> arr = {M, M};
|
||||
std::vector<cv::UMat> uvec = {uM, uM};
|
||||
|
||||
testA(vec, f, "isContinuous");
|
||||
testA(arr, f, "isContinuous");
|
||||
testA(uvec, f, "isContinuous");
|
||||
}
|
||||
|
||||
static void test_isSubmatrix()
|
||||
{
|
||||
auto f = [](cv::_InputArray ia, int i) { (void)ia.isSubmatrix(i); };
|
||||
|
||||
cv::Mat M;
|
||||
cv::UMat uM;
|
||||
|
||||
std::vector<cv::Mat> vec = {M, M};
|
||||
std::array<cv::Mat, 2> arr = {M, M};
|
||||
std::vector<cv::UMat> uvec = {uM, uM};
|
||||
|
||||
testA(vec, f, "isSubmatrix");
|
||||
testA(arr, f, "isSubmatrix");
|
||||
testA(uvec, f, "isSubmatrix");
|
||||
}
|
||||
|
||||
static void test_offset()
|
||||
{
|
||||
auto f = [](cv::_InputArray ia, int i) { return ia.offset(i); };
|
||||
|
||||
cv::Mat M;
|
||||
cv::UMat uM;
|
||||
cv::cuda::GpuMat gM;
|
||||
|
||||
std::vector<cv::Mat> vec = {M, M};
|
||||
std::array<cv::Mat, 2> arr = {M, M};
|
||||
std::vector<cv::UMat> uvec = {uM, uM};
|
||||
std::vector<cv::cuda::GpuMat> gvec = {gM, gM};
|
||||
|
||||
testB(vec, f, "offset");
|
||||
testB(arr, f, "offset");
|
||||
testB(uvec, f, "offset");
|
||||
testB(gvec, f, "offset");
|
||||
}
|
||||
|
||||
static void test_step()
|
||||
{
|
||||
auto f = [](cv::_InputArray ia, int i) { return ia.step(i); };
|
||||
|
||||
cv::Mat M;
|
||||
cv::UMat uM;
|
||||
cv::cuda::GpuMat gM;
|
||||
|
||||
std::vector<cv::Mat> vec = {M, M};
|
||||
std::array<cv::Mat, 2> arr = {M, M};
|
||||
std::vector<cv::UMat> uvec = {uM, uM};
|
||||
std::vector<cv::cuda::GpuMat> gvec = {gM, gM};
|
||||
|
||||
testB(vec, f, "step");
|
||||
testB(arr, f, "step");
|
||||
testB(uvec, f, "step");
|
||||
testB(gvec, f, "step");
|
||||
}
|
||||
|
||||
public:
|
||||
static void run()
|
||||
{
|
||||
test_isContinuous();
|
||||
test_isSubmatrix();
|
||||
test_offset();
|
||||
test_step();
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Core_InputArray, range_checking)
|
||||
{
|
||||
TestInputArrayRangeChecking::run();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TEST(Core_Vectors, issue_13078)
|
||||
{
|
||||
float floats_[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
|
||||
Reference in New Issue
Block a user