From af58e08ee22bb7618d7275c994c6b64fdea4a77d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 8 Feb 2018 16:00:41 +0300 Subject: [PATCH] build: fix C++17 build --- modules/optflow/src/sparse_matching_gpc.cpp | 10 +++++++++- .../xfeatures2d/samples/bagofwords_classification.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/optflow/src/sparse_matching_gpc.cpp b/modules/optflow/src/sparse_matching_gpc.cpp index 343b11604..6c485e160 100644 --- a/modules/optflow/src/sparse_matching_gpc.cpp +++ b/modules/optflow/src/sparse_matching_gpc.cpp @@ -40,13 +40,16 @@ // //M*/ +#include "precomp.hpp" #include "opencv2/core/core_c.h" #include "opencv2/core/private.hpp" #include "opencv2/flann/miniflann.hpp" #include "opencv2/imgcodecs.hpp" -#include "precomp.hpp" #include "opencl_kernels_optflow.hpp" #include "opencv2/core/hal/intrin.hpp" +#ifdef CV_CXX11 +#include // std::mt19937 +#endif /* Disable "from double to float" and "from size_t to int" warnings. * Fixing these would make the code look ugly by introducing explicit cast all around. @@ -402,7 +405,12 @@ void getTrainingSamples( const Mat &from, const Mat &to, const Mat >, GPCSampl // with a small displacement and train to better distinguish hard pairs. std::nth_element( mag.begin(), mag.begin() + n, mag.end() ); mag.resize( n ); +#ifdef CV_CXX11 + std::mt19937 std_rng(cv::theRNG()()); + std::shuffle(mag.begin(), mag.end(), std_rng); +#else std::random_shuffle( mag.begin(), mag.end() ); +#endif n /= patchRadius; mag.resize( n ); diff --git a/modules/xfeatures2d/samples/bagofwords_classification.cpp b/modules/xfeatures2d/samples/bagofwords_classification.cpp index 8ef7497eb..13a19a316 100644 --- a/modules/xfeatures2d/samples/bagofwords_classification.cpp +++ b/modules/xfeatures2d/samples/bagofwords_classification.cpp @@ -864,7 +864,12 @@ void VocData::calcPrecRecall_impl(const vector& ground_truth, const vector { recall_norm = recall_normalization; } else { +#ifdef CV_CXX11 + recall_norm = (int)std::count_if(ground_truth.begin(),ground_truth.end(), + [](const char a) { return a == (char)1; }); +#else recall_norm = (int)std::count_if(ground_truth.begin(),ground_truth.end(),std::bind2nd(std::equal_to(),(char)1)); +#endif } ap = 0; @@ -994,7 +999,12 @@ void VocData::calcClassifierConfMatRow(const string& obj_class, const vector(),(char)1)); +#endif } /* iterate through images */