Commit 1e122c19 authored by Maria Dimashova's avatar Maria Dimashova

modified grabCut test slightly; updated test data due to latest grabCut() fix (#666)

parent cb3711d5
...@@ -72,7 +72,7 @@ bool verify(const Mat& mask, const Mat& exp) ...@@ -72,7 +72,7 @@ bool verify(const Mat& mask, const Mat& exp)
const int inter_num = 2; const int inter_num = 2;
dilate(mask, mask_dilated, Mat(), Point(-1, -1), inter_num); dilate(mask, mask_dilated, Mat(), Point(-1, -1), inter_num);
dilate(exp, exp_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; return countNonZero(mask-exp_dilated) + countNonZero(mask_dilated-exp) == 0;
} }
...@@ -85,9 +85,9 @@ void CV_GrabcutTest::run( int /* start_from */) ...@@ -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_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); 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() || if (img.empty() || (!mask_prob.empty() && img.size() != mask_prob.size()) ||
img.size() != mask_prob.size() || mask_prob.size() != exp_mask1.size() || (!exp_mask1.empty() && img.size() != exp_mask1.size()) ||
exp_mask1.size() != exp_mask2.size()) (!exp_mask2.empty() && img.size() != exp_mask2.size()) )
{ {
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA); ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return; return;
...@@ -102,10 +102,19 @@ void CV_GrabcutTest::run( int /* start_from */) ...@@ -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, 0, GC_INIT_WITH_RECT );
grabCut( img, mask, rect, bgdModel, fgdModel, 2, GC_EVAL ); grabCut( img, mask, rect, bgdModel, fgdModel, 2, GC_EVAL );
//imwrite(string(ts->get_data_path()) + "grabcut/mask_prob.png", mask_prob); // Multiply images by 255 for more visuality of test data.
//imwrite(string(ts->get_data_path()) + "grabcut/exp_mask1.png", mask); 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); ts->set_failed_test_info(CvTS::FAIL_MISMATCH);
return; return;
...@@ -118,9 +127,13 @@ void CV_GrabcutTest::run( int /* start_from */) ...@@ -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, 0, GC_INIT_WITH_MASK );
grabCut( img, mask, rect, bgdModel, fgdModel, 1, GC_EVAL ); 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); ts->set_failed_test_info(CvTS::FAIL_MISMATCH);
return; return;
......
...@@ -51,7 +51,6 @@ const char* blacklist[] = ...@@ -51,7 +51,6 @@ const char* blacklist[] =
"subdiv", //ticket 454 "subdiv", //ticket 454
"warp-resize", //ticket 429 "warp-resize", //ticket 429
"latentsvmdetector", //ticket 661 "latentsvmdetector", //ticket 661
"segmentation-grabcut", //ticket 666
0 0
}; };
......
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