From 1e122c19e13532bed954cd90e756edf1aac0a5e1 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Thu, 11 Nov 2010 17:07:05 +0000 Subject: [PATCH] modified grabCut test slightly; updated test data due to latest grabCut() fix (#666) --- tests/cv/src/grabcut.cpp | 31 ++++++++++++++++++++++--------- tests/cv/src/tsysa.cpp | 1 - 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/cv/src/grabcut.cpp b/tests/cv/src/grabcut.cpp index 5fe828cfc..21d90ebb3 100644 --- a/tests/cv/src/grabcut.cpp +++ b/tests/cv/src/grabcut.cpp @@ -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; diff --git a/tests/cv/src/tsysa.cpp b/tests/cv/src/tsysa.cpp index e9481d021..febcc73e1 100644 --- a/tests/cv/src/tsysa.cpp +++ b/tests/cv/src/tsysa.cpp @@ -51,7 +51,6 @@ const char* blacklist[] = "subdiv", //ticket 454 "warp-resize", //ticket 429 "latentsvmdetector", //ticket 661 - "segmentation-grabcut", //ticket 666 0 };