mirror of
https://github.com/opencv/opencv.git
synced 2025-01-19 06:53:50 +08:00
Fix sanity checks for empty objects
This commit is contained in:
parent
f8672d49a0
commit
c146c54bcd
@ -392,30 +392,42 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
|
|||||||
cv::Mat expected;
|
cv::Mat expected;
|
||||||
valnode >> expected;
|
valnode >> expected;
|
||||||
|
|
||||||
ASSERT_EQ(expected.size(), actual.size())
|
if(expected.empty())
|
||||||
<< " " << node.name() << "[" << idx<< "] has unexpected size";
|
|
||||||
|
|
||||||
cv::Mat diff;
|
|
||||||
cv::absdiff(expected, actual, diff);
|
|
||||||
|
|
||||||
if (err == ERROR_ABSOLUTE)
|
|
||||||
{
|
{
|
||||||
if (!cv::checkRange(diff, true, 0, 0, eps))
|
ASSERT_TRUE(actual.empty())
|
||||||
{
|
<< " expected empty " << node.name() << "[" << idx<< "]";
|
||||||
double max;
|
|
||||||
cv::minMaxLoc(diff.reshape(1), 0, &max);
|
|
||||||
FAIL() << " Absolute difference (=" << max << ") between argument \""
|
|
||||||
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (err == ERROR_RELATIVE)
|
else
|
||||||
{
|
{
|
||||||
double maxv, maxa;
|
ASSERT_EQ(expected.size(), actual.size())
|
||||||
int violations = countViolations(expected, actual, diff, eps, &maxv, &maxa);
|
<< " " << node.name() << "[" << idx<< "] has unexpected size";
|
||||||
if (violations > 0)
|
|
||||||
|
cv::Mat diff;
|
||||||
|
cv::absdiff(expected, actual, diff);
|
||||||
|
|
||||||
|
if (err == ERROR_ABSOLUTE)
|
||||||
{
|
{
|
||||||
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \""
|
if (!cv::checkRange(diff, true, 0, 0, eps))
|
||||||
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps << " in " << violations << " points";
|
{
|
||||||
|
if(expected.total() * expected.channels() < 12)
|
||||||
|
std::cout << " Expected: " << std::endl << expected << std::endl << " Actual:" << std::endl << actual << std::endl;
|
||||||
|
|
||||||
|
double max;
|
||||||
|
cv::minMaxLoc(diff.reshape(1), 0, &max);
|
||||||
|
|
||||||
|
FAIL() << " Absolute difference (=" << max << ") between argument \""
|
||||||
|
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (err == ERROR_RELATIVE)
|
||||||
|
{
|
||||||
|
double maxv, maxa;
|
||||||
|
int violations = countViolations(expected, actual, diff, eps, &maxv, &maxa);
|
||||||
|
if (violations > 0)
|
||||||
|
{
|
||||||
|
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \""
|
||||||
|
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps << " in " << violations << " points";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,30 +446,42 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
|
|||||||
valnode >> expected;
|
valnode >> expected;
|
||||||
cv::Mat actual = array.getMat();
|
cv::Mat actual = array.getMat();
|
||||||
|
|
||||||
ASSERT_EQ(expected.size(), actual.size())
|
if(expected.empty())
|
||||||
<< " Argument \"" << node.name() << "\" has unexpected size";
|
|
||||||
|
|
||||||
cv::Mat diff;
|
|
||||||
cv::absdiff(expected, actual, diff);
|
|
||||||
|
|
||||||
if (err == ERROR_ABSOLUTE)
|
|
||||||
{
|
{
|
||||||
if (!cv::checkRange(diff, true, 0, 0, eps))
|
ASSERT_TRUE(actual.empty())
|
||||||
{
|
<< " expected empty " << node.name();
|
||||||
double max;
|
|
||||||
cv::minMaxLoc(diff.reshape(1), 0, &max);
|
|
||||||
FAIL() << " Difference (=" << max << ") between argument \"" << node.name()
|
|
||||||
<< "\" and expected value is bugger than " << eps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (err == ERROR_RELATIVE)
|
else
|
||||||
{
|
{
|
||||||
double maxv, maxa;
|
ASSERT_EQ(expected.size(), actual.size())
|
||||||
int violations = countViolations(expected, actual, diff, eps, &maxv, &maxa);
|
<< " Argument \"" << node.name() << "\" has unexpected size";
|
||||||
if (violations > 0)
|
|
||||||
|
cv::Mat diff;
|
||||||
|
cv::absdiff(expected, actual, diff);
|
||||||
|
|
||||||
|
if (err == ERROR_ABSOLUTE)
|
||||||
{
|
{
|
||||||
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \"" << node.name()
|
if (!cv::checkRange(diff, true, 0, 0, eps))
|
||||||
<< "\" and expected value is bugger than " << eps << " in " << violations << " points";
|
{
|
||||||
|
if(expected.total() * expected.channels() < 12)
|
||||||
|
std::cout << " Expected: " << std::endl << expected << std::endl << " Actual:" << std::endl << actual << std::endl;
|
||||||
|
|
||||||
|
double max;
|
||||||
|
cv::minMaxLoc(diff.reshape(1), 0, &max);
|
||||||
|
|
||||||
|
FAIL() << " Difference (=" << max << ") between argument1 \"" << node.name()
|
||||||
|
<< "\" and expected value is bugger than " << eps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (err == ERROR_RELATIVE)
|
||||||
|
{
|
||||||
|
double maxv, maxa;
|
||||||
|
int violations = countViolations(expected, actual, diff, eps, &maxv, &maxa);
|
||||||
|
if (violations > 0)
|
||||||
|
{
|
||||||
|
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \"" << node.name()
|
||||||
|
<< "\" and expected value is bugger than " << eps << " in " << violations << " points";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user