From 41559d748150e5694decf78c2b0fc95bd8deb1e4 Mon Sep 17 00:00:00 2001
From: Yuriy Obukh <nosferatu@ipm.lviv.ua>
Date: Fri, 2 Jun 2017 23:47:04 +0300
Subject: [PATCH] Some changes to make VS2010 compiler happy.

---
 modules/optflow/perf/opencl/perf_dis_optflow.cpp          | 4 ++--
 modules/optflow/perf/perf_disflow.cpp                     | 4 ++--
 modules/optflow/src/sparse_matching_gpc.cpp               | 2 +-
 modules/optflow/test/test_OF_reproducibility.cpp          | 8 ++++----
 modules/structured_light/samples/projectorcalibration.cpp | 2 +-
 modules/structured_light/src/sinusoidalpattern.cpp        | 4 ++--
 modules/xfeatures2d/samples/pct_webcam.cpp                | 2 +-
 modules/ximgproc/src/bilateral_texture_filter.cpp         | 2 +-
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/modules/optflow/perf/opencl/perf_dis_optflow.cpp b/modules/optflow/perf/opencl/perf_dis_optflow.cpp
index cdbc61a53..251129d1a 100644
--- a/modules/optflow/perf/opencl/perf_dis_optflow.cpp
+++ b/modules/optflow/perf/opencl/perf_dis_optflow.cpp
@@ -92,12 +92,12 @@ void MakeArtificialExample(UMat &dst_frame1, UMat &dst_frame2)
     int OF_scale = 6;
     double sigma = dst_frame1.cols / 300;
 
-    UMat tmp(Size(dst_frame1.cols / (int)pow(2, src_scale), dst_frame1.rows / (int)pow(2, src_scale)), CV_8U);
+    UMat tmp(Size(dst_frame1.cols / (1 << src_scale), dst_frame1.rows / (1 << src_scale)), CV_8U);
     randu(tmp, 0, 255);
     resize(tmp, dst_frame1, dst_frame1.size(), 0.0, 0.0, INTER_LINEAR);
     resize(tmp, dst_frame2, dst_frame2.size(), 0.0, 0.0, INTER_LINEAR);
 
