From 7fe4fbfc68cfcd3c9550119b41edc4adc79e97d2 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Fri, 12 Nov 2010 13:24:20 +0000 Subject: [PATCH] modified grabCut test to stable verification --- tests/cv/src/grabcut.cpp | 22 ++++++++++------------ tests/cv/src/tsysa.cpp | 1 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/cv/src/grabcut.cpp b/tests/cv/src/grabcut.cpp index 21d90ebb3..22e33ac57 100644 --- a/tests/cv/src/grabcut.cpp +++ b/tests/cv/src/grabcut.cpp @@ -52,7 +52,8 @@ class CV_GrabcutTest : public CvTest public: CV_GrabcutTest(); ~CV_GrabcutTest(); -protected: +protected: + bool verify(const Mat& mask, const Mat& exp); void run(int); }; @@ -62,18 +63,15 @@ CV_GrabcutTest::CV_GrabcutTest(): CvTest( "segmentation-grabcut", "cv::grabCut" } CV_GrabcutTest::~CV_GrabcutTest() {} -bool verify(const Mat& mask, const Mat& exp) -{ - if (0 == norm(mask, exp, NORM_INF)) - return true; +bool CV_GrabcutTest::verify(const Mat& mask, const Mat& exp) +{ + const float maxDiffRatio = 0.005f; + int expArea = countNonZero( exp ); + int nonIntersectArea = countNonZero( mask != exp ); - Mat mask_dilated, exp_dilated; - - 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; + float curRatio = (float)nonIntersectArea / (float)expArea; + ts->printf( CvTS::LOG, "nonIntersectArea/expArea = %f\n", curRatio ); + return curRatio < maxDiffRatio; } void CV_GrabcutTest::run( int /* start_from */) diff --git a/tests/cv/src/tsysa.cpp b/tests/cv/src/tsysa.cpp index a79653c51..d7dba13fc 100644 --- a/tests/cv/src/tsysa.cpp +++ b/tests/cv/src/tsysa.cpp @@ -53,7 +53,6 @@ const char* blacklist[] = "latentsvmdetector", //ticket 661 "warp-affine", //ticket 572 "warp-perspective", //ticket 575 - "segmentation-grabcut", //ticket 666 "_3d-fundam", //ticket 434 "posit", //ticket 430 0