From b12588f7024069132ee702a9788cc5f3cd3cd9a0 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Thu, 11 Nov 2010 15:45:54 +0000 Subject: [PATCH] fixed MserFeatureDetector --- modules/features2d/src/detectors.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index e9a837d60a..3dd999eae7 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -202,19 +202,18 @@ void MserFeatureDetector::detect( const Mat& image, vector& keypoints, { vector > msers; - Mat grayImage = image; - if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY ); + mser(image, msers, mask); - mser(grayImage, msers, mask); - - keypoints.resize( msers.size() ); + keypoints.clear(); vector >::const_iterator contour_it = msers.begin(); - vector::iterator keypoint_it = keypoints.begin(); - for( ; contour_it != msers.end(); ++contour_it, ++keypoint_it ) + for( ; contour_it != msers.end(); ++contour_it ) { // TODO check transformation from MSER region to KeyPoint RotatedRect rect = fitEllipse(Mat(*contour_it)); - *keypoint_it = KeyPoint( rect.center, sqrt(rect.size.height*rect.size.width), rect.angle); + float diam = sqrt(rect.size.height*rect.size.width); + + if( diam > std::numeric_limits::epsilon() ) + keypoints.push_back( KeyPoint( rect.center, diam, rect.angle) ); } }