-    Mat displacement_field(Size(dst_frame1.cols / (int)pow(2, OF_scale), dst_frame1.rows / (int)pow(2, OF_scale)),
+    Mat displacement_field(Size(dst_frame1.cols / (1 << OF_scale), dst_frame1.rows / (1 << OF_scale)),
                            CV_32FC2);
     randn(displacement_field, 0.0, sigma);
     resize(displacement_field, displacement_field, dst_frame2.size(), 0.0, 0.0, INTER_CUBIC);
diff --git a/modules/optflow/perf/perf_disflow.cpp b/modules/optflow/perf/perf_disflow.cpp
index 12a620310..5826c0602 100644
--- a/modules/optflow/perf/perf_disflow.cpp
+++ b/modules/optflow/perf/perf_disflow.cpp
@@ -86,12 +86,12 @@ void MakeArtificialExample(Mat &dst_frame1, Mat &dst_frame2)
     int OF_scale = 6;
     double sigma = dst_frame1.cols / 300;
 
-    Mat tmp(Size(dst_frame1.cols / (int)pow(2, src_scale), dst_frame1.rows / (int)pow(2, src_scale)), CV_8U);
+    Mat tmp(Size(dst_frame1.cols / (1 << src_scale), dst_frame1.rows / (1 << src_scale)), CV_8U);
     randu(tmp, 0, 255);
     resize(tmp, dst_frame1, dst_frame1.size(), 0.0, 0.0, INTER_LINEAR);
     resize(tmp, dst_frame2, dst_frame2.size(), 0.0, 0.0, INTER_LINEAR);
 
-    Mat displacement_field(Size(dst_frame1.cols / (int)pow(2, OF_scale), dst_frame1.rows / (int)pow(2, OF_scale)),
+    Mat displacement_field(Size(dst_frame1.cols / (1 << OF_scale), dst_frame1.rows / (1 << OF_scale)),
                            CV_32FC2);
     randn(displacement_field, 0.0, sigma);
     resize(displacement_field, displacement_field, dst_frame2.size(), 0.0, 0.0, INTER_CUBIC);
diff --git a/modules/optflow/src/sparse_matching_gpc.cpp b/modules/optflow/src/sparse_matching_gpc.cpp
index 25ccd62c0..86b70c9bc 100644
--- a/modules/optflow/src/sparse_matching_gpc.cpp
+++ b/modules/optflow/src/sparse_matching_gpc.cpp
@@ -570,7 +570,7 @@ bool GPCTree::trainNode( size_t nodeId, SIter begin, SIter end, unsigned depth )
         localBestScore = score;
       else
       {
-        const double beta = simulatedAnnealingTemperatureCoef * std::sqrt( i ) / ( nSamples * ( scoreGainPos + scoreGainNeg ) );
+        const double beta = simulatedAnnealingTemperatureCoef * std::sqrt( static_cast<float>(i) ) / ( nSamples * ( scoreGainPos + scoreGainNeg ) );
         if ( rng.uniform( 0.0, 1.0 ) > std::exp( -beta * ( localBestScore - score) ) )
           coef[pos] = randomModification;
       }
diff --git a/modules/optflow/test/test_OF_reproducibility.cpp b/modules/optflow/test/test_OF_reproducibility.cpp
index 0cdbd50fd..7b9905576 100644
--- a/modules/optflow/test/test_OF_reproducibility.cpp
+++ b/modules/optflow/test/test_OF_reproducibility.cpp
@@ -100,8 +100,8 @@ TEST_P(DenseOpticalFlow_DIS, MultithreadReproducibility)
         // resulting flow should be within the frame bounds:
         double min_val, max_val;
         minMaxLoc(resMultiThread, &min_val, &max_val);
-        EXPECT_LE(abs(min_val), sqrt(size.height * size.height + size.width * size.width));
-        EXPECT_LE(abs(max_val), sqrt(size.height * size.height + size.width * size.width));
+        EXPECT_LE(abs(min_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
+        EXPECT_LE(abs(max_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
     }
 }
 
@@ -151,8 +151,8 @@ TEST_P(DenseOpticalFlow_VariationalRefinement, MultithreadReproducibility)
         // resulting flow should be within the frame bounds:
         double min_val, max_val;
         minMaxLoc(resMultiThread, &min_val, &max_val);
-        EXPECT_LE(abs(min_val), sqrt(size.height * size.height + size.width * size.width));
-        EXPECT_LE(abs(max_val), sqrt(size.height * size.height + size.width * size.width));
+        EXPECT_LE(abs(min_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
+        EXPECT_LE(abs(max_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
     }
 }
 
diff --git a/modules/structured_light/samples/projectorcalibration.cpp b/modules/structured_light/samples/projectorcalibration.cpp
index d5bfb5554..77b6e205b 100644
--- a/modules/structured_light/samples/projectorcalibration.cpp
+++ b/modules/structured_light/samples/projectorcalibration.cpp
@@ -477,7 +477,7 @@ void normalize( const Mat &pts, const int& dim, Mat& normpts, Mat &T )
         averagedist = averagedist+(float)norm(ptstmp);
     }
     averagedist = averagedist / normpts.cols;
-    scale = (float)(sqrt(dim) / averagedist);
+    scale = (float)(sqrt(static_cast<float>(dim)) / averagedist);
 
     normpts = normpts * scale;
 
diff --git a/modules/structured_light/src/sinusoidalpattern.cpp b/modules/structured_light/src/sinusoidalpattern.cpp
index bc26b2026..28ee08f48 100644
--- a/modules/structured_light/src/sinusoidalpattern.cpp
+++ b/modules/structured_light/src/sinusoidalpattern.cpp
@@ -200,12 +200,12 @@ bool SinusoidalPatternProfilometry_Impl::generate( OutputArrayOfArrays pattern )
     if( params.horizontal )
     {
         period = params.height / params.nbrOfPeriods;
-        nbrOfMarkersOnOneRow = (int)floor((params.width - firstMarkerOffset) / m);
+        nbrOfMarkersOnOneRow = (int)floor(static_cast<float>((params.width - firstMarkerOffset) / m));
     }
     else
     {
         period = params.width / params.nbrOfPeriods;
-        nbrOfMarkersOnOneRow = (int)floor((params.height - firstMarkerOffset) / m);
+        nbrOfMarkersOnOneRow = (int)floor(static_cast<float>((params.height - firstMarkerOffset) / m));
     }
     frequency = (float) 1 / period;
 
diff --git a/modules/xfeatures2d/samples/pct_webcam.cpp b/modules/xfeatures2d/samples/pct_webcam.cpp
index 0f8e701c5..a524eb1fd 100644
--- a/modules/xfeatures2d/samples/pct_webcam.cpp
+++ b/modules/xfeatures2d/samples/pct_webcam.cpp
@@ -117,7 +117,7 @@ int main(int argc, char** argv)
             cerr << "Sample count have to be a positive integer: " << argv[1] << endl;
             return 1;
         }
-        initSeedCount = (int)floor(initSampleCount / 4);
+        initSeedCount = (int)floor(static_cast<float>(initSampleCount / 4));
         initSeedCount = std::max(1, initSeedCount);     // fallback if sample count == 1
     }
     if (argc > 2)               // seed count
diff --git a/modules/ximgproc/src/bilateral_texture_filter.cpp b/modules/ximgproc/src/bilateral_texture_filter.cpp
index 5be6c0a6b..2a37dc99d 100644
--- a/modules/ximgproc/src/bilateral_texture_filter.cpp
+++ b/modules/ximgproc/src/bilateral_texture_filter.cpp
@@ -63,7 +63,7 @@ namespace ximgproc
     if (sigmaAlpha < 0)
       sigmaAlpha = 5. * fr;
     if (sigmaAvg < 0)
-      sigmaAvg = 0.05 * sqrt(src.channels());
+      sigmaAvg = 0.05 * sqrt(static_cast<float>(src.channels()));
 
     Mat I;
     src.copyTo(I);