From 491e3627b6ad23fc23e5ffbfe7ab45925b44f6f5 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 17 May 2018 15:30:11 +0300 Subject: [PATCH] photo: initialize cos() table with double type This avoids MSVC 19.14.26428.1 to call vectorized __vdecl_cosf4() function with less precision. --- modules/photo/src/seamless_cloning_impl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/photo/src/seamless_cloning_impl.cpp b/modules/photo/src/seamless_cloning_impl.cpp index 6073a9bc4c..2d710cc61e 100644 --- a/modules/photo/src/seamless_cloning_impl.cpp +++ b/modules/photo/src/seamless_cloning_impl.cpp @@ -251,13 +251,15 @@ void Cloning::initVariables(const Mat &destination, const Mat &binaryMask) //init of the filters used in the dst const int w = destination.cols; filter_X.resize(w - 2); + double scale = CV_PI / (w - 1); for(int i = 0 ; i < w-2 ; ++i) - filter_X[i] = 2.0f * std::cos(static_cast(CV_PI) * (i + 1) / (w - 1)); + filter_X[i] = 2.0f * (float)std::cos(scale * (i + 1)); const int h = destination.rows; filter_Y.resize(h - 2); + scale = CV_PI / (h - 1); for(int j = 0 ; j < h - 2 ; ++j) - filter_Y[j] = 2.0f * std::cos(static_cast(CV_PI) * (j + 1) / (h - 1)); + filter_Y[j] = 2.0f * (float)std::cos(scale * (j + 1)); } void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask)