From f6c802b5638fd6d25cb6f3ac77eaea8d8aaab02f Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Tue, 24 Sep 2013 09:01:20 +0200 Subject: [PATCH] Applied fix suggested in bug 3282 and shortened code --- modules/nonfree/src/sift.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/nonfree/src/sift.cpp b/modules/nonfree/src/sift.cpp index 5a7fd8940..64b17c362 100644 --- a/modules/nonfree/src/sift.cpp +++ b/modules/nonfree/src/sift.cpp @@ -543,6 +543,8 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc float exp_scale = -1.f/(d * d * 0.5f); float hist_width = SIFT_DESCR_SCL_FCTR * scl; int radius = cvRound(hist_width * 1.4142135623730951f * (d + 1) * 0.5f); + // Clip the radius to the diagonal of the image to avoid autobuffer too large exception + radius = std::min(radius, (int) sqrt((double) img.cols*img.cols + img.rows*img.rows)); cos_t /= hist_width; sin_t /= hist_width;