From 99d914ea3b16475a55529210da3b36120aefec8d Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Sat, 11 Jun 2016 17:51:46 +0200 Subject: [PATCH] [move sift.cpp] fix overflow issue when computing diagonal - with big images the int multiplication can overflow original commit: https://github.com/opencv/opencv_contrib/commit/d4df727d380887fdd880fdb5430cf4680a4ad19b --- modules/features2d/src/sift.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/src/sift.cpp b/modules/features2d/src/sift.cpp index 9c3d2117b7..f14577bc35 100644 --- a/modules/features2d/src/sift.cpp +++ b/modules/features2d/src/sift.cpp @@ -544,7 +544,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc 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)); + radius = std::min(radius, (int) sqrt(((double) img.cols)*img.cols + ((double) img.rows)*img.rows)); cos_t /= hist_width; sin_t /= hist_width;