From b644505bdf1edb48345886ef001164782e34edbe Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Tue, 31 May 2011 22:51:16 +0000 Subject: [PATCH] fixed compilation problems with new SIFT on Windows --- modules/features2d/src/sift.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/features2d/src/sift.cpp b/modules/features2d/src/sift.cpp index 5ba472ca9d..8d5831d69d 100644 --- a/modules/features2d/src/sift.cpp +++ b/modules/features2d/src/sift.cpp @@ -315,7 +315,12 @@ static IplImage*** build_gauss_pyr( IplImage* base, int octvs, { IplImage*** gauss_pyr; const int _intvls = intvls; - double sig[_intvls+3], sig_total, sig_prev, k; +#if defined WIN32 || defined _WIN32 || defined WINCE + double *sig = new double[_intvls+3]; +#else + double sig[_intvls+3]; +#endif + double sig_total, sig_prev, k; int i, o; gauss_pyr = (IplImage***)calloc( octvs, sizeof( IplImage** ) ); @@ -342,7 +347,7 @@ static IplImage*** build_gauss_pyr( IplImage* base, int octvs, if( o == 0 && i == 0 ) gauss_pyr[o][i] = cvCloneImage(base); - /* base of new octvave is halved image from end of previous octave */ + /* base of new octave is halved image from end of previous octave */ else if( i == 0 ) gauss_pyr[o][i] = downsample( gauss_pyr[o-1][intvls] ); @@ -356,6 +361,10 @@ static IplImage*** build_gauss_pyr( IplImage* base, int octvs, } } +#if defined WIN32 || defined _WIN32 || defined WINCE + delete[] sig; +#endif + return gauss_pyr; } @@ -1102,7 +1111,7 @@ static double*** descr_hist( IplImage* img, int r, int c, double ori, bins_per_rad = n / PI2; exp_denom = d * d * 0.5; hist_width = SIFT_DESCR_SCL_FCTR * scl; - radius = hist_width * sqrt(2) * ( d + 1.0 ) * 0.5 + 0.5; + radius = hist_width * sqrt(2.0) * ( d + 1.0 ) * 0.5 + 0.5; for( i = -radius; i <= radius; i++ ) for( j = -radius; j <= radius; j++ ) { @@ -1291,7 +1300,7 @@ struct ImagePyrData /* build scale space pyramid; smallest dimension of top level is ~4 pixels */ init_img = create_init_img( img, img_dbl, _sigma ); - int max_octvs = log( MIN( init_img->width, init_img->height ) ) / log(2) - 2; + int max_octvs = static_cast( log( static_cast(MIN( init_img->width, init_img->height ))) / log(2.0) - 2.0); octvs = std::max( std::min( octvs, max_octvs ), 1 ); gauss_pyr = build_gauss_pyr( init_img, octvs, intvls, _sigma ); @@ -1537,7 +1546,7 @@ static void fillFeatureData( feature& feat, const SiftParams& params ) int o, ix, iy, is; float s, phi; - phi = log2( sigma / params.sigma0 ) ; + phi = static_cast(log( sigma / params.sigma0 ) / log(2.0)); o = std::floor( phi - (float(params.smin)+.5)/params.S ); o = std::min(o, params.omin+params.O-1); o = std::max(o, params.omin);