From a69804e1581fa939f8e90e71ea37144545e2509b Mon Sep 17 00:00:00 2001 From: Liu Liu Date: Tue, 18 May 2010 07:16:24 +0000 Subject: [PATCH] fixed the error in SURF when no keypoint detected --- modules/features2d/src/surf.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/features2d/src/surf.cpp b/modules/features2d/src/surf.cpp index 754b0dbed3..9dd1e844d3 100644 --- a/modules/features2d/src/surf.cpp +++ b/modules/features2d/src/surf.cpp @@ -352,8 +352,8 @@ static CvSeq* icvFastHessianDetector( const CvMat* sum, const CvMat* mask_sum, CvSURFPoint point = cvSURFPoint( cvPoint2D32f(center_j,center_i), CV_SIGN(trace_ptr[j]), sizes[layer], 0, val0 ); - - /* Interpolate maxima location within the 3x3x3 neighbourhood */ + + /* Interpolate maxima location within the 3x3x3 neighbourhood */ int ds = sizes[layer]-sizes[layer-1]; int interp_ok = icvInterpolateKeypoint( N9, sampleStep, sampleStep, ds, &point ); @@ -430,7 +430,7 @@ struct SURFInvoker CvMat _angle = cvMat(1, max_ori_samples, CV_32F, angle); CvMat _patch = cvMat(PATCH_SZ+1, PATCH_SZ+1, CV_8U, PATCH); - int k, k1 = range.begin(), k2 = range.end(); + int k, k1 = range.begin(), k2 = range.end(); int maxSize = 0; for( k = k1; k < k2; k++ ) @@ -662,7 +662,6 @@ const float SURFInvoker::DESC_SIGMA = 3.3f; } - CV_IMPL void cvExtractSURF( const CvArr* _img, const CvArr* _mask, CvSeq** _keypoints, CvSeq** _descriptors, @@ -761,10 +760,11 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask, } } cvScale( &_DW, &_DW, 1./gs ); - - cv::parallel_for(cv::BlockedRange(0, N), - cv::SURFInvoker(¶ms, keypoints, descriptors, img, sum, - apt, aptw, nangle0, &DW[0][0])); + + if ( N > 0 ) + cv::parallel_for(cv::BlockedRange(0, N), + cv::SURFInvoker(¶ms, keypoints, descriptors, img, sum, + apt, aptw, nangle0, &DW[0][0])); //cv::SURFInvoker(¶ms, keypoints, descriptors, img, sum, // apt, aptw, nangle0, &DW[0][0])(cv::BlockedRange(0, N));