Commit 094a63c8 authored by Victor Erukhimov's avatar Victor Erukhimov

Fixing a problem with SURF detector crash due to large keypoint sizes

parent 9ee99f1f
...@@ -199,7 +199,16 @@ icvInterpolateKeypoint( float N9[3][9], int dx, int dy, int ds, CvSURFPoint *poi ...@@ -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.x += x[0]*dx;
point->pt.y += x[1]*dy; 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; return solve_ok;
} }
...@@ -267,7 +276,6 @@ static CvSeq* icvFastHessianDetector( const CvMat* sum, const CvMat* mask_sum, ...@@ -267,7 +276,6 @@ static CvSeq* icvFastHessianDetector( const CvMat* sum, const CvMat* mask_sum,
icvResizeHaarPattern( dx_s, Dx, NX, 9, size, sum->cols ); icvResizeHaarPattern( dx_s, Dx, NX, 9, size, sum->cols );
icvResizeHaarPattern( dy_s, Dy, NY, 9, size, sum->cols ); icvResizeHaarPattern( dy_s, Dy, NY, 9, size, sum->cols );
icvResizeHaarPattern( dxy_s, Dxy, NXY, 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; margin = (size/2)/sampleStep;
for( sum_i=0, i=margin; sum_i<=(sum->rows-1)-size; sum_i+=sampleStep, i++ ) for( sum_i=0, i=margin; sum_i<=(sum->rows-1)-size; sum_i+=sampleStep, i++ )
...@@ -434,7 +442,9 @@ struct SURFInvoker ...@@ -434,7 +442,9 @@ struct SURFInvoker
int maxSize = 0; int maxSize = 0;
for( k = k1; k < k2; k++ ) for( k = k1; k < k2; k++ )
{
maxSize = std::max(maxSize, ((CvSURFPoint*)cvGetSeqElem( keypoints, k ))->size); maxSize = std::max(maxSize, ((CvSURFPoint*)cvGetSeqElem( keypoints, k ))->size);
}
maxSize = cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f); maxSize = cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f);
Ptr<CvMat> winbuf = cvCreateMat( 1, maxSize > 0 ? maxSize*maxSize : 1, CV_8U ); Ptr<CvMat> winbuf = cvCreateMat( 1, maxSize > 0 ? maxSize*maxSize : 1, CV_8U );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment