From 094a63c8387e91f64ce0343192189b7ad39695a3 Mon Sep 17 00:00:00 2001 From: Victor Erukhimov Date: Sun, 24 Oct 2010 12:36:47 +0000 Subject: [PATCH] Fixing a problem with SURF detector crash due to large keypoint sizes --- modules/features2d/src/surf.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/features2d/src/surf.cpp b/modules/features2d/src/surf.cpp index 7c96b01..5552ed3 100644 --- a/modules/features2d/src/surf.cpp +++ b/modules/features2d/src/surf.cpp @@ -199,7 +199,16 @@ icvInterpolateKeypoint( float N9[3][9], int dx, int dy, int ds, CvSURFPoint *poi { point->pt.x += x[0]*dx; point->pt.y += x[1]*dy; - point->size = cvRound( point->size + x[2]*ds ); + // TBD quick fix to be reviewed + if(x[2]*ds/point->size > 10) + { + //printf("Replacing point size %d with %f\n", point->size, x[2]*ds); + + } + else + { + point->size = cvRound( point->size + x[2]*ds ); + } } return solve_ok; } @@ -267,7 +276,6 @@ static CvSeq* icvFastHessianDetector( const CvMat* sum, const CvMat* mask_sum, icvResizeHaarPattern( dx_s, Dx, NX, 9, size, sum->cols ); icvResizeHaarPattern( dy_s, Dy, NY, 9, size, sum->cols ); icvResizeHaarPattern( dxy_s, Dxy, NXY, 9, size, sum->cols ); - /*printf( "octave=%d layer=%d size=%d rows=%d cols=%d\n", octave, layer, size, rows, cols );*/ margin = (size/2)/sampleStep; for( sum_i=0, i=margin; sum_i<=(sum->rows-1)-size; sum_i+=sampleStep, i++ ) @@ -434,7 +442,9 @@ struct SURFInvoker int maxSize = 0; for( k = k1; k < k2; k++ ) + { maxSize = std::max(maxSize, ((CvSURFPoint*)cvGetSeqElem( keypoints, k ))->size); + } maxSize = cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f); Ptr winbuf = cvCreateMat( 1, maxSize > 0 ? maxSize*maxSize : 1, CV_8U ); -- 2.7.4