modified grabCut test slightly; updated test data due to latest grabCut() fix (#666)
This commit is contained in:
parent
cb3711d51d
commit
1e122c19e1
@ -72,7 +72,7 @@ bool verify(const Mat& mask, const Mat& exp)
|
||||
const int inter_num = 2;
|
||||
dilate(mask, mask_dilated, Mat(), Point(-1, -1), inter_num);
|
||||
dilate(exp, exp_dilated, Mat(), Point(-1, -1), inter_num);
|
||||
|
||||
|
||||
return countNonZero(mask-exp_dilated) + countNonZero(mask_dilated-exp) == 0;
|
||||
}
|
||||
|
||||
@ -85,9 +85,9 @@ void CV_GrabcutTest::run( int /* start_from */)
|
||||
Mat exp_mask1 = imread(string(ts->get_data_path()) + "grabcut/exp_mask1.png", 0);
|
||||
Mat exp_mask2 = imread(string(ts->get_data_path()) + "grabcut/exp_mask2.png", 0);
|
||||
|
||||
if (img.empty() || mask_prob.empty() || exp_mask1.empty() || exp_mask2.empty() ||
|
||||
img.size() != mask_prob.size() || mask_prob.size() != exp_mask1.size() ||
|
||||
exp_mask1.size() != exp_mask2.size())
|
||||
if (img.empty() || (!mask_prob.empty() && img.size() != mask_prob.size()) ||
|
||||
(!exp_mask1.empty() && img.size() != exp_mask1.size()) ||
|
||||
(!exp_mask2.empty() && img.size() != exp_mask2.size()) )
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
|
||||
return;
|
||||
@ -102,10 +102,19 @@ void CV_GrabcutTest::run( int /* start_from */)
|
||||
grabCut( img, mask, rect, bgdModel, fgdModel, 0, GC_INIT_WITH_RECT );
|
||||
grabCut( img, mask, rect, bgdModel, fgdModel, 2, GC_EVAL );
|
||||
|
||||
//imwrite(string(ts->get_data_path()) + "grabcut/mask_prob.png", mask_prob);
|
||||
//imwrite(string(ts->get_data_path()) + "grabcut/exp_mask1.png", mask);
|
||||
// Multiply images by 255 for more visuality of test data.
|
||||
if( mask_prob.empty() )
|
||||
{
|
||||
mask.copyTo( mask_prob );
|
||||
imwrite(string(ts->get_data_path()) + "grabcut/mask_prob.png", mask_prob);
|
||||
}
|
||||
if( exp_mask1.empty() )
|
||||
{
|
||||
exp_mask1 = (mask & 1) * 255;
|
||||
imwrite(string(ts->get_data_path()) + "grabcut/exp_mask1.png", exp_mask1);
|
||||
}
|
||||
|
||||
if (!verify(mask & 1, exp_mask1))
|
||||
if (!verify((mask & 1) * 255, exp_mask1))
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISMATCH);
|
||||
return;
|
||||
@ -118,9 +127,13 @@ void CV_GrabcutTest::run( int /* start_from */)
|
||||
grabCut( img, mask, rect, bgdModel, fgdModel, 0, GC_INIT_WITH_MASK );
|
||||
grabCut( img, mask, rect, bgdModel, fgdModel, 1, GC_EVAL );
|
||||
|
||||
//imwrite(string(ts->get_data_path()) + "grabcut/exp_mask2.png", mask);
|
||||
if( exp_mask2.empty() )
|
||||
{
|
||||
exp_mask2 = (mask & 1) * 255;
|
||||
imwrite(string(ts->get_data_path()) + "grabcut/exp_mask2.png", exp_mask2);
|
||||
}
|
||||
|
||||
if (!verify(mask & 1, exp_mask2))
|
||||
if (!verify((mask & 1) * 255, exp_mask2))
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISMATCH);
|
||||
return;
|
||||
|
@ -51,7 +51,6 @@ const char* blacklist[] =
|
||||
"subdiv", //ticket 454
|
||||
"warp-resize", //ticket 429
|
||||
"latentsvmdetector", //ticket 661
|
||||
"segmentation-grabcut", //ticket 666
|
||||
0
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user