core(check): add Size_<int>

pull/16249/head
Alexander Alekhin 5 years ago
parent 9572895da0
commit 523f081923
  1. 6
      modules/calib3d/src/calibration.cpp
  2. 2
      modules/core/include/opencv2/core/check.hpp
  3. 8
      modules/core/src/check.cpp
  4. 37
      modules/core/test/test_misc.cpp

@ -3221,8 +3221,10 @@ void cv::Rodrigues(InputArray _src, OutputArray _dst, OutputArray _jacobian)
CV_INSTRUMENT_REGION();
Mat src = _src.getMat();
CV_Check(src.rows, (src.rows == 1 && src.cols == 3) || (src.rows == 3 && src.cols == 1) ||
(src.rows == 1 && src.cols == 1 && src.channels() == 3) || (src.rows == 3 && src.cols == 3),
const Size srcSz = src.size();
CV_Check(srcSz, srcSz == Size(3, 1) || srcSz == Size(1, 3) ||
(srcSz == Size(1, 1) && src.channels() == 3) ||
srcSz == Size(3, 3),
"Input matrix must be 1x3 or 3x1 for a rotation vector, or 3x3 for a rotation matrix");
bool v2m = src.cols == 1 || src.rows == 1;

@ -69,6 +69,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_<int> v1, const Size_<int> v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx);
@ -77,6 +78,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& c
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_<int> v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx);

@ -113,6 +113,10 @@ void check_failed_auto(const double v1, const double v2, const CheckContext& ctx
{
check_failed_auto_<double>(v1, v2, ctx);
}
void check_failed_auto(const Size_<int> v1, const Size_<int> v2, const CheckContext& ctx)
{
check_failed_auto_< Size_<int> >(v1, v2, ctx);
}
template<typename T> static CV_NORETURN
@ -163,6 +167,10 @@ void check_failed_auto(const double v, const CheckContext& ctx)
{
check_failed_auto_<double>(v, ctx);
}
void check_failed_auto(const Size_<int> v, const CheckContext& ctx)
{
check_failed_auto_< Size_<int> >(v, ctx);
}
}} // namespace

@ -671,7 +671,8 @@ TEST(Core_Check, testMatType_fail_2)
EXPECT_STREQ(e.err.c_str(),
"> Unsupported src:\n"
"> 'src_type == CV_32FC1 || src_type == CV_32FC3'\n"
"> where\n> 'src_type' is 0 (CV_8UC1)\n"
"> where\n"
"> 'src_type' is 0 (CV_8UC1)\n"
);
}
catch (const std::exception& e)
@ -737,7 +738,39 @@ TEST(Core_Check, testMatDepth_fail_2)
EXPECT_STREQ(e.err.c_str(),
"> Unsupported src:\n"
"> 'src_depth == CV_32F || src_depth == CV_64F'\n"
"> where\n> 'src_depth' is 0 (CV_8U)\n"
"> where\n"
"> 'src_depth' is 0 (CV_8U)\n"
);
}
catch (const std::exception& e)
{
FAIL() << "Unexpected C++ exception: " << e.what();
}
catch (...)
{
FAIL() << "Unexpected unknown exception";
}
}
void test_check_Size_1(const Size& srcSz)
{
CV_Check(srcSz, srcSz == Size(4, 3), "Unsupported src size");
}
TEST(Core_Check, testSize_1)
{
try
{
test_check_Size_1(Size(2, 1));
FAIL() << "Unreachable code called";
}
catch (const cv::Exception& e)
{
EXPECT_STREQ(e.err.c_str(),
"> Unsupported src size:\n"
"> 'srcSz == Size(4, 3)'\n"
"> where\n"
"> 'srcSz' is [2 x 1]\n"
);
}
catch (const std::exception& e)

Loading…
Cancel
Save