From ac2d79fd670035429053a9cd305b99fd88f7fa8c Mon Sep 17 00:00:00 2001 From: will hunt Date: Sun, 7 Aug 2016 08:38:38 +0800 Subject: [PATCH] MSER: all test passed. 1. if a component's variation is a global minimum than it should be a local minimum 2. for the small image with invert and blur, the MSERs number should be 20 --- modules/features2d/src/mser.cpp | 2 +- modules/features2d/test/test_mser.cpp | 2 +- modules/python/test/test_mser.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index 669e3877d8..8f43eeaa38 100644 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -211,7 +211,7 @@ public: return; } } - if( parent_ && parent_->var >= 0.f && var >= parent_->var ) + if( var > 0.f && parent_ && parent_->var >= 0.f && var >= parent_->var ) return; int xmin = INT_MAX, ymin = INT_MAX, xmax = INT_MIN, ymax = INT_MIN, j = 0; wp.msers->push_back(vector()); diff --git a/modules/features2d/test/test_mser.cpp b/modules/features2d/test/test_mser.cpp index 89b8ddbade..a52c3c3b81 100644 --- a/modules/features2d/test/test_mser.cpp +++ b/modules/features2d/test/test_mser.cpp @@ -132,7 +132,7 @@ TEST(Features2d_MSER, cases) GaussianBlur(src, src, Size(5, 5), 1.5, 1.5); int minRegs = use_big_image ? 7 : 2; - int maxRegs = use_big_image ? 1000 : 15; + int maxRegs = use_big_image ? 1000 : 20; if( binarize && (thresh == 0 || thresh == 255) ) minRegs = maxRegs = 0; diff --git a/modules/python/test/test_mser.py b/modules/python/test/test_mser.py index 619300b865..f66582ee4b 100644 --- a/modules/python/test/test_mser.py +++ b/modules/python/test/test_mser.py @@ -59,11 +59,11 @@ class mser_test(NewOpenCVTests): if blur: src = cv2.GaussianBlur(src, (5, 5), 1.5, 1.5) minRegs = 7 if use_big_image else 2 - maxRegs = 1000 if use_big_image else 15 + maxRegs = 1000 if use_big_image else 20 if binarize and (thresh == 0 or thresh == 255): minRegs = maxRegs = 0 msers, boxes = mserExtractor.detectRegions(src) nmsers = len(msers) self.assertEqual(nmsers, len(boxes)) self.assertLessEqual(minRegs, nmsers) - self.assertGreaterEqual(maxRegs, nmsers) \ No newline at end of file + self.assertGreaterEqual(maxRegs, nmsers)