From 517062039e2078e86babdd87c7dfd2992e029c78 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 1 Apr 2013 17:29:10 +0400 Subject: [PATCH] Make core/internal.hpp a private header --- apps/traincascade/boost.cpp | 48 ++++++++ cmake/OpenCVModule.cmake | 2 +- include/opencv/cxmisc.h | 4 +- modules/calib3d/perf/perf_pnp.cpp | 5 +- modules/calib3d/src/precomp.hpp | 8 +- modules/calib3d/test/test_solvepnp_ransac.cpp | 5 +- modules/contrib/src/precomp.hpp | 8 +- modules/contrib/src/rgbdodometry.cpp | 1 - .../core/include/opencv2/core/operations.hpp | 101 ---------------- .../core/{internal.hpp => private.hpp} | 110 ++++++++++++++++++ modules/core/src/gl_core_3_1.cpp | 5 +- modules/core/src/precomp.hpp | 7 +- modules/features2d/src/matchers.cpp | 1 - modules/features2d/src/precomp.hpp | 6 +- .../flann/include/opencv2/flann/lsh_table.h | 2 +- modules/flann/src/precomp.hpp | 6 +- modules/gpu/perf/perf_precomp.hpp | 4 +- modules/gpu/src/precomp.hpp | 7 +- modules/gpu/test/test_precomp.hpp | 4 +- modules/highgui/src/precomp.hpp | 4 +- modules/highgui/test/test_precomp.hpp | 6 +- modules/imgproc/perf/perf_blur.cpp | 1 - modules/imgproc/src/precomp.hpp | 6 +- modules/legacy/src/precomp.hpp | 8 +- modules/ml/src/precomp.hpp | 6 +- modules/nonfree/src/precomp.hpp | 7 +- modules/objdetect/src/haar.cpp | 3 +- modules/objdetect/src/precomp.hpp | 7 +- .../objdetect/test/test_latentsvmdetector.cpp | 5 - modules/ocl/perf/precomp.hpp | 7 +- modules/ocl/src/precomp.hpp | 7 +- modules/ocl/test/precomp.hpp | 5 +- .../src/fast_nlmeans_denoising_invoker.hpp | 3 - ...fast_nlmeans_denoising_invoker_commons.hpp | 4 - .../fast_nlmeans_multi_denoising_invoker.hpp | 3 - modules/photo/src/precomp.hpp | 5 +- modules/softcascade/src/precomp.hpp | 7 +- modules/stitching/perf/perf_stich.cpp | 1 - modules/stitching/src/precomp.hpp | 6 +- modules/superres/perf/perf_precomp.hpp | 4 - modules/superres/src/precomp.hpp | 7 +- modules/superres/test/test_precomp.hpp | 4 - modules/ts/include/opencv2/ts.hpp | 3 +- modules/ts/include/opencv2/ts/ts_perf.hpp | 1 + modules/ts/src/gpu_perf.cpp | 3 +- modules/ts/src/precomp.hpp | 1 + modules/video/src/precomp.hpp | 8 +- modules/videostab/src/precomp.hpp | 6 +- modules/world/src/precomp.hpp | 4 - samples/cpp/build3dmodel.cpp | 90 ++++++++++++++ samples/gpu/driver_api_multi.cpp | 15 ++- samples/gpu/driver_api_stereo_multi.cpp | 15 ++- samples/gpu/multi.cpp | 16 ++- samples/gpu/stereo_multi.cpp | 16 ++- 54 files changed, 364 insertions(+), 264 deletions(-) rename modules/core/include/opencv2/core/{internal.hpp => private.hpp} (71%) diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index 4849839ab1..c5a89e45cf 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -5,6 +5,48 @@ #include #include "cxmisc.h" +#include "cvconfig.h" +#ifdef HAVE_TBB +# include "tbb/tbb_stddef.h" +# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 +# include "tbb/tbb.h" +# include "tbb/task.h" +# undef min +# undef max +# else +# undef HAVE_TBB +# endif +#endif + +#ifdef HAVE_TBB + typedef tbb::blocked_range BlockedRange; + + template static inline + void parallel_for( const BlockedRange& range, const Body& body ) + { + tbb::parallel_for(range, body); + } +#else + class BlockedRange + { + public: + BlockedRange() : _begin(0), _end(0), _grainsize(0) {} + BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {} + int begin() const { return _begin; } + int end() const { return _end; } + int grainsize() const { return _grainsize; } + + protected: + int _begin, _end, _grainsize; + }; + + template static inline + void parallel_for( const BlockedRange& range, const Body& body ) + { + body(range); + } +#endif + using namespace std; static inline double @@ -26,6 +68,12 @@ public: const T* arr; }; +static inline int cvAlign( int size, int align ) +{ + CV_DbgAssert( (align & (align-1)) == 0 && size < INT_MAX ); + return (size + align - 1) & -align; +} + #define CV_THRESHOLD_EPS (0.00001F) static const int MinBlockSize = 1 << 16; diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 6d18e47f6d..1ce9c8917c 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -535,7 +535,7 @@ macro(ocv_create_module) if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};") foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS}) string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}") - if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$") + if(hdr2 MATCHES "^(opencv2/.*)[^/]+.h(..)?$" AND NOT hdr2 MATCHES "opencv2/${the_module}/private.*") install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT main) endif() endforeach() diff --git a/include/opencv/cxmisc.h b/include/opencv/cxmisc.h index 6446944643..6c93a0cce4 100644 --- a/include/opencv/cxmisc.h +++ b/include/opencv/cxmisc.h @@ -1,6 +1,8 @@ #ifndef __OPENCV_OLD_CXMISC_H__ #define __OPENCV_OLD_CXMISC_H__ -#include "opencv2/core/internal.hpp" +#ifdef __cplusplus +# include "opencv2/core/utility.hpp" +#endif #endif diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index e0ffd70cfb..02ecd2c599 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -1,5 +1,8 @@ #include "perf_precomp.hpp" -#include "opencv2/core/internal.hpp" + +#ifdef HAVE_TBB +#include "tbb/task_scheduler_init.h" +#endif using namespace std; using namespace cv; diff --git a/modules/calib3d/src/precomp.hpp b/modules/calib3d/src/precomp.hpp index 7a7140d593..7cd4a4ec48 100644 --- a/modules/calib3d/src/precomp.hpp +++ b/modules/calib3d/src/precomp.hpp @@ -42,19 +42,13 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/calib3d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/features2d.hpp" - #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" -#include +#include "opencv2/core/private.hpp" #ifdef HAVE_TEGRA_OPTIMIZATION #include "opencv2/calib3d/calib3d_tegra.hpp" diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index dc66c1dc70..5cc39a0ea1 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -41,7 +41,10 @@ //M*/ #include "test_precomp.hpp" -#include "opencv2/core/internal.hpp" + +#ifdef HAVE_TBB +#include "tbb/task_scheduler_init.h" +#endif using namespace cv; using namespace std; diff --git a/modules/contrib/src/precomp.hpp b/modules/contrib/src/precomp.hpp index 59c76cf166..03ef4acc3b 100644 --- a/modules/contrib/src/precomp.hpp +++ b/modules/contrib/src/precomp.hpp @@ -43,18 +43,14 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/contrib.hpp" #include "opencv2/features2d.hpp" #include "opencv2/objdetect.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" - #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" + +#include "opencv2/core/private.hpp" namespace cv { diff --git a/modules/contrib/src/rgbdodometry.cpp b/modules/contrib/src/rgbdodometry.cpp index 1fa800b0ae..6e1f217d09 100644 --- a/modules/contrib/src/rgbdodometry.cpp +++ b/modules/contrib/src/rgbdodometry.cpp @@ -54,7 +54,6 @@ #include #include -#include "opencv2/core/internal.hpp" #if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3 # ifdef ANDROID template Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); } diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index a072b4ce4a..1118900cb4 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -808,107 +808,6 @@ inline FileNode FileStorage::getFirstTopLevelNode() const return it != r.end() ? *it : FileNode(); } -//////////////////////////////////////// Various algorithms //////////////////////////////////// - - - -// This function splits the input sequence or set into one or more equivalence classes and -// returns the vector of labels - 0-based class indexes for each element. -// predicate(a,b) returns true if the two sequence elements certainly belong to the same class. -// -// The algorithm is described in "Introduction to Algorithms" -// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets" -template int -partition( const std::vector<_Tp>& _vec, std::vector& labels, - _EqPredicate predicate=_EqPredicate()) -{ - int i, j, N = (int)_vec.size(); - const _Tp* vec = &_vec[0]; - - const int PARENT=0; - const int RANK=1; - - std::vector _nodes(N*2); - int (*nodes)[2] = (int(*)[2])&_nodes[0]; - - // The first O(N) pass: create N single-vertex trees - for(i = 0; i < N; i++) - { - nodes[i][PARENT]=-1; - nodes[i][RANK] = 0; - } - - // The main O(N^2) pass: merge connected components - for( i = 0; i < N; i++ ) - { - int root = i; - - // find root - while( nodes[root][PARENT] >= 0 ) - root = nodes[root][PARENT]; - - for( j = 0; j < N; j++ ) - { - if( i == j || !predicate(vec[i], vec[j])) - continue; - int root2 = j; - - while( nodes[root2][PARENT] >= 0 ) - root2 = nodes[root2][PARENT]; - - if( root2 != root ) - { - // unite both trees - int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; - if( rank > rank2 ) - nodes[root2][PARENT] = root; - else - { - nodes[root][PARENT] = root2; - nodes[root2][RANK] += rank == rank2; - root = root2; - } - CV_Assert( nodes[root][PARENT] < 0 ); - - int k = j, parent; - - // compress the path from node2 to root - while( (parent = nodes[k][PARENT]) >= 0 ) - { - nodes[k][PARENT] = root; - k = parent; - } - - // compress the path from node to root - k = i; - while( (parent = nodes[k][PARENT]) >= 0 ) - { - nodes[k][PARENT] = root; - k = parent; - } - } - } - } - - // Final O(N) pass: enumerate classes - labels.resize(N); - int nclasses = 0; - - for( i = 0; i < N; i++ ) - { - int root = i; - while( nodes[root][PARENT] >= 0 ) - root = nodes[root][PARENT]; - // re-use the rank as the class label - if( nodes[root][RANK] >= 0 ) - nodes[root][RANK] = ~nclasses++; - labels[i] = ~nodes[root][RANK]; - } - - return nclasses; -} - - ////////////////////////////////////////////////////////////////////////////// class CV_EXPORTS Formatter diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/private.hpp similarity index 71% rename from modules/core/include/opencv2/core/internal.hpp rename to modules/core/include/opencv2/core/private.hpp index d08bb001c8..14875008d9 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -151,6 +151,7 @@ namespace cv } + /****************************************************************************************\ * Common declarations * \****************************************************************************************/ @@ -187,6 +188,8 @@ static inline cv::Size cvGetMatSize( const CvMat* mat ) return cv::Size(mat->cols, mat->rows); } + + /****************************************************************************************\ * Structures and macros for integration with IPP * \****************************************************************************************/ @@ -245,4 +248,111 @@ typedef enum CvStatus } CvStatus; + + +/****************************************************************************************\ +* Auxiliary algorithms * +\****************************************************************************************/ + +namespace cv +{ + +// This function splits the input sequence or set into one or more equivalence classes and +// returns the vector of labels - 0-based class indexes for each element. +// predicate(a,b) returns true if the two sequence elements certainly belong to the same class. +// +// The algorithm is described in "Introduction to Algorithms" +// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets" +template int +partition( const std::vector<_Tp>& _vec, std::vector& labels, + _EqPredicate predicate=_EqPredicate()) +{ + int i, j, N = (int)_vec.size(); + const _Tp* vec = &_vec[0]; + + const int PARENT=0; + const int RANK=1; + + std::vector _nodes(N*2); + int (*nodes)[2] = (int(*)[2])&_nodes[0]; + + // The first O(N) pass: create N single-vertex trees + for(i = 0; i < N; i++) + { + nodes[i][PARENT]=-1; + nodes[i][RANK] = 0; + } + + // The main O(N^2) pass: merge connected components + for( i = 0; i < N; i++ ) + { + int root = i; + + // find root + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + + for( j = 0; j < N; j++ ) + { + if( i == j || !predicate(vec[i], vec[j])) + continue; + int root2 = j; + + while( nodes[root2][PARENT] >= 0 ) + root2 = nodes[root2][PARENT]; + + if( root2 != root ) + { + // unite both trees + int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; + if( rank > rank2 ) + nodes[root2][PARENT] = root; + else + { + nodes[root][PARENT] = root2; + nodes[root2][RANK] += rank == rank2; + root = root2; + } + CV_Assert( nodes[root][PARENT] < 0 ); + + int k = j, parent; + + // compress the path from node2 to root + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + + // compress the path from node to root + k = i; + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + } + } + } + + // Final O(N) pass: enumerate classes + labels.resize(N); + int nclasses = 0; + + for( i = 0; i < N; i++ ) + { + int root = i; + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + // re-use the rank as the class label + if( nodes[root][RANK] >= 0 ) + nodes[root][RANK] = ~nclasses++; + labels[i] = ~nodes[root][RANK]; + } + + return nclasses; +} + +} // namespace cv + #endif // __OPENCV_CORE_PRIVATE_HPP__ diff --git a/modules/core/src/gl_core_3_1.cpp b/modules/core/src/gl_core_3_1.cpp index f1d23b2780..48201b4b76 100644 --- a/modules/core/src/gl_core_3_1.cpp +++ b/modules/core/src/gl_core_3_1.cpp @@ -40,10 +40,7 @@ // //M*/ -#include -#include "cvconfig.h" -#include "opencv2/core.hpp" -#include "opencv2/core/utility.hpp" +#include "precomp.hpp" #include "gl_core_3_1.hpp" #ifdef HAVE_OPENGL diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 09e8636ed7..499537f731 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -43,15 +43,12 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/core/utility.hpp" #include "opencv2/core/core_c.h" -#include "opencv2/core/internal.hpp" #include "opencv2/core/gpumat.hpp" +#include "opencv2/core/private.hpp" + #include #include #include diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index e0e5f40188..c9ab9be488 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -41,7 +41,6 @@ #include "precomp.hpp" -#include "opencv2/core/internal.hpp" #if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 2 #include #endif diff --git a/modules/features2d/src/precomp.hpp b/modules/features2d/src/precomp.hpp index bcaa9b26eb..fc6df5c260 100644 --- a/modules/features2d/src/precomp.hpp +++ b/modules/features2d/src/precomp.hpp @@ -43,16 +43,12 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/features2d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" +#include "opencv2/core/private.hpp" #include diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index 7f857ff3de..9b3ac09911 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -266,7 +266,7 @@ private: const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT); if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound) { - CV_Error(CV_StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound)); + CV_Error(cv::Error::StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound)); } speed_level_ = kHash; diff --git a/modules/flann/src/precomp.hpp b/modules/flann/src/precomp.hpp index 7f924694cb..b16e4a518a 100644 --- a/modules/flann/src/precomp.hpp +++ b/modules/flann/src/precomp.hpp @@ -5,12 +5,8 @@ #include #include -#ifdef HAVE_CVCONFIG_H -# include "cvconfig.h" -#endif #include "opencv2/core.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/flann/miniflann.hpp" #include "opencv2/flann/dist.h" @@ -24,5 +20,7 @@ #include "opencv2/flann/all_indices.h" #include "opencv2/flann/flann_base.hpp" +#include "opencv2/core/private.hpp" + #endif diff --git a/modules/gpu/perf/perf_precomp.hpp b/modules/gpu/perf/perf_precomp.hpp index 8a9eb78ae7..56227223ab 100644 --- a/modules/gpu/perf/perf_precomp.hpp +++ b/modules/gpu/perf/perf_precomp.hpp @@ -54,8 +54,6 @@ #include #include -#include "cvconfig.h" - #ifdef HAVE_CUDA #include #endif @@ -72,6 +70,8 @@ #include "opencv2/legacy.hpp" #include "opencv2/photo.hpp" +#include "opencv2/core/private.hpp" + #ifdef GTEST_CREATE_SHARED_LIBRARY #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined #endif diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index b7ef329ca1..93e687a3fe 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -47,10 +47,6 @@ #pragma warning( disable: 4251 4710 4711 4514 4996 ) #endif -#ifdef HAVE_CVCONFIG_H - #include "cvconfig.h" -#endif - #include #include #include @@ -71,9 +67,10 @@ #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/calib3d.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/video.hpp" +#include "opencv2/core/private.hpp" + #if defined WIN32 || defined WINCE #include #undef small diff --git a/modules/gpu/test/test_precomp.hpp b/modules/gpu/test/test_precomp.hpp index 79fa4a5d20..c036586896 100644 --- a/modules/gpu/test/test_precomp.hpp +++ b/modules/gpu/test/test_precomp.hpp @@ -64,8 +64,6 @@ #include #include -#include "cvconfig.h" - #ifdef HAVE_CUDA #include #include @@ -83,6 +81,8 @@ #include "interpolation.hpp" #include "main_test_nvidia.h" + + #include "opencv2/core/private.hpp" #endif #endif diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 26aae1d2de..463cd1685c 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -42,14 +42,12 @@ #ifndef __HIGHGUI_H_ #define __HIGHGUI_H_ -#include "cvconfig.h" - #include "opencv2/highgui.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" +#include "opencv2/core/private.hpp" #include #include diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index 4d36cdd643..92b76076c3 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -9,15 +9,13 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H -# include "cvconfig.h" -#endif - #include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" +#include "opencv2/core/private.hpp" + #if defined(HAVE_VIDEOINPUT) || \ defined(HAVE_TYZX) || \ defined(HAVE_VFW) || \ diff --git a/modules/imgproc/perf/perf_blur.cpp b/modules/imgproc/perf/perf_blur.cpp index 6604608b04..2abd2d863e 100644 --- a/modules/imgproc/perf/perf_blur.cpp +++ b/modules/imgproc/perf/perf_blur.cpp @@ -1,5 +1,4 @@ #include "perf_precomp.hpp" -#include "opencv2/core/internal.hpp" using namespace std; using namespace cv; diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp index cde17ae05d..f2c4ee0f6a 100644 --- a/modules/imgproc/src/precomp.hpp +++ b/modules/imgproc/src/precomp.hpp @@ -43,15 +43,13 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" +#include "opencv2/core/private.hpp" + #include #include #include diff --git a/modules/legacy/src/precomp.hpp b/modules/legacy/src/precomp.hpp index e6c3d012da..7093f9fa90 100644 --- a/modules/legacy/src/precomp.hpp +++ b/modules/legacy/src/precomp.hpp @@ -41,18 +41,14 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/legacy.hpp" #include "opencv2/video.hpp" #include "opencv2/legacy/blobtrack.hpp" #include "opencv2/legacy/compat.hpp" - #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" + +#include "opencv2/core/private.hpp" #define __BEGIN__ __CV_BEGIN__ #define __END__ __CV_END__ diff --git a/modules/ml/src/precomp.hpp b/modules/ml/src/precomp.hpp index ee03a94d24..ecae7b3446 100644 --- a/modules/ml/src/precomp.hpp +++ b/modules/ml/src/precomp.hpp @@ -41,15 +41,13 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif #include "opencv2/core.hpp" #include "opencv2/ml.hpp" #include "opencv2/core/core_c.h" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" + +#include "opencv2/core/private.hpp" #include #include diff --git a/modules/nonfree/src/precomp.hpp b/modules/nonfree/src/precomp.hpp index 9ba4136fae..424c716c52 100644 --- a/modules/nonfree/src/precomp.hpp +++ b/modules/nonfree/src/precomp.hpp @@ -43,15 +43,10 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/nonfree.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/opencv_modules.hpp" @@ -73,4 +68,6 @@ # include "opencv2/ocl/private/util.hpp" #endif +#include "opencv2/core/private.hpp" + #endif diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 9bacab0314..0f7ac288a8 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -42,8 +42,7 @@ /* Haar features calculation */ #include "precomp.hpp" -#include -#include "opencv2/core/internal.hpp" +#include "stdio.h" #if CV_SSE2 # if 1 /*!CV_SSE4_1 && !CV_SSE4_2*/ diff --git a/modules/objdetect/src/precomp.hpp b/modules/objdetect/src/precomp.hpp index be3547c752..fd5f560257 100644 --- a/modules/objdetect/src/precomp.hpp +++ b/modules/objdetect/src/precomp.hpp @@ -43,23 +43,20 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/objdetect.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/core_c.h" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/opencv_modules.hpp" #ifdef HAVE_OPENCV_HIGHGUI # include "opencv2/highgui.hpp" #endif +#include "opencv2/core/private.hpp" + #ifdef HAVE_TEGRA_OPTIMIZATION #include "opencv2/objdetect/objdetect_tegra.hpp" #endif diff --git a/modules/objdetect/test/test_latentsvmdetector.cpp b/modules/objdetect/test/test_latentsvmdetector.cpp index 9bbc7a9aa5..52bc36d7df 100644 --- a/modules/objdetect/test/test_latentsvmdetector.cpp +++ b/modules/objdetect/test/test_latentsvmdetector.cpp @@ -41,13 +41,8 @@ //M*/ #include "test_precomp.hpp" - #include -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #ifdef HAVE_TBB #include "tbb/task_scheduler_init.h" #endif diff --git a/modules/ocl/perf/precomp.hpp b/modules/ocl/perf/precomp.hpp index d8b4931ff8..208e5ebc64 100644 --- a/modules/ocl/perf/precomp.hpp +++ b/modules/ocl/perf/precomp.hpp @@ -61,19 +61,16 @@ #include #include #include -#include "cvconfig.h" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" #include "opencv2/ts.hpp" #include "opencv2/ocl.hpp" -//#include "opencv2/calib3d.hpp" -//#include "opencv2/nonfree.hpp" #include "utility.hpp" #include "interpolation.hpp" -//#include "add_test_info.h" -//#define PERF_TEST_OCL 1 + +#include "opencv2/core/private.hpp" #endif diff --git a/modules/ocl/src/precomp.hpp b/modules/ocl/src/precomp.hpp index d4f743a50c..98787df47d 100644 --- a/modules/ocl/src/precomp.hpp +++ b/modules/ocl/src/precomp.hpp @@ -52,10 +52,6 @@ #pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 ) #endif -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include #include #include @@ -72,7 +68,8 @@ #include "opencv2/ocl.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" +#include "opencv2/core/private.hpp" + //#include "opencv2/highgui.hpp" #define __ATI__ diff --git a/modules/ocl/test/precomp.hpp b/modules/ocl/test/precomp.hpp index cef6479ac7..56efdabaaa 100644 --- a/modules/ocl/test/precomp.hpp +++ b/modules/ocl/test/precomp.hpp @@ -61,17 +61,16 @@ #include #include #include -#include "cvconfig.h" #include "opencv2/ts.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" #include "opencv2/ocl.hpp" -//#include "opencv2/calib3d.hpp" #include "utility.hpp" #include "interpolation.hpp" -//#include "add_test_info.h" + +#include "opencv2/core/private.hpp" #endif diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp index c2e240b55f..232dba88da 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp @@ -43,9 +43,6 @@ #define __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_HPP__ #include "precomp.hpp" -#include -#include -#include #include #include "fast_nlmeans_denoising_invoker_commons.hpp" diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp index fd2b835e32..978f3170c7 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp @@ -42,10 +42,6 @@ #ifndef __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_COMMONS_HPP__ #define __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_COMMONS_HPP__ -#include -#include -#include - using namespace cv; template static inline int calcDist(const T a, const T b); diff --git a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp index 037c128a12..ee7d3bc7fa 100644 --- a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp @@ -43,9 +43,6 @@ #define __OPENCV_FAST_NLMEANS_MULTI_DENOISING_INVOKER_HPP__ #include "precomp.hpp" -#include -#include -#include #include #include "fast_nlmeans_denoising_invoker_commons.hpp" diff --git a/modules/photo/src/precomp.hpp b/modules/photo/src/precomp.hpp index d397dedf4d..60cc99b19d 100644 --- a/modules/photo/src/precomp.hpp +++ b/modules/photo/src/precomp.hpp @@ -43,11 +43,8 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/photo.hpp" +#include "opencv2/core/private.hpp" #ifdef HAVE_TEGRA_OPTIMIZATION #include "opencv2/photo/photo_tegra.hpp" diff --git a/modules/softcascade/src/precomp.hpp b/modules/softcascade/src/precomp.hpp index 2b6be26640..5d91d51256 100644 --- a/modules/softcascade/src/precomp.hpp +++ b/modules/softcascade/src/precomp.hpp @@ -43,17 +43,14 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/softcascade.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/core_c.h" -#include "opencv2/core/internal.hpp" #include "opencv2/ml.hpp" +#include "opencv2/core/private.hpp" + namespace cv { namespace softcascade { namespace internal { diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index 5afe217b02..e42dea968a 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -1,6 +1,5 @@ #include "perf_precomp.hpp" #include "opencv2/highgui.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/flann.hpp" #include "opencv2/opencv_modules.hpp" diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index 15508a47f9..9e056bc0fa 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -43,9 +43,6 @@ #ifndef __OPENCV_STITCHING_PRECOMP_H__ #define __OPENCV_STITCHING_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" #include @@ -56,7 +53,6 @@ #include #include #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/stitching.hpp" #include "opencv2/stitching/detail/autocalib.hpp" #include "opencv2/stitching/detail/blenders.hpp" @@ -79,6 +75,8 @@ #include "../../imgproc/src/gcgraph.hpp" +#include "opencv2/core/private.hpp" + #ifdef HAVE_TEGRA_OPTIMIZATION # include "opencv2/stitching/stitching_tegra.hpp" #endif diff --git a/modules/superres/perf/perf_precomp.hpp b/modules/superres/perf/perf_precomp.hpp index 0c41001252..c15ed2fafe 100644 --- a/modules/superres/perf/perf_precomp.hpp +++ b/modules/superres/perf/perf_precomp.hpp @@ -51,10 +51,6 @@ #ifndef __OPENCV_PERF_PRECOMP_HPP__ #define __OPENCV_PERF_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/core.hpp" #include "opencv2/core/gpumat.hpp" #include "opencv2/ts/ts_perf.hpp" diff --git a/modules/superres/src/precomp.hpp b/modules/superres/src/precomp.hpp index 86d9a28112..870bde93e5 100644 --- a/modules/superres/src/precomp.hpp +++ b/modules/superres/src/precomp.hpp @@ -46,16 +46,11 @@ #include #include -#ifdef HAVE_CVCONFIG_H - #include "cvconfig.h" -#endif - #include "opencv2/opencv_modules.hpp" #include "opencv2/core.hpp" #include "opencv2/core/gpumat.hpp" #include "opencv2/core/opengl.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/video/tracking.hpp" @@ -76,4 +71,6 @@ #include "ring_buffer.hpp" +#include "opencv2/core/private.hpp" + #endif /* __OPENCV_PRECOMP_H__ */ diff --git a/modules/superres/test/test_precomp.hpp b/modules/superres/test/test_precomp.hpp index e9418c7b0b..4ef73030bd 100644 --- a/modules/superres/test/test_precomp.hpp +++ b/modules/superres/test/test_precomp.hpp @@ -51,10 +51,6 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/opencv_modules.hpp" #include "opencv2/core.hpp" #include "opencv2/imgproc.hpp" diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 9e9bcb39cc..0df6decf1d 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -2,8 +2,9 @@ #define __OPENCV_GTESTCV_HPP__ #ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" +# include "cvconfig.h" #endif + #ifndef GTEST_CREATE_SHARED_LIBRARY #ifdef BUILD_SHARED_LIBS #define GTEST_LINKED_AS_SHARED_LIBRARY 1 diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index c45f6d4af9..633928874c 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -4,6 +4,7 @@ #ifdef HAVE_CVCONFIG_H # include "cvconfig.h" #endif + #ifndef GTEST_CREATE_SHARED_LIBRARY # ifdef BUILD_SHARED_LIBS # define GTEST_LINKED_AS_SHARED_LIBRARY 1 diff --git a/modules/ts/src/gpu_perf.cpp b/modules/ts/src/gpu_perf.cpp index 6c094666c8..19146c0b58 100644 --- a/modules/ts/src/gpu_perf.cpp +++ b/modules/ts/src/gpu_perf.cpp @@ -40,11 +40,10 @@ // //M*/ +#include "precomp.hpp" #include "opencv2/ts/gpu_perf.hpp" #include "opencv2/core/gpumat.hpp" -#include "cvconfig.h" - #ifdef HAVE_CUDA #include #endif diff --git a/modules/ts/src/precomp.hpp b/modules/ts/src/precomp.hpp index a4306d2d86..87435e350f 100644 --- a/modules/ts/src/precomp.hpp +++ b/modules/ts/src/precomp.hpp @@ -3,6 +3,7 @@ #include "opencv2/core/core_c.h" #include "opencv2/core/utility.hpp" +#include "opencv2/core/private.hpp" #ifdef GTEST_LINKED_AS_SHARED_LIBRARY #error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined diff --git a/modules/video/src/precomp.hpp b/modules/video/src/precomp.hpp index 0b9e58283a..389e2823da 100644 --- a/modules/video/src/precomp.hpp +++ b/modules/video/src/precomp.hpp @@ -43,15 +43,11 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/video.hpp" #include "opencv2/imgproc/imgproc_c.h" - #include "opencv2/core/utility.hpp" -#include "opencv2/core/internal.hpp" + +#include "opencv2/core/private.hpp" #include diff --git a/modules/videostab/src/precomp.hpp b/modules/videostab/src/precomp.hpp index bf2d2114ac..691107412a 100644 --- a/modules/videostab/src/precomp.hpp +++ b/modules/videostab/src/precomp.hpp @@ -43,10 +43,6 @@ #ifndef __OPENCV_PRECOMP_HPP__ #define __OPENCV_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H - #include "cvconfig.h" -#endif - #include #include #include @@ -57,6 +53,8 @@ #include "opencv2/features2d.hpp" #include "opencv2/calib3d.hpp" +#include "opencv2/core/private.hpp" + // some aux. functions inline float sqr(float x) { return x * x; } diff --git a/modules/world/src/precomp.hpp b/modules/world/src/precomp.hpp index 343b875979..1aa056848f 100644 --- a/modules/world/src/precomp.hpp +++ b/modules/world/src/precomp.hpp @@ -43,10 +43,6 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H -#include "cvconfig.h" -#endif - #include "opencv2/opencv_modules.hpp" #ifdef HAVE_OPENCV_VIDEO #include "opencv2/video.hpp" diff --git a/samples/cpp/build3dmodel.cpp b/samples/cpp/build3dmodel.cpp index 2ce1abd2de..5535a5fb8c 100644 --- a/samples/cpp/build3dmodel.cpp +++ b/samples/cpp/build3dmodel.cpp @@ -382,6 +382,96 @@ struct EqKeypoints const Set2i* pairs; }; +template static +int partition( const std::vector<_Tp>& _vec, std::vector& labels, + _EqPredicate predicate=_EqPredicate()) +{ + int i, j, N = (int)_vec.size(); + const _Tp* vec = &_vec[0]; + + const int PARENT=0; + const int RANK=1; + + std::vector _nodes(N*2); + int (*nodes)[2] = (int(*)[2])&_nodes[0]; + + // The first O(N) pass: create N single-vertex trees + for(i = 0; i < N; i++) + { + nodes[i][PARENT]=-1; + nodes[i][RANK] = 0; + } + + // The main O(N^2) pass: merge connected components + for( i = 0; i < N; i++ ) + { + int root = i; + + // find root + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + + for( j = 0; j < N; j++ ) + { + if( i == j || !predicate(vec[i], vec[j])) + continue; + int root2 = j; + + while( nodes[root2][PARENT] >= 0 ) + root2 = nodes[root2][PARENT]; + + if( root2 != root ) + { + // unite both trees + int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; + if( rank > rank2 ) + nodes[root2][PARENT] = root; + else + { + nodes[root][PARENT] = root2; + nodes[root2][RANK] += rank == rank2; + root = root2; + } + CV_Assert( nodes[root][PARENT] < 0 ); + + int k = j, parent; + + // compress the path from node2 to root + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + + // compress the path from node to root + k = i; + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + } + } + } + + // Final O(N) pass: enumerate classes + labels.resize(N); + int nclasses = 0; + + for( i = 0; i < N; i++ ) + { + int root = i; + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + // re-use the rank as the class label + if( nodes[root][RANK] >= 0 ) + nodes[root][RANK] = ~nclasses++; + labels[i] = ~nodes[root][RANK]; + } + + return nclasses; +} + static void build3dmodel( const Ptr& detector, const Ptr& descriptorExtractor, const vector& /*modelBox*/, diff --git a/samples/gpu/driver_api_multi.cpp b/samples/gpu/driver_api_multi.cpp index 2d743f0e9c..9119cfac1e 100644 --- a/samples/gpu/driver_api_multi.cpp +++ b/samples/gpu/driver_api_multi.cpp @@ -11,6 +11,18 @@ #include "opencv2/core/core.hpp" #include "opencv2/gpu/gpu.hpp" +#ifdef HAVE_TBB +# include "tbb/tbb_stddef.h" +# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 +# include "tbb/tbb.h" +# include "tbb/task.h" +# undef min +# undef max +# else +# undef HAVE_TBB +# endif +#endif + #if !defined(HAVE_CUDA) || !defined(HAVE_TBB) int main() @@ -30,7 +42,6 @@ int main() #include #include -#include "opencv2/core/internal.hpp" // For TBB wrappers using namespace std; using namespace cv; @@ -96,7 +107,7 @@ int main() // Execute calculation in two threads using two GPUs int devices[] = {0, 1}; - parallel_do(devices, devices + 2, Worker()); + tbb::parallel_do(devices, devices + 2, Worker()); destroyContexts(); return 0; diff --git a/samples/gpu/driver_api_stereo_multi.cpp b/samples/gpu/driver_api_stereo_multi.cpp index 10c3974771..338ef0ef68 100644 --- a/samples/gpu/driver_api_stereo_multi.cpp +++ b/samples/gpu/driver_api_stereo_multi.cpp @@ -13,6 +13,18 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/gpu/gpu.hpp" +#ifdef HAVE_TBB +# include "tbb/tbb_stddef.h" +# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 +# include "tbb/tbb.h" +# include "tbb/task.h" +# undef min +# undef max +# else +# undef HAVE_TBB +# endif +#endif + #if !defined(HAVE_CUDA) || !defined(HAVE_TBB) int main() @@ -32,7 +44,6 @@ int main() #include #include -#include "opencv2/core/internal.hpp" // For TBB wrappers using namespace std; using namespace cv; @@ -159,7 +170,7 @@ int main(int argc, char** argv) // Execute calculation in two threads using two GPUs int devices[] = {0, 1}; - parallel_do(devices, devices + 2, Worker()); + tbb::parallel_do(devices, devices + 2, Worker()); // Release the first GPU resources contextOn(0); diff --git a/samples/gpu/multi.cpp b/samples/gpu/multi.cpp index c3925fc442..180388fa3b 100644 --- a/samples/gpu/multi.cpp +++ b/samples/gpu/multi.cpp @@ -11,6 +11,18 @@ #include "opencv2/core/core.hpp" #include "opencv2/gpu/gpu.hpp" +#ifdef HAVE_TBB +# include "tbb/tbb_stddef.h" +# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 +# include "tbb/tbb.h" +# include "tbb/task.h" +# undef min +# undef max +# else +# undef HAVE_TBB +# endif +#endif + #if !defined(HAVE_CUDA) || !defined(HAVE_TBB) int main() @@ -28,8 +40,6 @@ int main() #else -#include "opencv2/core/internal.hpp" // For TBB wrappers - using namespace std; using namespace cv; using namespace cv::gpu; @@ -60,7 +70,7 @@ int main() // Execute calculation in two threads using two GPUs int devices[] = {0, 1}; - parallel_do(devices, devices + 2, Worker()); + tbb::parallel_do(devices, devices + 2, Worker()); return 0; } diff --git a/samples/gpu/stereo_multi.cpp b/samples/gpu/stereo_multi.cpp index cf42043bbe..7489ec060c 100644 --- a/samples/gpu/stereo_multi.cpp +++ b/samples/gpu/stereo_multi.cpp @@ -13,6 +13,18 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/gpu/gpu.hpp" +#ifdef HAVE_TBB +# include "tbb/tbb_stddef.h" +# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 +# include "tbb/tbb.h" +# include "tbb/task.h" +# undef min +# undef max +# else +# undef HAVE_TBB +# endif +#endif + #if !defined(HAVE_CUDA) || !defined(HAVE_TBB) int main() @@ -30,8 +42,6 @@ int main() #else -#include "opencv2/core/internal.hpp" // For TBB wrappers - using namespace std; using namespace cv; using namespace cv::gpu; @@ -112,7 +122,7 @@ int main(int argc, char** argv) // Execute calculation in two threads using two GPUs int devices[] = {0, 1}; - parallel_do(devices, devices + 2, Worker()); + tbb::parallel_do(devices, devices + 2, Worker()); // Release the first GPU resources setDevice(0);