From: Maria Dimashova Date: Thu, 11 Nov 2010 15:45:54 +0000 (+0000) Subject: fixed MserFeatureDetector X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~8454 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b12588f7024069132ee702a9788cc5f3cd3cd9a0;p=platform%2Fupstream%2Fopencv.git fixed MserFeatureDetector --- diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index e9a837d..3dd999e 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(grayImage, msers, mask); + mser(image, 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) ); } }