From 964a4d75b44a3c4c2425b9ed8c4c25c4e6db79ca Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 12:21:53 +0300 Subject: [PATCH 01/14] next: version.hpp --- modules/core/include/opencv2/core/version.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index 28cf598964..73d61a5042 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -5,10 +5,10 @@ #ifndef OPENCV_VERSION_HPP #define OPENCV_VERSION_HPP -#define CV_VERSION_MAJOR 3 -#define CV_VERSION_MINOR 4 -#define CV_VERSION_REVISION 1 -#define CV_VERSION_STATUS "-dev" +#define CV_VERSION_MAJOR 4 +#define CV_VERSION_MINOR 0 +#define CV_VERSION_REVISION 0 +#define CV_VERSION_STATUS "-pre" #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) From 2d54fed3ccbb67ae246897874ad7490ef188af96 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 14:38:53 +0300 Subject: [PATCH 02/14] next: OPENCV_ABI_COMPATIBILITY drop change: template operator Vec<_Tp2, 3>() const; because it break builds due ambiguous errors --- modules/core/include/opencv2/core/base.hpp | 4 ---- modules/core/include/opencv2/core/cvdef.h | 2 +- modules/core/include/opencv2/core/types.hpp | 12 ------------ modules/core/include/opencv2/core/utility.hpp | 7 ------- modules/core/src/system.cpp | 8 -------- 5 files changed, 1 insertion(+), 32 deletions(-) diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 61144e999c..5545030b91 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -727,11 +727,7 @@ namespace cudev namespace ipp { -#if OPENCV_ABI_COMPATIBILITY > 300 CV_EXPORTS unsigned long long getIppFeatures(); -#else -CV_EXPORTS int getIppFeatures(); -#endif CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL, int line = 0); CV_EXPORTS int getIppStatus(); diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index a87ced09d7..64b4dabf97 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -251,7 +251,7 @@ typedef union Cv64suf } Cv64suf; -#define OPENCV_ABI_COMPATIBILITY 300 +#define OPENCV_ABI_COMPATIBILITY 400 #ifdef __OPENCV_BUILD # define DISABLE_OPENCV_24_COMPATIBILITY diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 6d8782058a..fdb52efe8e 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -250,11 +250,7 @@ public: //! conversion to another data type template operator Point3_<_Tp2>() const; //! conversion to cv::Vec<> -#if OPENCV_ABI_COMPATIBILITY > 300 - template operator Vec<_Tp2, 3>() const; -#else operator Vec<_Tp, 3>() const; -#endif //! dot product _Tp dot(const Point3_& pt) const; @@ -1405,19 +1401,11 @@ Point3_<_Tp>::operator Point3_<_Tp2>() const return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); } -#if OPENCV_ABI_COMPATIBILITY > 300 -template template inline -Point3_<_Tp>::operator Vec<_Tp2, 3>() const -{ - return Vec<_Tp2, 3>(x, y, z); -} -#else template inline Point3_<_Tp>::operator Vec<_Tp, 3>() const { return Vec<_Tp, 3>(x, y, z); } -#endif template inline Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt) diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 8ee82b82cf..f72f13a5bb 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -689,17 +689,10 @@ protected: virtual ~TLSDataContainer(); void gatherData(std::vector &data) const; -#if OPENCV_ABI_COMPATIBILITY > 300 void* getData() const; void release(); private: -#else - void release(); - -public: - void* getData() const; -#endif virtual void* createDataInstance() const = 0; virtual void deleteDataInstance(void* pData) const = 0; diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index b53f7c9c43..0f20248a3b 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -2023,18 +2023,10 @@ static IPPInitSingleton& getIPPSingleton() } #endif -#if OPENCV_ABI_COMPATIBILITY > 300 unsigned long long getIppFeatures() -#else -int getIppFeatures() -#endif { #ifdef HAVE_IPP -#if OPENCV_ABI_COMPATIBILITY > 300 return getIPPSingleton().ippFeatures; -#else - return (int)getIPPSingleton().ippFeatures; -#endif #else return 0; #endif From 2b2fa58f977b3f5334d18cba381e568e7e5622ed Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 14:41:15 +0300 Subject: [PATCH 03/14] next: drop DISABLE_OPENCV_24_COMPATIBILITY --- modules/calib3d/include/opencv2/calib3d.hpp | 4 ---- modules/core/include/opencv2/core/cvdef.h | 2 +- modules/core/include/opencv2/core/cvstd.hpp | 5 +---- modules/core/include/opencv2/core/utility.hpp | 4 ---- modules/highgui/include/opencv2/highgui.hpp | 4 ---- modules/imgproc/include/opencv2/imgproc.hpp | 4 ---- modules/objdetect/include/opencv2/objdetect.hpp | 4 ---- modules/photo/include/opencv2/photo.hpp | 4 ---- modules/video/include/opencv2/video.hpp | 4 ---- 9 files changed, 2 insertions(+), 33 deletions(-) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 54b193cb70..22bb124627 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -2426,8 +2426,4 @@ optimization. It stays at the center or at a different location specified when C } //end namespace cv -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/calib3d/calib3d_c.h" -#endif - #endif diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 64b4dabf97..32e5343ff4 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -254,7 +254,7 @@ Cv64suf; #define OPENCV_ABI_COMPATIBILITY 400 #ifdef __OPENCV_BUILD -# define DISABLE_OPENCV_24_COMPATIBILITY +# define DISABLE_OPENCV_3_COMPATIBILITY #endif #ifdef CVAPI_EXPORTS diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 0a3f553ab8..453904e6b7 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -281,10 +281,7 @@ struct Ptr @note It is often easier to use makePtr instead. */ template -#ifdef DISABLE_OPENCV_24_COMPATIBILITY - explicit -#endif - Ptr(Y* p); + explicit Ptr(Y* p); /** @overload @param d Deleter to use for the owned pointer. diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index f72f13a5bb..ba76176723 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -1244,8 +1244,4 @@ CV_EXPORTS int getThreadID(); } //namespace cv -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/core/core_c.h" -#endif - #endif //OPENCV_CORE_UTILITY_H diff --git a/modules/highgui/include/opencv2/highgui.hpp b/modules/highgui/include/opencv2/highgui.hpp index 0394c7d70d..763d95f6bf 100644 --- a/modules/highgui/include/opencv2/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui.hpp @@ -837,8 +837,4 @@ CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change, } // cv -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/highgui/highgui_c.h" -#endif - #endif diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index b93a10c0d9..75f009aa5f 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -4907,8 +4907,4 @@ Point LineIterator::pos() const } // cv -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/imgproc/imgproc_c.h" -#endif - #endif diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index eac9cbaf58..df6ca9a7ed 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -676,8 +676,4 @@ public: #include "opencv2/objdetect/detection_based_tracker.hpp" -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/objdetect/objdetect_c.h" -#endif - #endif diff --git a/modules/photo/include/opencv2/photo.hpp b/modules/photo/include/opencv2/photo.hpp index 8cd1971899..ec1665c700 100644 --- a/modules/photo/include/opencv2/photo.hpp +++ b/modules/photo/include/opencv2/photo.hpp @@ -869,8 +869,4 @@ CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 6 } // cv -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/photo/photo_c.h" -#endif - #endif diff --git a/modules/video/include/opencv2/video.hpp b/modules/video/include/opencv2/video.hpp index aa644a937a..a3dde60399 100644 --- a/modules/video/include/opencv2/video.hpp +++ b/modules/video/include/opencv2/video.hpp @@ -56,8 +56,4 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" -#ifndef DISABLE_OPENCV_24_COMPATIBILITY -#include "opencv2/video/tracking_c.h" -#endif - #endif //OPENCV_VIDEO_HPP From 98c8584b8810362777af747be6cec09e0644a549 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 14:51:39 +0300 Subject: [PATCH 04/14] next: drop CV_CXX11 conditions define itself is still here for compatibility --- .../calib3d/test/test_affine3d_estimator.cpp | 5 - .../include/opencv2/core/cuda/functional.hpp | 5 - modules/core/include/opencv2/core/cvdef.h | 3 + modules/core/include/opencv2/core/mat.hpp | 6 - modules/core/include/opencv2/core/mat.inl.hpp | 4 - modules/core/include/opencv2/core/matx.hpp | 10 -- modules/core/include/opencv2/core/utility.hpp | 4 - modules/core/src/parallel_impl.cpp | 47 +----- modules/core/test/test_mat.cpp | 8 - .../src/brute_force_matcher.cpp | 4 - modules/imgproc/src/featureselect.cpp | 4 - modules/imgproc/src/generalized_hough.cpp | 9 -- .../imgproc/test/test_goodfeaturetotrack.cpp | 4 - .../objdetect/detection_based_tracker.hpp | 5 - .../objdetect/perf/opencl/perf_hogdetect.cpp | 4 - .../objdetect/src/detection_based_tracker.cpp | 153 ------------------ modules/ts/include/opencv2/ts/ts_perf.hpp | 8 - modules/ts/src/cuda_test.cpp | 4 - 18 files changed, 6 insertions(+), 281 deletions(-) diff --git a/modules/calib3d/test/test_affine3d_estimator.cpp b/modules/calib3d/test/test_affine3d_estimator.cpp index 9c3821bbc4..42e10a0e77 100644 --- a/modules/calib3d/test/test_affine3d_estimator.cpp +++ b/modules/calib3d/test/test_affine3d_estimator.cpp @@ -138,13 +138,8 @@ bool CV_Affine3D_EstTest::testNPoints() std::transform(fpts.ptr(), fpts.ptr() + n, tpts.ptr(), WrapAff(aff)); /* adding noise*/ -#ifdef CV_CXX11 std::transform(tpts.ptr() + m, tpts.ptr() + n, tpts.ptr() + m, [=] (const Point3f& pt) -> Point3f { return Noise(noise_level)(pt + shift_outl); }); -#else - std::transform(tpts.ptr() + m, tpts.ptr() + n, tpts.ptr() + m, std::bind2nd(std::plus(), shift_outl)); - std::transform(tpts.ptr() + m, tpts.ptr() + n, tpts.ptr() + m, Noise(noise_level)); -#endif Mat aff_est; vector outl; diff --git a/modules/core/include/opencv2/core/cuda/functional.hpp b/modules/core/include/opencv2/core/cuda/functional.hpp index b28f7a5e0e..7f404dece5 100644 --- a/modules/core/include/opencv2/core/cuda/functional.hpp +++ b/modules/core/include/opencv2/core/cuda/functional.hpp @@ -58,7 +58,6 @@ namespace cv { namespace cuda { namespace device { // Function Objects -#ifdef CV_CXX11 template struct unary_function { typedef Argument argument_type; @@ -70,10 +69,6 @@ namespace cv { namespace cuda { namespace device typedef Argument2 second_argument_type; typedef Result result_type; }; -#else - template struct unary_function : public std::unary_function {}; - template struct binary_function : public std::binary_function {}; -#endif // Arithmetic Operations template struct plus : binary_function diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 32e5343ff4..b424d14799 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -417,6 +417,9 @@ Cv64suf; # undef CV_CXX11 # endif #endif +#ifndef CV_CXX11 +# error "OpenCV 4.x+ requires enabled C++11 support" +#endif /****************************************************************************************\ diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index ca1b3aa9b5..627c7d14e6 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -53,9 +53,7 @@ #include "opencv2/core/bufferpool.hpp" -#ifdef CV_CXX11 #include -#endif namespace cv { @@ -984,7 +982,6 @@ public: */ template explicit Mat(const std::vector<_Tp>& vec, bool copyData=false); -#ifdef CV_CXX11 /** @overload */ template::value>::type> @@ -993,7 +990,6 @@ public: /** @overload */ template explicit Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> list); -#endif #ifdef CV_CXX_STD_ARRAY /** @overload @@ -2210,10 +2206,8 @@ public: explicit Mat_(const Point3_::channel_type>& pt, bool copyData=true); explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); -#ifdef CV_CXX11 Mat_(std::initializer_list<_Tp> values); explicit Mat_(const std::initializer_list sizes, const std::initializer_list<_Tp> values); -#endif #ifdef CV_CXX_STD_ARRAY template explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false); diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 9b2da34e61..dc1eadfefc 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -574,7 +574,6 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData) Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); } -#ifdef CV_CXX11 template inline Mat::Mat(const std::initializer_list<_Tp> list) : Mat() @@ -594,7 +593,6 @@ Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp CV_Assert(size_total == list.size()); Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); } -#endif #ifdef CV_CXX_STD_ARRAY template inline @@ -1634,7 +1632,6 @@ Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData) : Mat(vec, copyData) {} -#ifdef CV_CXX11 template inline Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list) : Mat(list) @@ -1644,7 +1641,6 @@ template inline Mat_<_Tp>::Mat_(const std::initializer_list sizes, std::initializer_list<_Tp> list) : Mat(sizes, list) {} -#endif #ifdef CV_CXX_STD_ARRAY template template inline diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index e664a3e84c..cdeda40f7b 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -53,9 +53,7 @@ #include "opencv2/core/traits.hpp" #include "opencv2/core/saturate.hpp" -#ifdef CV_CXX11 #include -#endif namespace cv { @@ -141,9 +139,7 @@ public: _Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix explicit Matx(const _Tp* vals); //!< initialize from a plain array -#ifdef CV_CXX11 Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list -#endif static Matx all(_Tp alpha); static Matx zeros(); @@ -361,9 +357,7 @@ public: Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor explicit Vec(const _Tp* values); -#ifdef CV_CXX11 Vec(std::initializer_list<_Tp>); -#endif Vec(const Vec<_Tp, cn>& v); @@ -665,7 +659,6 @@ Matx<_Tp, m, n>::Matx(const _Tp* values) for( int i = 0; i < channels; i++ ) val[i] = values[i]; } -#ifdef CV_CXX11 template inline Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list) { @@ -676,7 +669,6 @@ Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list) val[i++] = elem; } } -#endif template inline Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha) @@ -1019,11 +1011,9 @@ template inline Vec<_Tp, cn>::Vec(const _Tp* values) : Matx<_Tp, cn, 1>(values) {} -#ifdef CV_CXX11 template inline Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list) : Matx<_Tp, cn, 1>(list) {} -#endif template inline Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m) diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index ba76176723..092f732c78 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -56,9 +56,7 @@ #include "opencv2/core.hpp" #include -#ifdef CV_CXX11 #include -#endif namespace cv { @@ -531,7 +529,6 @@ public: */ CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.); -#ifdef CV_CXX11 class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody { private: @@ -551,7 +548,6 @@ inline void parallel_for_(const Range& range, std::function { parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes); } -#endif /////////////////////////////// forEach method of cv::Mat //////////////////////////// template inline diff --git a/modules/core/src/parallel_impl.cpp b/modules/core/src/parallel_impl.cpp index bc64fce7a8..cf8165e3cd 100644 --- a/modules/core/src/parallel_impl.cpp +++ b/modules/core/src/parallel_impl.cpp @@ -21,27 +21,15 @@ //#define CV_USE_GLOBAL_WORKERS_COND_VAR // not effective on many-core systems (10+) -#ifdef CV_CXX11 #include -#else -#include // _POSIX_PRIORITY_SCHEDULING -#endif // Spin lock's OS-level yield #ifdef DECLARE_CV_YIELD DECLARE_CV_YIELD #endif #ifndef CV_YIELD -# ifdef CV_CXX11 -# include -# define CV_YIELD() std::this_thread::yield() -# elif defined(_POSIX_PRIORITY_SCHEDULING) -# include -# define CV_YIELD() sched_yield() -# else -# warning "Can't detect sched_yield() on the target platform. Specify CV_YIELD() definition via compiler flags." -# define CV_YIELD() /* no-op: works, but not effective */ -# endif +# include +# define CV_YIELD() std::this_thread::yield() #endif // CV_YIELD // Spin lock's CPU-level yield (required for Hyper-Threading) @@ -290,15 +278,9 @@ public: is_completed(false) { CV_LOG_VERBOSE(NULL, 5, "ParallelJob::ParallelJob(" << (void*)this << ")"); -#ifdef CV_CXX11 current_task.store(0, std::memory_order_relaxed); active_thread_count.store(0, std::memory_order_relaxed); completed_thread_count.store(0, std::memory_order_relaxed); -#else - current_task = 0; - active_thread_count = 0; - completed_thread_count = 0; -#endif dummy0_[0] = 0, dummy1_[0] = 0, dummy2_[0] = 0; // compiler warning } @@ -319,11 +301,7 @@ public: for (;;) { int chunk_size = std::max(1, (task_count - current_task) / remaining_multiplier); -#ifdef CV_CXX11 int id = current_task.fetch_add(chunk_size, std::memory_order_seq_cst); -#else - int id = (int)CV_XADD(¤t_task, chunk_size); -#endif if (id >= task_count) break; // no more free tasks @@ -349,7 +327,7 @@ public: const ParallelLoopBody& body; const Range range; const unsigned nstripes; -#ifdef CV_CXX11 + std::atomic current_task; // next free part of job int64 dummy0_[8]; // avoid cache-line reusing for the same atomics @@ -358,16 +336,6 @@ public: std::atomic completed_thread_count; // number of threads completed any activities on this job int64 dummy2_[8]; // avoid cache-line reusing for the same atomics -#else - /*CV_DECL_ALIGNED(64)*/ volatile int current_task; // next free part of job - int64 dummy0_[8]; // avoid cache-line reusing for the same atomics - - /*CV_DECL_ALIGNED(64)*/ volatile int active_thread_count; // number of threads worked on this job - int64 dummy1_[8]; // avoid cache-line reusing for the same atomics - - /*CV_DECL_ALIGNED(64)*/ volatile int completed_thread_count; // number of threads completed any activities on this job - int64 dummy2_[8]; // avoid cache-line reusing for the same atomics -#endif volatile bool is_completed; // std::atomic_flag ? @@ -437,11 +405,7 @@ void WorkerThread::thread_body() CV_LOG_VERBOSE(NULL, 5, "Thread: job size=" << j->range.size() << " done=" << j->current_task); if (j->current_task < j->range.size()) { -#ifdef CV_CXX11 int other = j->active_thread_count.fetch_add(1, std::memory_order_seq_cst); -#else - int other = CV_XADD(&j->active_thread_count, 1); -#endif CV_LOG_VERBOSE(NULL, 5, "Thread: processing new job (with " << other << " other threads)"); CV_UNUSED(other); #ifdef CV_PROFILE_THREADS stat.threadExecuteStart = getTickCount(); @@ -450,13 +414,8 @@ void WorkerThread::thread_body() #else j->execute(true); #endif -#ifdef CV_CXX11 int completed = j->completed_thread_count.fetch_add(1, std::memory_order_seq_cst) + 1; int active = j->active_thread_count.load(std::memory_order_acquire); -#else - int completed = (int)CV_XADD(&j->completed_thread_count, 1) + 1; - int active = j->active_thread_count; -#endif if (CV_WORKER_ACTIVE_WAIT_THREADS_LIMIT > 0) { allow_active_wait = true; diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 53b43ae8c2..bb149dbae1 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1344,8 +1344,6 @@ TEST(Core_Matx, fromMat_) ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.); } -#ifdef CV_CXX11 - TEST(Core_Matx, from_initializer_list) { Mat_ a = (Mat_(2,2) << 10, 11, 12, 13); @@ -1360,8 +1358,6 @@ TEST(Core_Mat, regression_9507) EXPECT_EQ(25u, m2.total()); } -#endif // CXX11 - TEST(Core_InputArray, empty) { vector > data; @@ -1711,8 +1707,6 @@ TEST(Mat, regression_8680) ASSERT_EQ(mat.channels(), 2); } -#ifdef CV_CXX11 - TEST(Mat_, range_based_for) { Mat_ img = Mat_::zeros(3, 3); @@ -1774,6 +1768,4 @@ TEST(Mat_, template_based_ptr) ASSERT_FLOAT_EQ(66.0f, *(mat.ptr(idx))); } -#endif - }} // namespace diff --git a/modules/cudafeatures2d/src/brute_force_matcher.cpp b/modules/cudafeatures2d/src/brute_force_matcher.cpp index 5287546bbe..87316846d5 100644 --- a/modules/cudafeatures2d/src/brute_force_matcher.cpp +++ b/modules/cudafeatures2d/src/brute_force_matcher.cpp @@ -564,12 +564,8 @@ namespace if (compactResult) { -#ifdef CV_CXX11 std::vector< std::vector >::iterator new_end = std::remove_if(matches.begin(), matches.end(), [](const std::vector& e)->bool { return e.empty(); }); -#else - std::vector< std::vector >::iterator new_end = std::remove_if(matches.begin(), matches.end(), std::mem_fun_ref(&std::vector::empty)); -#endif matches.erase(new_end, matches.end()); } } diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 95b44b3742..c384a81148 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -52,11 +52,7 @@ namespace cv { -#ifdef CV_CXX11 struct greaterThanPtr -#else -struct greaterThanPtr : public std::binary_function -#endif { bool operator () (const float * a, const float * b) const // Ensure a fully deterministic result of the sort diff --git a/modules/imgproc/src/generalized_hough.cpp b/modules/imgproc/src/generalized_hough.cpp index 027e67a77e..c4f121df8a 100644 --- a/modules/imgproc/src/generalized_hough.cpp +++ b/modules/imgproc/src/generalized_hough.cpp @@ -385,11 +385,7 @@ namespace const double thetaScale = levels_ / 360.0; r_table_.resize(levels_ + 1); -#ifdef CV_CXX11 std::for_each(r_table_.begin(), r_table_.end(), [](std::vector& e)->void { e.clear(); }); -#else - std::for_each(r_table_.begin(), r_table_.end(), std::mem_fun_ref(&std::vector::clear)); -#endif for (int y = 0; y < templSize_.height; ++y) { @@ -696,12 +692,7 @@ namespace getContourPoints(edges, dx, dy, points); features.resize(levels_ + 1); -#ifdef CV_CXX11 std::for_each(features.begin(), features.end(), [=](std::vector& e) { e.clear(); e.reserve(maxBufferSize_); }); -#else - std::for_each(features.begin(), features.end(), std::mem_fun_ref(&std::vector::clear)); - std::for_each(features.begin(), features.end(), std::bind2nd(std::mem_fun_ref(&std::vector::reserve), maxBufferSize_)); -#endif for (size_t i = 0; i < points.size(); ++i) { diff --git a/modules/imgproc/test/test_goodfeaturetotrack.cpp b/modules/imgproc/test/test_goodfeaturetotrack.cpp index 362cc014cf..1a339bea55 100644 --- a/modules/imgproc/test/test_goodfeaturetotrack.cpp +++ b/modules/imgproc/test/test_goodfeaturetotrack.cpp @@ -56,11 +56,7 @@ enum { MINEIGENVAL=0, HARRIS=1, EIGENVALSVECS=2 }; /////////////////////ref////////////////////// -#ifdef CV_CXX11 struct greaterThanPtr -#else -struct greaterThanPtr : public std::binary_function -#endif { bool operator () (const float * a, const float * b) const { return *a > *b; } diff --git a/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp b/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp index 07dd587491..18cde13eab 100644 --- a/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp +++ b/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp @@ -46,10 +46,6 @@ #include -// After this condition removal update blacklist for bindings: modules/python/common.cmake -#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || \ - defined(CV_CXX11) - #include namespace cv @@ -222,6 +218,5 @@ class CV_EXPORTS DetectionBasedTracker //! @} objdetect } //end of cv namespace -#endif #endif diff --git a/modules/objdetect/perf/opencl/perf_hogdetect.cpp b/modules/objdetect/perf/opencl/perf_hogdetect.cpp index 43c63d8cca..e7ca8c232a 100644 --- a/modules/objdetect/perf/opencl/perf_hogdetect.cpp +++ b/modules/objdetect/perf/opencl/perf_hogdetect.cpp @@ -53,11 +53,7 @@ namespace opencv_test { namespace ocl { ///////////// HOG//////////////////////// -#ifdef CV_CXX11 struct RectLess -#else -struct RectLess : public std::binary_function -#endif { bool operator()(const cv::Rect& a, const cv::Rect& b) const diff --git a/modules/objdetect/src/detection_based_tracker.cpp b/modules/objdetect/src/detection_based_tracker.cpp index 0cdcafacee..431c289a00 100644 --- a/modules/objdetect/src/detection_based_tracker.cpp +++ b/modules/objdetect/src/detection_based_tracker.cpp @@ -42,23 +42,12 @@ //M*/ #include "precomp.hpp" -#include - -#ifdef CV_CXX11 -#define USE_STD_THREADS -#endif - -#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(USE_STD_THREADS) #include "opencv2/core/utility.hpp" -#ifdef USE_STD_THREADS #include #include #include -#else //USE_STD_THREADS -#include -#endif //USE_STD_THREADS #if defined(DEBUG) || defined(_DEBUG) #undef DEBUGLOGS @@ -139,49 +128,26 @@ class cv::DetectionBasedTracker::SeparateDetectionWork } void setParameters(const cv::DetectionBasedTracker::Parameters& params) { -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif parameters = params; -#ifndef USE_STD_THREADS - pthread_mutex_unlock(&mutex); -#endif } inline void init() { -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif stateThread = STATE_THREAD_STOPPED; isObjectDetectingReady = false; shouldObjectDetectingResultsBeForgot = false; -#ifdef USE_STD_THREADS objectDetectorThreadStartStop.notify_one(); -#else - pthread_cond_signal(&(objectDetectorThreadStartStop)); - pthread_mutex_unlock(&mutex); -#endif } protected: DetectionBasedTracker& detectionBasedTracker; cv::Ptr cascadeInThread; -#ifdef USE_STD_THREADS std::thread second_workthread; std::mutex mtx; std::condition_variable objectDetectorRun; std::condition_variable objectDetectorThreadStartStop; -#else - pthread_t second_workthread; - pthread_mutex_t mutex; - pthread_cond_t objectDetectorRun; - pthread_cond_t objectDetectorThreadStartStop; -#endif std::vector resultDetect; volatile bool isObjectDetectingReady; volatile bool shouldObjectDetectingResultsBeForgot; @@ -217,28 +183,6 @@ cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(Detectio CV_Assert(_detector); cascadeInThread = _detector; -#ifndef USE_STD_THREADS - second_workthread = 0; - int res=0; - res=pthread_mutex_init(&mutex, NULL);//TODO: should be attributes? - if (res) { - LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_mutex_init(&mutex, NULL) is %d", res); - throw(std::exception()); - } - res=pthread_cond_init (&objectDetectorRun, NULL); - if (res) { - LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorRun,, NULL) is %d", res); - pthread_mutex_destroy(&mutex); - throw(std::exception()); - } - res=pthread_cond_init (&objectDetectorThreadStartStop, NULL); - if (res) { - LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorThreadStartStop,, NULL) is %d", res); - pthread_cond_destroy(&objectDetectorRun); - pthread_mutex_destroy(&mutex); - throw(std::exception()); - } -#endif } cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork() @@ -246,39 +190,20 @@ cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork() if(stateThread!=STATE_THREAD_STOPPED) { LOGE("\n\n\nATTENTION!!! dangerous algorithm error: destructor DetectionBasedTracker::DetectionBasedTracker::~SeparateDetectionWork is called before stopping the workthread"); } -#ifndef USE_STD_THREADS - pthread_cond_destroy(&objectDetectorThreadStartStop); - pthread_cond_destroy(&objectDetectorRun); - pthread_mutex_destroy(&mutex); -#else second_workthread.join(); -#endif } bool cv::DetectionBasedTracker::SeparateDetectionWork::run() { LOGD("DetectionBasedTracker::SeparateDetectionWork::run() --- start"); -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); // unlocked when leaving scope -#else - pthread_mutex_lock(&mutex); -#endif if (stateThread != STATE_THREAD_STOPPED) { LOGE("DetectionBasedTracker::SeparateDetectionWork::run is called while the previous run is not stopped"); -#ifndef USE_STD_THREADS - pthread_mutex_unlock(&mutex); -#endif return false; } stateThread=STATE_THREAD_WORKING_SLEEPING; -#ifdef USE_STD_THREADS second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes? objectDetectorThreadStartStop.wait(mtx_lock); -#else - pthread_create(&second_workthread, NULL, workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes? - pthread_cond_wait(&objectDetectorThreadStartStop, &mutex); - pthread_mutex_unlock(&mutex); -#endif LOGD("DetectionBasedTracker::SeparateDetectionWork::run --- end"); return true; } @@ -313,34 +238,18 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() std::vector objects; CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif { -#ifdef USE_STD_THREADS objectDetectorThreadStartStop.notify_one(); -#else - pthread_cond_signal(&objectDetectorThreadStartStop); -#endif LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting"); CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); -#ifdef USE_STD_THREADS objectDetectorRun.wait(mtx_lock); -#else - pthread_cond_wait(&objectDetectorRun, &mutex); -#endif if (isWorking()) { stateThread=STATE_THREAD_WORKING_WITH_IMAGE; } LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting"); } -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif bool isFirstStep=true; @@ -353,34 +262,18 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() if (! isFirstStep) { LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting"); CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); -#ifdef USE_STD_THREADS mtx_lock.lock(); -#else - pthread_mutex_lock(&mutex); -#endif if (!isWorking()) {//it is a rare case, but may cause a crash LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle from inner part of lock just before waiting"); -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif break; } CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); -#ifdef USE_STD_THREADS objectDetectorRun.wait(mtx_lock); -#else - pthread_cond_wait(&objectDetectorRun, &mutex); -#endif if (isWorking()) { stateThread=STATE_THREAD_WORKING_WITH_IMAGE; } -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting"); } else { @@ -427,11 +320,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() (void)(dt_detect_ms); LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- objects num==%d, t_ms=%.4f", (int)objects.size(), dt_detect_ms); -#ifdef USE_STD_THREADS mtx_lock.lock(); -#else - pthread_mutex_lock(&mutex); -#endif if (!shouldObjectDetectingResultsBeForgot) { resultDetect=objects; isObjectDetectingReady=true; @@ -443,11 +332,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() if(isWorking()) { stateThread=STATE_THREAD_WORKING_SLEEPING; } -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif objects.clear(); }// while(isWorking()) @@ -458,44 +343,25 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() void cv::DetectionBasedTracker::SeparateDetectionWork::stop() { //FIXME: TODO: should add quickStop functionality -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif if (!isWorking()) { -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif LOGE("SimpleHighguiDemoCore::stop is called but the SimpleHighguiDemoCore pthread is not active"); stateThread = STATE_THREAD_STOPPING; return; } stateThread=STATE_THREAD_STOPPING; LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: before going to sleep to wait for the signal from the workthread"); -#ifdef USE_STD_THREADS objectDetectorRun.notify_one(); objectDetectorThreadStartStop.wait(mtx_lock); LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread); mtx_lock.unlock(); -#else - pthread_cond_signal(&objectDetectorRun); - pthread_cond_wait(&objectDetectorThreadStartStop, &mutex); - LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread); - pthread_mutex_unlock(&mutex); -#endif } void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking() { LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking"); -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif if (stateThread == STATE_THREAD_WORKING_WITH_IMAGE) { LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking: since workthread is detecting objects at the moment, we should make cascadeInThread stop detecting and forget the detecting results"); @@ -508,12 +374,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking() resultDetect.clear(); isObjectDetectingReady=false; -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif - } bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector& rectsWhereRegions) @@ -529,11 +390,7 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingT bool shouldHandleResult = false; -#ifdef USE_STD_THREADS std::unique_lock mtx_lock(mtx); -#else - pthread_mutex_lock(&mutex); -#endif if (isObjectDetectingReady) { shouldHandleResult=true; @@ -562,18 +419,10 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingT timeWhenDetectingThreadStartedWork = getTickCount() ; -#ifdef USE_STD_THREADS objectDetectorRun.notify_one(); -#else - pthread_cond_signal(&objectDetectorRun); -#endif } -#ifdef USE_STD_THREADS mtx_lock.unlock(); -#else - pthread_mutex_unlock(&mutex); -#endif LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: result: shouldHandleResult=%d", (shouldHandleResult?1:0)); return shouldHandleResult; @@ -1034,5 +883,3 @@ const cv::DetectionBasedTracker::Parameters& DetectionBasedTracker::getParameter { return parameters; } - -#endif //defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(USE_STD_THREADS) diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index a5d0acfa41..a61da5e618 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -706,11 +706,7 @@ namespace comparators { template -#ifdef CV_CXX11 struct RectLess_ -#else -struct RectLess_ : public std::binary_function, cv::Rect_, bool> -#endif { bool operator()(const cv::Rect_& r1, const cv::Rect_& r2) const { @@ -723,11 +719,7 @@ struct RectLess_ : public std::binary_function, cv::Rect_, bool> typedef RectLess_ RectLess; -#ifdef CV_CXX11 struct KeypointGreater -#else -struct KeypointGreater : public std::binary_function -#endif { bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const { diff --git a/modules/ts/src/cuda_test.cpp b/modules/ts/src/cuda_test.cpp index 307e1296a2..ca48d0631e 100644 --- a/modules/ts/src/cuda_test.cpp +++ b/modules/ts/src/cuda_test.cpp @@ -462,11 +462,7 @@ namespace cvtest return false; } -#ifdef CV_CXX11 struct KeyPointLess -#else - struct KeyPointLess : std::binary_function -#endif { bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const { From e567135ed3abef3d228160a1e224433f0ee7cbbc Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 14:57:10 +0300 Subject: [PATCH 05/14] next: force C++11 features unconditionally: CV_CXX_MOVE_SEMANTICS/CV_CXX_STD_ARRAY --- modules/core/include/opencv2/core/cvdef.h | 58 ++----------------- modules/core/include/opencv2/core/cvstd.hpp | 2 - modules/core/include/opencv2/core/mat.hpp | 8 --- modules/core/include/opencv2/core/mat.inl.hpp | 29 ---------- modules/core/include/opencv2/core/ptr.inl.hpp | 4 -- modules/core/test/test_mat.cpp | 2 - 6 files changed, 5 insertions(+), 98 deletions(-) diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index b424d14799..7059a4d81d 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -421,63 +421,15 @@ Cv64suf; # error "OpenCV 4.x+ requires enabled C++11 support" #endif - -/****************************************************************************************\ -* C++ Move semantics * -\****************************************************************************************/ - -#ifndef CV_CXX_MOVE_SEMANTICS -# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && _MSC_VER >= 1600) -# define CV_CXX_MOVE_SEMANTICS 1 -# elif defined(__clang) -# if __has_feature(cxx_rvalue_references) -# define CV_CXX_MOVE_SEMANTICS 1 -# endif -# endif -#else -# if CV_CXX_MOVE_SEMANTICS == 0 -# undef CV_CXX_MOVE_SEMANTICS -# endif -#endif - -/****************************************************************************************\ -* C++11 std::array * -\****************************************************************************************/ - -#ifndef CV_CXX_STD_ARRAY -# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) -# define CV_CXX_STD_ARRAY 1 -# include -# endif -#else -# if CV_CXX_STD_ARRAY == 0 -# undef CV_CXX_STD_ARRAY -# endif -#endif - - -/****************************************************************************************\ -* C++11 override / final * -\****************************************************************************************/ - +#define CV_CXX_MOVE_SEMANTICS 1 +#define CV_CXX_STD_ARRAY 1 +#include #ifndef CV_OVERRIDE -# ifdef CV_CXX11 -# define CV_OVERRIDE override -# endif +# define CV_OVERRIDE override #endif -#ifndef CV_OVERRIDE -# define CV_OVERRIDE -#endif - #ifndef CV_FINAL -# ifdef CV_CXX11 -# define CV_FINAL final -# endif +# define CV_FINAL final #endif -#ifndef CV_FINAL -# define CV_FINAL -#endif - // Integer types portatibility diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 453904e6b7..ec2258bb2a 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -386,10 +386,8 @@ struct Ptr template Ptr dynamicCast() const; -#ifdef CV_CXX_MOVE_SEMANTICS Ptr(Ptr&& o); Ptr& operator = (Ptr&& o); -#endif private: detail::PtrOwner* owner; diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 627c7d14e6..9160037300 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -196,10 +196,8 @@ public: _InputArray(const UMat& um); _InputArray(const std::vector& umv); -#ifdef CV_CXX_STD_ARRAY template _InputArray(const std::array<_Tp, _Nm>& arr); template _InputArray(const std::array& arr); -#endif Mat getMat(int idx=-1) const; Mat getMat_(int idx=-1) const; @@ -2052,10 +2050,8 @@ public: /** @overload */ template void forEach(const Functor& operation) const; -#ifdef CV_CXX_MOVE_SEMANTICS Mat(Mat&& m); Mat& operator = (Mat&& m); -#endif enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; @@ -2319,7 +2315,6 @@ public: //! conversion to Matx template operator Matx::channel_type, m, n>() const; -#ifdef CV_CXX_MOVE_SEMANTICS Mat_(Mat_&& m); Mat_& operator = (Mat_&& m); @@ -2327,7 +2322,6 @@ public: Mat_& operator = (Mat&& m); Mat_(MatExpr&& e); -#endif }; typedef Mat_ Mat1b; @@ -2524,10 +2518,8 @@ public: //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; -#ifdef CV_CXX_MOVE_SEMANTICS UMat(UMat&& m); UMat& operator = (UMat&& m); -#endif /*! Returns the OpenCL buffer handle on which UMat operates on. The UMat instance should be kept alive during the use of the handle to prevent the buffer to be diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index dc1eadfefc..a8191b59fa 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -84,7 +84,6 @@ template inline _InputArray::_InputArray(const std::vector<_Tp>& vec) { init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } -#ifdef CV_CXX_STD_ARRAY template inline _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); } @@ -92,7 +91,6 @@ _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) template inline _InputArray::_InputArray(const std::array& arr) { init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); } -#endif inline _InputArray::_InputArray(const std::vector& vec) @@ -172,7 +170,6 @@ template inline _OutputArray::_OutputArray(std::vector<_Tp>& vec) { init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } -#ifdef CV_CXX_STD_ARRAY template inline _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } @@ -180,7 +177,6 @@ _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) template inline _OutputArray::_OutputArray(std::array& arr) { init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } -#endif inline _OutputArray::_OutputArray(std::vector&) @@ -214,7 +210,6 @@ template inline _OutputArray::_OutputArray(const std::vector<_Tp>& vec) { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } -#ifdef CV_CXX_STD_ARRAY template inline _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } @@ -222,7 +217,6 @@ _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) template inline _OutputArray::_OutputArray(const std::array& arr) { init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } -#endif template inline _OutputArray::_OutputArray(const std::vector >& vec) @@ -291,7 +285,6 @@ template inline _InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) { init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } -#ifdef CV_CXX_STD_ARRAY template inline _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } @@ -299,7 +292,6 @@ _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) template inline _InputOutputArray::_InputOutputArray(std::array& arr) { init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } -#endif inline _InputOutputArray::_InputOutputArray(std::vector&) { CV_Error(Error::StsUnsupportedFormat, "std::vector cannot be an input/output array\n"); } @@ -328,7 +320,6 @@ template inline _InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } -#ifdef CV_CXX_STD_ARRAY template inline _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) { init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } @@ -336,7 +327,6 @@ _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) template inline _InputOutputArray::_InputOutputArray(const std::array& arr) { init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } -#endif template inline _InputOutputArray::_InputOutputArray(const std::vector >& vec) @@ -594,7 +584,6 @@ Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); } -#ifdef CV_CXX_STD_ARRAY template inline Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) : flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), @@ -611,7 +600,6 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) else Mat((int)arr.size(), 1, traits::Type<_Tp>::value, (uchar*)arr.data()).copyTo(*this); } -#endif template inline Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) @@ -1261,7 +1249,6 @@ Mat::operator std::vector<_Tp>() const return v; } -#ifdef CV_CXX_STD_ARRAY template inline Mat::operator std::array<_Tp, _Nm>() const { @@ -1269,7 +1256,6 @@ Mat::operator std::array<_Tp, _Nm>() const copyTo(v); return v; } -#endif template inline Mat::operator Vec<_Tp, n>() const @@ -1337,8 +1323,6 @@ void Mat::push_back(const std::vector<_Tp>& v) push_back(Mat(v)); } -#ifdef CV_CXX_MOVE_SEMANTICS - inline Mat::Mat(Mat&& m) : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), @@ -1400,8 +1384,6 @@ Mat& Mat::operator = (Mat&& m) return *this; } -#endif - ///////////////////////////// MatSize //////////////////////////// @@ -1642,12 +1624,10 @@ Mat_<_Tp>::Mat_(const std::initializer_list sizes, std::initializer_list<_T : Mat(sizes, list) {} -#ifdef CV_CXX_STD_ARRAY template template inline Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData) : Mat(arr, copyData) {} -#endif template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) @@ -1935,7 +1915,6 @@ Mat_<_Tp>::operator std::vector<_Tp>() const return v; } -#ifdef CV_CXX_STD_ARRAY template template inline Mat_<_Tp>::operator std::array<_Tp, _Nm>() const { @@ -1943,7 +1922,6 @@ Mat_<_Tp>::operator std::array<_Tp, _Nm>() const copyTo(a); return a; } -#endif template template inline Mat_<_Tp>::operator Vec::channel_type, n>() const @@ -2007,8 +1985,6 @@ void Mat_<_Tp>::forEach(const Functor& operation) const { Mat::forEach<_Tp, Functor>(operation); } -#ifdef CV_CXX_MOVE_SEMANTICS - template inline Mat_<_Tp>::Mat_(Mat_&& m) : Mat(m) @@ -2056,7 +2032,6 @@ Mat_<_Tp>::Mat_(MatExpr&& e) *this = Mat(e); } -#endif ///////////////////////////// SparseMat ///////////////////////////// @@ -3827,8 +3802,6 @@ size_t UMat::total() const return p; } -#ifdef CV_CXX_MOVE_SEMANTICS - inline UMat::UMat(UMat&& m) : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator), @@ -3889,8 +3862,6 @@ UMat& UMat::operator = (UMat&& m) return *this; } -#endif - inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } diff --git a/modules/core/include/opencv2/core/ptr.inl.hpp b/modules/core/include/opencv2/core/ptr.inl.hpp index 466f6342ec..9165de0993 100644 --- a/modules/core/include/opencv2/core/ptr.inl.hpp +++ b/modules/core/include/opencv2/core/ptr.inl.hpp @@ -252,8 +252,6 @@ Ptr Ptr::dynamicCast() const return Ptr(*this, dynamic_cast(stored)); } -#ifdef CV_CXX_MOVE_SEMANTICS - template Ptr::Ptr(Ptr&& o) : owner(o.owner), stored(o.stored) { @@ -275,8 +273,6 @@ Ptr& Ptr::operator = (Ptr&& o) return *this; } -#endif - template void swap(Ptr& ptr1, Ptr& ptr2){ diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index bb149dbae1..17bcd5524e 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1608,7 +1608,6 @@ TEST(Mat, regression_7873_mat_vector_initialize) ASSERT_EQ(2, sub_mat.size[2]); } -#ifdef CV_CXX_STD_ARRAY TEST(Core_Mat_array, outputArray_create_getMat) { cv::Mat_ src_base(5, 1); @@ -1697,7 +1696,6 @@ TEST(Core_Mat_array, SplitMerge) EXPECT_EQ(0, cvtest::norm(src[i], dst[i], NORM_INF)); } } -#endif TEST(Mat, regression_8680) { From 2385a5870e1ad7b6fe689329c90a7d6e973acb4b Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 15:19:05 +0300 Subject: [PATCH 06/14] next(ml): eliminate dummy interface class ANN_MLP_ANNEAL --- modules/ml/include/opencv2/ml.hpp | 59 ++++++------------------ modules/ml/src/ann_mlp.cpp | 76 +------------------------------ modules/ml/test/test_mltests2.cpp | 4 +- 3 files changed, 17 insertions(+), 122 deletions(-) diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 31e7427735..2b694c8d47 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -1503,33 +1503,33 @@ public: /** ANNEAL: Update initial temperature. It must be \>=0. Default value is 10.*/ /** @see setAnnealInitialT */ - CV_WRAP double getAnnealInitialT() const; + CV_WRAP virtual double getAnnealInitialT() const = 0; /** @copybrief getAnnealInitialT @see getAnnealInitialT */ - CV_WRAP void setAnnealInitialT(double val); + CV_WRAP virtual void setAnnealInitialT(double val) = 0; /** ANNEAL: Update final temperature. It must be \>=0 and less than initialT. Default value is 0.1.*/ /** @see setAnnealFinalT */ - CV_WRAP double getAnnealFinalT() const; + CV_WRAP virtual double getAnnealFinalT() const = 0; /** @copybrief getAnnealFinalT @see getAnnealFinalT */ - CV_WRAP void setAnnealFinalT(double val); + CV_WRAP virtual void setAnnealFinalT(double val) = 0; /** ANNEAL: Update cooling ratio. It must be \>0 and less than 1. Default value is 0.95.*/ /** @see setAnnealCoolingRatio */ - CV_WRAP double getAnnealCoolingRatio() const; + CV_WRAP virtual double getAnnealCoolingRatio() const = 0; /** @copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio */ - CV_WRAP void setAnnealCoolingRatio(double val); + CV_WRAP virtual void setAnnealCoolingRatio(double val) = 0; /** ANNEAL: Update iteration per step. It must be \>0 . Default value is 10.*/ /** @see setAnnealItePerStep */ - CV_WRAP int getAnnealItePerStep() const; + CV_WRAP virtual int getAnnealItePerStep() const = 0; /** @copybrief getAnnealItePerStep @see getAnnealItePerStep */ - CV_WRAP void setAnnealItePerStep(int val); + CV_WRAP virtual void setAnnealItePerStep(int val) = 0; /** @brief Set/initialize anneal RNG */ - void setAnnealEnergyRNG(const RNG& rng); + virtual void setAnnealEnergyRNG(const RNG& rng) = 0; /** possible activation functions */ enum ActivationFunctions { @@ -1586,6 +1586,10 @@ public: }; +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef ANN_MLP ANN_MLP_ANNEAL; +#endif + /****************************************************************************************\ * Logistic Regression * \****************************************************************************************/ @@ -1870,43 +1874,6 @@ CV_EXPORTS void randMVNormal( InputArray mean, InputArray cov, int nsamples, Out CV_EXPORTS void createConcentricSpheresTestSet( int nsamples, int nfeatures, int nclasses, OutputArray samples, OutputArray responses); -/** @brief Artificial Neural Networks - Multi-Layer Perceptrons. - -@sa @ref ml_intro_ann -*/ -class CV_EXPORTS_W ANN_MLP_ANNEAL : public ANN_MLP -{ -public: - /** @see setAnnealInitialT */ - CV_WRAP virtual double getAnnealInitialT() const = 0; - /** @copybrief getAnnealInitialT @see getAnnealInitialT */ - CV_WRAP virtual void setAnnealInitialT(double val) = 0; - - /** ANNEAL: Update final temperature. - It must be \>=0 and less than initialT. Default value is 0.1.*/ - /** @see setAnnealFinalT */ - CV_WRAP virtual double getAnnealFinalT() const = 0; - /** @copybrief getAnnealFinalT @see getAnnealFinalT */ - CV_WRAP virtual void setAnnealFinalT(double val) = 0; - - /** ANNEAL: Update cooling ratio. - It must be \>0 and less than 1. Default value is 0.95.*/ - /** @see setAnnealCoolingRatio */ - CV_WRAP virtual double getAnnealCoolingRatio() const = 0; - /** @copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio */ - CV_WRAP virtual void setAnnealCoolingRatio(double val) = 0; - - /** ANNEAL: Update iteration per step. - It must be \>0 . Default value is 10.*/ - /** @see setAnnealItePerStep */ - CV_WRAP virtual int getAnnealItePerStep() const = 0; - /** @copybrief getAnnealItePerStep @see getAnnealItePerStep */ - CV_WRAP virtual void setAnnealItePerStep(int val) = 0; - - /** @brief Set/initialize anneal RNG */ - virtual void setAnnealEnergyRNG(const RNG& rng) = 0; -}; - /****************************************************************************************\ * Simulated annealing solver * diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index 156a0440ba..cec0af17dd 100644 --- a/modules/ml/src/ann_mlp.cpp +++ b/modules/ml/src/ann_mlp.cpp @@ -141,79 +141,7 @@ protected: }; -double ANN_MLP::getAnnealInitialT() const -{ - const ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - return this_->getAnnealInitialT(); -} - -void ANN_MLP::setAnnealInitialT(double val) -{ - ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - this_->setAnnealInitialT(val); -} - -double ANN_MLP::getAnnealFinalT() const -{ - const ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - return this_->getAnnealFinalT(); -} - -void ANN_MLP::setAnnealFinalT(double val) -{ - ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - this_->setAnnealFinalT(val); -} - -double ANN_MLP::getAnnealCoolingRatio() const -{ - const ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - return this_->getAnnealCoolingRatio(); -} - -void ANN_MLP::setAnnealCoolingRatio(double val) -{ - ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - this_->setAnnealCoolingRatio(val); -} - -int ANN_MLP::getAnnealItePerStep() const -{ - const ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - return this_->getAnnealItePerStep(); -} - -void ANN_MLP::setAnnealItePerStep(int val) -{ - ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - this_->setAnnealItePerStep(val); -} - -void ANN_MLP::setAnnealEnergyRNG(const RNG& rng) -{ - ANN_MLP_ANNEAL* this_ = dynamic_cast(this); - if (!this_) - CV_Error(Error::StsNotImplemented, "the class is not ANN_MLP_ANNEAL"); - this_->setAnnealEnergyRNG(rng); -} - -class ANN_MLPImpl CV_FINAL : public ANN_MLP_ANNEAL +class ANN_MLPImpl CV_FINAL : public ANN_MLP { public: ANN_MLPImpl() @@ -224,7 +152,7 @@ public: setTrainMethod(ANN_MLP::RPROP, 0.1, FLT_EPSILON); } - virtual ~ANN_MLPImpl() {} + virtual ~ANN_MLPImpl() CV_OVERRIDE {} inline TermCriteria getTermCriteria() const CV_OVERRIDE { return params.termCrit; } inline void setTermCriteria(TermCriteria val) CV_OVERRIDE { params.termCrit = val; } diff --git a/modules/ml/test/test_mltests2.cpp b/modules/ml/test/test_mltests2.cpp index 2ff0c93acb..7a9731a5d7 100644 --- a/modules/ml/test/test_mltests2.cpp +++ b/modules/ml/test/test_mltests2.cpp @@ -283,7 +283,7 @@ TEST_P(ML_ANN_METHOD, Test) #ifdef GENERATE_TESTDATA { - Ptr xx = ml::ANN_MLP_ANNEAL::create(); + Ptr xx = ml::ANN_MLP::create(); Mat_ layerSizesXX(1, 4); layerSizesXX(0, 0) = tdata->getNVars(); layerSizesXX(0, 1) = 30; @@ -303,7 +303,7 @@ TEST_P(ML_ANN_METHOD, Test) { FileStorage fs; fs.open(dataname + "_init_weight.yml.gz", FileStorage::READ); - Ptr x = ml::ANN_MLP_ANNEAL::create(); + Ptr x = ml::ANN_MLP::create(); x->read(fs.root()); x->setTrainMethod(methodType); if (methodType == ml::ANN_MLP::ANNEAL) From ca922443db5958460d24bb46abcd591dcc6f56c3 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 22 Mar 2018 16:19:47 +0300 Subject: [PATCH 07/14] next(calib3d): eliminate CirclesGridFinderParameters2 --- modules/calib3d/include/opencv2/calib3d.hpp | 17 +++++------------ modules/calib3d/misc/java/gen_dict.json | 3 +-- modules/calib3d/src/calibinit.cpp | 18 +++++------------- modules/calib3d/src/circlesgrid.cpp | 8 ++------ modules/calib3d/src/circlesgrid.hpp | 4 +--- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 22bb124627..83a707337f 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -881,16 +881,15 @@ struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters SYMMETRIC_GRID, ASYMMETRIC_GRID }; GridType gridType; -}; - -struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters2 : public CirclesGridFinderParameters -{ - CV_WRAP CirclesGridFinderParameters2(); CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING. CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from predicion. Used by CALIB_CB_CLUSTERING. }; +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef CirclesGridFinderParameters CirclesGridFinderParameters2; +#endif + /** @brief Finds centers in the grid of circles. @param image grid view of input circles; it must be an 8-bit grayscale or color image. @@ -926,13 +925,7 @@ the board to make the detection more robust in various environments. CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, OutputArray centers, int flags, const Ptr &blobDetector, - CirclesGridFinderParameters parameters); - -/** @overload */ -CV_EXPORTS_W bool findCirclesGrid2( InputArray image, Size patternSize, - OutputArray centers, int flags, - const Ptr &blobDetector, - CirclesGridFinderParameters2 parameters); + const CirclesGridFinderParameters& parameters); /** @overload */ CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, diff --git a/modules/calib3d/misc/java/gen_dict.json b/modules/calib3d/misc/java/gen_dict.json index 4c2d9d2f86..0e3519608b 100644 --- a/modules/calib3d/misc/java/gen_dict.json +++ b/modules/calib3d/misc/java/gen_dict.json @@ -1,7 +1,6 @@ { "class_ignore_list": [ - "CirclesGridFinderParameters", - "CirclesGridFinderParameters2" + "CirclesGridFinderParameters" ], "missing_consts" : { "Calib3d": { diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 283a9217a9..f157ede587 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -2094,22 +2094,14 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize, nelems, patternWasFound ); } -bool cv::findCirclesGrid( InputArray image, Size patternSize, - OutputArray centers, int flags, - const Ptr &blobDetector, - CirclesGridFinderParameters parameters) -{ - CirclesGridFinderParameters2 parameters2; - *((CirclesGridFinderParameters*)¶meters2) = parameters; - return cv::findCirclesGrid2(image, patternSize, centers, flags, blobDetector, parameters2); -} - -bool cv::findCirclesGrid2( InputArray _image, Size patternSize, +bool cv::findCirclesGrid( InputArray _image, Size patternSize, OutputArray _centers, int flags, const Ptr &blobDetector, - CirclesGridFinderParameters2 parameters) + const CirclesGridFinderParameters& parameters_) { CV_INSTRUMENT_REGION() + CirclesGridFinderParameters parameters = parameters_; // parameters.gridType is amended below + bool isAsymmetricGrid = (flags & CALIB_CB_ASYMMETRIC_GRID) ? true : false; bool isSymmetricGrid = (flags & CALIB_CB_SYMMETRIC_GRID ) ? true : false; CV_Assert(isAsymmetricGrid ^ isSymmetricGrid); @@ -2201,7 +2193,7 @@ bool cv::findCirclesGrid2( InputArray _image, Size patternSize, bool cv::findCirclesGrid( InputArray _image, Size patternSize, OutputArray _centers, int flags, const Ptr &blobDetector) { - return cv::findCirclesGrid2(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters2()); + return cv::findCirclesGrid(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters()); } /* End of file. */ diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 694644bbd5..1a08e3db8f 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -565,13 +565,9 @@ CirclesGridFinderParameters::CirclesGridFinderParameters() minRNGEdgeSwitchDist = 5.f; gridType = SYMMETRIC_GRID; -} -CirclesGridFinderParameters2::CirclesGridFinderParameters2() -: CirclesGridFinderParameters() -{ - squareSize = 1.0f; - maxRectifiedDistance = squareSize/2.0f; + squareSize = 1.0f; + maxRectifiedDistance = squareSize/2.0f; } CirclesGridFinder::CirclesGridFinder(Size _patternSize, const std::vector &testKeypoints, diff --git a/modules/calib3d/src/circlesgrid.hpp b/modules/calib3d/src/circlesgrid.hpp index ad0f916eed..9ddc7d552c 100644 --- a/modules/calib3d/src/circlesgrid.hpp +++ b/modules/calib3d/src/circlesgrid.hpp @@ -49,14 +49,12 @@ #include #include -#include "precomp.hpp" - class CirclesGridClusterFinder { CirclesGridClusterFinder& operator=(const CirclesGridClusterFinder&); CirclesGridClusterFinder(const CirclesGridClusterFinder&); public: - CirclesGridClusterFinder(const cv::CirclesGridFinderParameters2 ¶meters) + CirclesGridClusterFinder(const cv::CirclesGridFinderParameters ¶meters) { isAsymmetricGrid = parameters.gridType == cv::CirclesGridFinderParameters::ASYMMETRIC_GRID; squareSize = parameters.squareSize; From e7e29cb63c5fa13562d285fa6b9aa20a9e9fc838 Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Thu, 18 May 2017 13:49:46 +0300 Subject: [PATCH 08/14] cmake: add compilation test for VTK --- cmake/OpenCVDetectVTK.cmake | 13 +++++++++++++ cmake/checks/vtk_test.cpp | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 cmake/checks/vtk_test.cpp diff --git a/cmake/OpenCVDetectVTK.cmake b/cmake/OpenCVDetectVTK.cmake index f16077755a..702069b80b 100644 --- a/cmake/OpenCVDetectVTK.cmake +++ b/cmake/OpenCVDetectVTK.cmake @@ -52,5 +52,18 @@ if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} endif() endif() +try_compile(VTK_COMPILE_STATUS + "${OpenCV_BINARY_DIR}" + "${OpenCV_SOURCE_DIR}/cmake/checks/vtk_test.cpp" + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${VTK_INCLUDE_DIRS}" + LINK_LIBRARIES ${VTK_LIBRARIES} + OUTPUT_VARIABLE OUTPUT +) + +if(NOT ${VTK_COMPILE_STATUS}) + message(STATUS "VTK support is disabled. Compilation of the sample code has failed.") + return() +endif() + set(HAVE_VTK ON) message(STATUS "Found VTK ${VTK_VERSION} (${VTK_USE_FILE})") diff --git a/cmake/checks/vtk_test.cpp b/cmake/checks/vtk_test.cpp new file mode 100644 index 0000000000..2096133e5f --- /dev/null +++ b/cmake/checks/vtk_test.cpp @@ -0,0 +1,9 @@ +#include +#include +#include + +int main() +{ + vtkSmartPointer transform = vtkSmartPointer::New(); + return 0; +} From d4688e6474dcd59c1d66736b744a8049f386a90b Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 23 Mar 2018 12:07:10 +0300 Subject: [PATCH 09/14] cmake: require C++11 and CMake 3.5.1+ --- CMakeLists.txt | 4 ---- cmake/OpenCVDetectCXXCompiler.cmake | 16 ++++++++-------- cmake/OpenCVMinDepVersions.cmake | 2 +- doc/tutorials/dnn/dnn_halide/dnn_halide.markdown | 2 -- samples/CMakeLists.txt | 6 +++++- samples/cpp/example_cmake/CMakeLists.txt | 11 +++++------ 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc7b72c4b8..d760804d2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,7 +149,6 @@ endif() # ---------------------------------------------------------------------------- # Detect compiler and target platform architecture # ---------------------------------------------------------------------------- -OCV_OPTION(ENABLE_CXX11 "Enable C++11 compilation mode" "${OPENCV_CXX11}") include(cmake/OpenCVDetectCXXCompiler.cmake) ocv_cmake_hook(POST_DETECT_COMPILER) @@ -1018,9 +1017,6 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR) status("") status(" C/C++:") status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO) -if(ENABLE_CXX11 OR HAVE_CXX11) -status(" C++11:" HAVE_CXX11 THEN YES ELSE NO) -endif() status(" C++ Compiler:" ${OPENCV_COMPILER_STR}) status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}) status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}) diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index 8c9ff0345a..04a1f48134 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -166,14 +166,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1") endforeach() endif() -if(ENABLE_CXX11) - #cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED TRUE) - set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11 - if(CMAKE_CXX11_COMPILE_FEATURES) - set(HAVE_CXX11 ON) - endif() +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11 +if(CMAKE_CXX11_COMPILE_FEATURES) + set(HAVE_CXX11 ON) endif() if(NOT HAVE_CXX11) ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp") @@ -185,3 +182,6 @@ if(NOT HAVE_CXX11) endif() endif() endif() +if(NOT HAVE_CXX11) + message(FATAL_ERROR "OpenCV 4.x requires C++11") +endif() diff --git a/cmake/OpenCVMinDepVersions.cmake b/cmake/OpenCVMinDepVersions.cmake index d2c5b7c27f..f08fa57734 100644 --- a/cmake/OpenCVMinDepVersions.cmake +++ b/cmake/OpenCVMinDepVersions.cmake @@ -1,4 +1,4 @@ -set(MIN_VER_CMAKE 2.8.12.2) +set(MIN_VER_CMAKE 3.5.1) set(MIN_VER_CUDA 6.5) set(MIN_VER_PYTHON2 2.6) set(MIN_VER_PYTHON3 3.2) diff --git a/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown b/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown index 7271d08b68..fe82f05816 100644 --- a/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown +++ b/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown @@ -68,8 +68,6 @@ MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\ALL_BUILD.vcxproj ## Build OpenCV with Halide backend When you build OpenCV add the following configuration flags: -- `ENABLE_CXX11` - enable C++11 standard - - `WITH_HALIDE` - enable Halide linkage - `HALIDE_ROOT_DIR` - path to Halide build directory diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 45dae6a5ad..6ac1dea60b 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -81,7 +81,11 @@ else() # Standalone mode # #=================================================================================================== -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) + +# Enable C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) project(samples C CXX) option(BUILD_EXAMPLES "Build samples" ON) diff --git a/samples/cpp/example_cmake/CMakeLists.txt b/samples/cpp/example_cmake/CMakeLists.txt index 00c1687fa0..f7c5b6bbd6 100644 --- a/samples/cpp/example_cmake/CMakeLists.txt +++ b/samples/cpp/example_cmake/CMakeLists.txt @@ -1,5 +1,9 @@ # cmake needs this line -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) + +# Enable C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) # Define project name project(opencv_example_project) @@ -18,11 +22,6 @@ message(STATUS " version: ${OpenCV_VERSION}") message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") -if(CMAKE_VERSION VERSION_LESS "2.8.11") - # Add OpenCV headers location to your include paths - include_directories(${OpenCV_INCLUDE_DIRS}) -endif() - # Declare the executable target built from your sources add_executable(opencv_example example.cpp) From b07f772f36cc94bef03d0c5333bb145ae2ed6562 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 26 Mar 2018 15:21:45 +0300 Subject: [PATCH 10/14] android: enable C++11 in test sample --- platforms/android/build-tests/test_cmake_build.py | 13 +++++++++---- platforms/android/build-tests/test_ndk_build.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platforms/android/build-tests/test_cmake_build.py b/platforms/android/build-tests/test_cmake_build.py index f02915c611..eb4d43512a 100644 --- a/platforms/android/build-tests/test_cmake_build.py +++ b/platforms/android/build-tests/test_cmake_build.py @@ -8,12 +8,17 @@ log.basicConfig(format='%(message)s', level=log.DEBUG) CMAKE_TEMPLATE='''\ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Enable C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) + SET(PROJECT_NAME hello-android) PROJECT(${PROJECT_NAME}) + FIND_PACKAGE(OpenCV REQUIRED %(libset)s) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) FILE(GLOB srcs "*.cpp") + ADD_EXECUTABLE(${PROJECT_NAME} ${srcs}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenCV_LIBS} dl z) ''' @@ -28,9 +33,9 @@ int main(int argc, char* argv[]) { (void)argc; (void)argv; printf("%s\\n", message); - Size textsize = getTextSize(message, CV_FONT_HERSHEY_COMPLEX, 3, 5, 0); + Size textsize = getTextSize(message, FONT_HERSHEY_COMPLEX, 3, 5, 0); Mat img(textsize.height + 20, textsize.width + 20, CV_32FC1, Scalar(230,230,230)); - putText(img, message, Point(10, img.rows - 10), CV_FONT_HERSHEY_COMPLEX, 3, Scalar(0, 0, 0), 5); + putText(img, message, Point(10, img.rows - 10), FONT_HERSHEY_COMPLEX, 3, Scalar(0, 0, 0), 5); imwrite("/mnt/sdcard/HelloAndroid.png", img); return 0; } diff --git a/platforms/android/build-tests/test_ndk_build.py b/platforms/android/build-tests/test_ndk_build.py index cbc2b7c6ab..cc1dbc0102 100644 --- a/platforms/android/build-tests/test_ndk_build.py +++ b/platforms/android/build-tests/test_ndk_build.py @@ -22,7 +22,7 @@ include $(BUILD_SHARED_LIBRARY) TEMPLATE_APPLICATION_MK = '''\ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -fexceptions +APP_CPPFLAGS := -frtti -fexceptions -std=c++11 APP_ABI := {abi} APP_PLATFORM := android-9 ''' From 5b17a60dde5cb7706bc3b7f6caeb2dcb46850259 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 28 Mar 2018 15:19:54 +0300 Subject: [PATCH 11/14] next: drop HAVE_TEGRA_OPTIMIZATION/TADP --- .../android_binary_package/O4A_SDK.markdown | 12 ----- .../android_dev_intro.markdown | 25 --------- modules/calib3d/src/circlesgrid.cpp | 4 -- modules/calib3d/src/precomp.hpp | 4 -- .../core/include/opencv2/core/fast_math.hpp | 10 ---- modules/core/include/opencv2/core/private.hpp | 9 ---- modules/core/src/arithm.cpp | 53 ------------------- modules/core/src/precomp.hpp | 10 ---- modules/core/src/system.cpp | 33 ------------ modules/features2d/src/fast.cpp | 4 -- modules/features2d/src/precomp.hpp | 4 -- modules/highgui/src/precomp.hpp | 4 -- modules/imgproc/src/canny.cpp | 5 -- modules/imgproc/src/corner.cpp | 4 -- modules/imgproc/src/deriv.cpp | 14 ----- modules/imgproc/src/precomp.hpp | 4 -- modules/imgproc/src/pyramids.cpp | 10 ---- modules/imgproc/src/smooth.cpp | 5 -- modules/imgproc/src/templmatch.cpp | 5 -- modules/imgproc/src/thresh.cpp | 17 ------ modules/objdetect/src/cascadedetect.cpp | 4 -- modules/objdetect/src/precomp.hpp | 4 -- modules/photo/src/denoising.cpp | 5 -- modules/photo/src/precomp.hpp | 4 -- modules/stitching/src/blenders.cpp | 12 ----- modules/stitching/src/matchers.cpp | 5 -- modules/stitching/src/precomp.hpp | 4 -- modules/ts/src/ts_func.cpp | 10 ---- modules/video/src/lkpyramid.cpp | 10 ---- modules/video/src/precomp.hpp | 4 -- 30 files changed, 298 deletions(-) diff --git a/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown b/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown index cb61f6dd94..57600c03c6 100644 --- a/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown +++ b/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown @@ -19,18 +19,6 @@ If you encounter any error after thoroughly following these steps, feel free to [OpenCV4Android](https://groups.google.com/group/android-opencv/) discussion group or OpenCV [Q&A forum](http://answers.opencv.org). We'll do our best to help you out. -Tegra Android Development Pack users ------------------------------------- - -You may have used [Tegra Android Development -Pack](http://developer.nvidia.com/tegra-android-development-pack) (**TADP**) released by **NVIDIA** -for Android development environment setup. - -Beside Android development tools the TADP 2.0 includes OpenCV4Android SDK, so it can be already -installed in your system and you can skip to @ref tutorial_O4A_SDK_samples "samples" section of this tutorial. - -More details regarding TADP can be found in the @ref tutorial_android_dev_intro guide. - General info ------------ diff --git a/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown b/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown index 5d43b229d6..a614081926 100644 --- a/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown +++ b/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown @@ -31,31 +31,6 @@ key topis: -# OpenCV development will certainly require some knowledge of the [Android Camera](http://developer.android.com/guide/topics/media/camera.html) specifics. -Quick environment setup for Android development ------------------------------------------------ - -If you are making a clean environment install, then you can try [Tegra Android Development -Pack](https://developer.nvidia.com/tegra-android-development-pack) (**TADP**) released by -**NVIDIA**. - -@note Starting the *version 2.0* the TADP package includes *OpenCV for Tegra* SDK that is a regular -*OpenCV4Android SDK* extended with Tegra-specific stuff. When unpacked, TADP will cover all of the -environment setup automatically and you can skip the rest of the guide. - -If you are a beginner in Android development then we also recommend you to start with TADP. - -@note *NVIDIA*'s Tegra Android Development Pack includes some special features for *NVIDIA*’s [Tegra -platform](http://www.nvidia.com/object/tegra-3-processor.html) -but its use is not limited to *Tegra* devices only. \* You need at least *1.6 Gb* free -disk space for the install. - -- TADP will download Android SDK platforms and Android NDK from Google's server, so Internet - connection is required for the installation. -- TADP may ask you to flash your development kit at the end of installation process. Just skip - this step if you have no [Tegra Development Kit](http://developer.nvidia.com/mobile/tegra-hardware-sales-inquiries). -- (UNIX) TADP will ask you for *root* in the middle of installation, so you need to be a member of - *sudo* group. - Manual environment setup for Android development ------------------------------------------------ diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 1a08e3db8f..aecafa2fee 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -69,10 +69,6 @@ void drawPoints(const std::vector &points, Mat &outImage, int radius = void CirclesGridClusterFinder::hierarchicalClustering(const std::vector &points, const Size &patternSz, std::vector &patternPoints) { -#ifdef HAVE_TEGRA_OPTIMIZATION - if(tegra::useTegra() && tegra::hierarchicalClustering(points, patternSz, patternPoints)) - return; -#endif int j, n = (int)points.size(); size_t pn = static_cast(patternSz.area()); diff --git a/modules/calib3d/src/precomp.hpp b/modules/calib3d/src/precomp.hpp index 753c46ae54..b112786254 100644 --- a/modules/calib3d/src/precomp.hpp +++ b/modules/calib3d/src/precomp.hpp @@ -51,11 +51,7 @@ #include "opencv2/core/ocl.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/calib3d/calib3d_tegra.hpp" -#else #define GET_OPTIMIZED(func) (func) -#endif namespace cv diff --git a/modules/core/include/opencv2/core/fast_math.hpp b/modules/core/include/opencv2/core/fast_math.hpp index 7858d40492..6ff31c2017 100644 --- a/modules/core/include/opencv2/core/fast_math.hpp +++ b/modules/core/include/opencv2/core/fast_math.hpp @@ -70,10 +70,6 @@ # endif #endif -#ifdef HAVE_TEGRA_OPTIMIZATION -# include "tegra_round.hpp" -#endif - #if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ && !defined(__CUDACC__) // 1. general scheme #define ARM_ROUND(_value, _asm_string) \ @@ -112,9 +108,6 @@ cvRound( double value ) fistp t; } return t; -#elif ((defined _MSC_VER && defined _M_ARM) || defined CV_ICC || \ - defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION - TEGRA_ROUND_DBL(value); #elif defined CV_ICC || defined __GNUC__ # if defined ARM_ROUND_DBL ARM_ROUND_DBL(value); @@ -200,9 +193,6 @@ CV_INLINE int cvRound(float value) fistp t; } return t; -#elif ((defined _MSC_VER && defined _M_ARM) || defined CV_ICC || \ - defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION - TEGRA_ROUND_FLT(value); #elif defined CV_ICC || defined __GNUC__ # if defined ARM_ROUND_FLT ARM_ROUND_FLT(value); diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index a212ac1e12..d07727c5b0 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -622,15 +622,6 @@ typedef enum CvStatus } CvStatus; -#ifdef HAVE_TEGRA_OPTIMIZATION -namespace tegra { - -CV_EXPORTS bool useTegra(); -CV_EXPORTS void setUseTegra(bool flag); - -} -#endif - #ifdef ENABLE_INSTRUMENTATION namespace cv { diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 45721538bb..b03809d27f 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -931,59 +931,6 @@ void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst, { CV_INSTRUMENT_REGION() -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra()) - { - int kind1 = _src1.kind(), kind2 = _src2.kind(); - Mat src1 = _src1.getMat(), src2 = _src2.getMat(); - bool src1Scalar = checkScalar(src1, _src2.type(), kind1, kind2); - bool src2Scalar = checkScalar(src2, _src1.type(), kind2, kind1); - - if (!src1Scalar && !src2Scalar && - src1.depth() == CV_8U && src2.type() == src1.type() && - src1.dims == 2 && src2.size() == src1.size() && - mask.empty()) - { - if (dtype < 0) - { - if (_dst.fixedType()) - { - dtype = _dst.depth(); - } - else - { - dtype = src1.depth(); - } - } - - dtype = CV_MAT_DEPTH(dtype); - - if (!_dst.fixedType() || dtype == _dst.depth()) - { - _dst.create(src1.size(), CV_MAKE_TYPE(dtype, src1.channels())); - - if (dtype == CV_16S) - { - Mat dst = _dst.getMat(); - if(tegra::subtract_8u8u16s(src1, src2, dst)) - return; - } - else if (dtype == CV_32F) - { - Mat dst = _dst.getMat(); - if(tegra::subtract_8u8u32f(src1, src2, dst)) - return; - } - else if (dtype == CV_8S) - { - Mat dst = _dst.getMat(); - if(tegra::subtract_8u8u8s(src1, src2, dst)) - return; - } - } - } - } -#endif arithm_op(_src1, _src2, _dst, mask, dtype, getSubTab(), false, 0, OCL_OP_SUB ); } diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 3d6835fd0d..1e261785b2 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -89,11 +89,7 @@ #include "arithm_core.hpp" #include "hal_replacement.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/core/core_tegra.hpp" -#else #define GET_OPTIMIZED(func) (func) -#endif namespace cv { @@ -269,9 +265,6 @@ struct CoreTLSData //#endif useIPP(-1), useIPP_NE(-1) -#ifdef HAVE_TEGRA_OPTIMIZATION - ,useTegra(-1) -#endif #ifdef HAVE_OPENVX ,useOpenVX(-1) #endif @@ -285,9 +278,6 @@ struct CoreTLSData //#endif int useIPP; // 1 - use, 0 - do not use, -1 - auto/not initialized int useIPP_NE; // 1 - use, 0 - do not use, -1 - auto/not initialized -#ifdef HAVE_TEGRA_OPTIMIZATION - int useTegra; // 1 - use, 0 - do not use, -1 - auto/not initialized -#endif #ifdef HAVE_OPENVX int useOpenVX; // 1 - use, 0 - do not use, -1 - auto/not initialized #endif diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 0f20248a3b..1d8d8557ee 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -619,9 +619,6 @@ void setUseOptimized( bool flag ) #ifdef HAVE_OPENCL ocl::setUseOpenCL(flag); #endif -#ifdef HAVE_TEGRA_OPTIMIZATION - ::tegra::setUseTegra(flag); -#endif } bool useOptimized(void) @@ -2140,34 +2137,4 @@ void setUseIPP_NE(bool flag) } // namespace cv -#ifdef HAVE_TEGRA_OPTIMIZATION - -namespace tegra { - -bool useTegra() -{ - cv::CoreTLSData* data = cv::getCoreTlsData().get(); - - if (data->useTegra < 0) - { - const char* pTegraEnv = getenv("OPENCV_TEGRA"); - if (pTegraEnv && (cv::String(pTegraEnv) == "disabled")) - data->useTegra = false; - else - data->useTegra = true; - } - - return (data->useTegra > 0); -} - -void setUseTegra(bool flag) -{ - cv::CoreTLSData* data = cv::getCoreTlsData().get(); - data->useTegra = flag; -} - -} // namespace tegra - -#endif - /* End of file. */ diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index 106e5802cd..5299e14ae5 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -497,10 +497,6 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool FAST_t<12>(_img, keypoints, threshold, nonmax_suppression); break; case FastFeatureDetector::TYPE_9_16: -#ifdef HAVE_TEGRA_OPTIMIZATION - if(tegra::useTegra() && tegra::FAST(_img, keypoints, threshold, nonmax_suppression)) - break; -#endif FAST_t<16>(_img, keypoints, threshold, nonmax_suppression); break; } diff --git a/modules/features2d/src/precomp.hpp b/modules/features2d/src/precomp.hpp index c3db78b9da..27feebcd54 100644 --- a/modules/features2d/src/precomp.hpp +++ b/modules/features2d/src/precomp.hpp @@ -53,8 +53,4 @@ #include -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/features2d/features2d_tegra.hpp" -#endif - #endif diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 1d72a5d7a2..cf23a39e17 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -68,10 +68,6 @@ #undef abs #endif -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/highgui/highgui_tegra.hpp" -#endif - /* Errors */ #define HG_OK 0 /* Don't bet on it! */ #define HG_BADNAME -1 /* Bad window or file name */ diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 1d413726b8..e0753bd1d4 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -996,11 +996,6 @@ void Canny( InputArray _src, OutputArray _dst, aperture_size, L2gradient ) ) -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::canny(src, dst, low_thresh, high_thresh, aperture_size, L2gradient)) - return; -#endif - CV_IPP_RUN_FAST(ipp_Canny(src, Mat(), Mat(), dst, (float)low_thresh, (float)high_thresh, L2gradient, aperture_size)) if (L2gradient) diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index e784fa2403..cfb5681c9a 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -247,10 +247,6 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, int aperture_size, int op_type, double k=0., int borderType=BORDER_DEFAULT ) { -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::cornerEigenValsVecs(src, eigenv, block_size, aperture_size, op_type, k, borderType)) - return; -#endif #if CV_TRY_AVX bool haveAvx = CV_CPU_HAS_SUPPORT_AVX; #endif diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index 3e464baa72..16e2278f82 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -808,20 +808,6 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, CV_IPP_RUN(!(cv::ocl::isOpenCLActivated() && _dst.isUMat()), ipp_Laplacian(_src, _dst, ksize, scale, delta, borderType)); - -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && scale == 1.0 && delta == 0) - { - Mat src = _src.getMat(), dst = _dst.getMat(); - if (ksize == 1 && tegra::laplace1(src, dst, borderType)) - return; - if (ksize == 3 && tegra::laplace3(src, dst, borderType)) - return; - if (ksize == 5 && tegra::laplace5(src, dst, borderType)) - return; - } -#endif - if( ksize == 1 || ksize == 3 ) { float K[2][9] = diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp index 55241d9b88..d0d02e164d 100644 --- a/modules/imgproc/src/precomp.hpp +++ b/modules/imgproc/src/precomp.hpp @@ -61,11 +61,7 @@ #include #include -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/imgproc/imgproc_tegra.hpp" -#else #define GET_OPTIMIZED(func) (func) -#endif /* helper tables */ extern const uchar icvSaturate8u_cv[]; diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index 7ece7f5537..af24d38b83 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -1355,11 +1355,6 @@ void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borde CALL_HAL(pyrDown, cv_hal_pyrdown, src.data, src.step, src.cols, src.rows, dst.data, dst.step, dst.cols, dst.rows, depth, src.channels(), borderType); -#ifdef HAVE_TEGRA_OPTIMIZATION - if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrDown(src, dst)) - return; -#endif - #ifdef HAVE_IPP bool isolated = (borderType & BORDER_ISOLATED) != 0; int borderTypeNI = borderType & ~BORDER_ISOLATED; @@ -1463,11 +1458,6 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT Mat dst = _dst.getMat(); int depth = src.depth(); -#ifdef HAVE_TEGRA_OPTIMIZATION - if(borderType == BORDER_DEFAULT && tegra::useTegra() && tegra::pyrUp(src, dst)) - return; -#endif - #ifdef HAVE_IPP bool isolated = (borderType & BORDER_ISOLATED) != 0; int borderTypeNI = borderType & ~BORDER_ISOLATED; diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 72876d6332..9b1c9fa32e 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -4566,11 +4566,6 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) CV_IPP_RUN_FAST(ipp_medianFilter(src0, dst, ksize)); -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::medianBlur(src0, dst, ksize)) - return; -#endif - bool useSortNet = ksize == 3 || (ksize == 5 #if !(CV_SIMD128) && ( src0.depth() > CV_8U || src0.channels() == 2 || src0.channels() > 4 ) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 302e26ef67..b21a485b33 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -1118,11 +1118,6 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, _result.create(corrSize, CV_32F); Mat result = _result.getMat(); -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::matchTemplate(img, templ, result, method)) - return; -#endif - CV_IPP_RUN_FAST(ipp_matchTemplate(img, templ, result, method)) crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0); diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 520a9c8fe9..375f1f7b3b 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -136,11 +136,6 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type ) src_step = dst_step = roi.width; } -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::thresh_8u(_src, _dst, roi.width, roi.height, thresh, maxval, type)) - return; -#endif - #if defined(HAVE_IPP) CV_IPP_CHECK() { @@ -356,8 +351,6 @@ thresh_16u(const Mat& _src, Mat& _dst, ushort thresh, ushort maxval, int type) src_step = dst_step = roi.width; } - // HAVE_TEGRA_OPTIMIZATION not supported - // HAVE_IPP not supported const ushort* src = _src.ptr(); @@ -500,11 +493,6 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type ) src_step = dst_step = roi.width; } -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::thresh_16s(_src, _dst, roi.width, roi.height, thresh, maxval, type)) - return; -#endif - #if defined(HAVE_IPP) CV_IPP_CHECK() { @@ -697,11 +685,6 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type ) roi.height = 1; } -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::thresh_32f(_src, _dst, roi.width, roi.height, thresh, maxval, type)) - return; -#endif - #if defined(HAVE_IPP) CV_IPP_CHECK() { diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 6c98eb9299..79af4576f4 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -969,10 +969,6 @@ Ptr CascadeClassifierImpl::getMaskGenerato Ptr createFaceDetectionMaskGenerator() { -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra()) - return tegra::getCascadeClassifierMaskGenerator(); -#endif return Ptr(); } diff --git a/modules/objdetect/src/precomp.hpp b/modules/objdetect/src/precomp.hpp index 448d8b19b7..cbefc396be 100644 --- a/modules/objdetect/src/precomp.hpp +++ b/modules/objdetect/src/precomp.hpp @@ -50,8 +50,4 @@ #include "opencv2/core/ocl.hpp" #include "opencv2/core/private.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/objdetect/objdetect_tegra.hpp" -#endif - #endif diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp index ee9e57331e..e81a53ba55 100644 --- a/modules/photo/src/denoising.cpp +++ b/modules/photo/src/denoising.cpp @@ -131,11 +131,6 @@ void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst, const std::vec switch (normType) { case NORM_L2: -#ifdef HAVE_TEGRA_OPTIMIZATION - if(hn == 1 && tegra::useTegra() && - tegra::fastNlMeansDenoising(src, dst, h[0], templateWindowSize, searchWindowSize)) - return; -#endif switch (depth) { case CV_8U: fastNlMeansDenoising_(src, dst, h, diff --git a/modules/photo/src/precomp.hpp b/modules/photo/src/precomp.hpp index 4355f13c00..18348819e7 100644 --- a/modules/photo/src/precomp.hpp +++ b/modules/photo/src/precomp.hpp @@ -49,8 +49,4 @@ #include "opencv2/core/ocl.hpp" #include "opencv2/imgproc.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/photo/photo_tegra.hpp" -#endif - #endif diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index ee665b348d..94047e4ed6 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -625,12 +625,6 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) { Mat src; Mat weight; -#ifdef HAVE_TEGRA_OPTIMIZATION - src = _src.getMat(); - weight = _weight.getMat(); - if(tegra::useTegra() && tegra::normalizeUsingWeightMap(weight, src)) - return; -#endif #ifdef HAVE_OPENCL if ( !cv::ocl::isOpenCLActivated() || @@ -697,12 +691,6 @@ void createWeightMap(InputArray mask, float sharpness, InputOutputArray weight) void createLaplacePyr(InputArray img, int num_levels, std::vector &pyr) { -#ifdef HAVE_TEGRA_OPTIMIZATION - cv::Mat imgMat = img.getMat(); - if(tegra::useTegra() && tegra::createLaplacePyr(imgMat, num_levels, pyr)) - return; -#endif - pyr.resize(num_levels + 1); if(img.depth() == CV_8U) diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 140d4dae1e..6b9d75cdd8 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -187,11 +187,6 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat CV_Assert(features1.descriptors.type() == features2.descriptors.type()); CV_Assert(features2.descriptors.depth() == CV_8U || features2.descriptors.depth() == CV_32F); -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::match2nearest(features1, features2, matches_info, match_conf_)) - return; -#endif - matches_info.matches.clear(); Ptr matcher; diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index eff78cf585..ef3740ed76 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -95,10 +95,6 @@ #include "opencv2/core/private.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -# include "opencv2/stitching/stitching_tegra.hpp" -#endif - #include "util_log.hpp" #endif diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index a639dc2e18..8c5d6f3d54 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -3,10 +3,6 @@ #include #include "opencv2/imgproc/types_c.h" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "tegra.hpp" -#endif - using namespace cv; namespace cvtest @@ -3101,12 +3097,6 @@ void printVersionInfo(bool useStdOut) ::testing::Test::RecordProperty("cv_cpu_features", cpu_features); if (useStdOut) std::cout << "CPU features: " << cpu_features << std::endl; -#ifdef HAVE_TEGRA_OPTIMIZATION - const char * tegra_optimization = tegra::useTegra() && tegra::isDeviceSupported() ? "enabled" : "disabled"; - ::testing::Test::RecordProperty("cv_tegra_optimization", tegra_optimization); - if (useStdOut) std::cout << "Tegra optimization: " << tegra_optimization << std::endl; -#endif - #ifdef HAVE_IPP const char * ipp_optimization = cv::ipp::useIPP()? "enabled" : "disabled"; ::testing::Test::RecordProperty("cv_ipp_optimization", ipp_optimization); diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index 48f896d4e0..d65f82da1e 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -60,11 +60,6 @@ static void calcSharrDeriv(const cv::Mat& src, cv::Mat& dst) CV_Assert(depth == CV_8U); dst.create(rows, cols, CV_MAKETYPE(DataType::depth, cn*2)); -#ifdef HAVE_TEGRA_OPTIMIZATION - if (tegra::useTegra() && tegra::calcSharrDeriv(src, dst)) - return; -#endif - int x, y, delta = (int)alignSize((cols + 2)*cn, 16); AutoBuffer _tempBuf(delta*2 + 64); deriv_type *trow0 = alignPtr(_tempBuf + cn, 16), *trow1 = alignPtr(trow0 + delta, 16); @@ -1378,12 +1373,7 @@ void SparsePyrLKOpticalFlowImpl::calc( InputArray _prevImg, InputArray _nextImg, CV_Assert(prevPyr[level * lvlStep1].size() == nextPyr[level * lvlStep2].size()); CV_Assert(prevPyr[level * lvlStep1].type() == nextPyr[level * lvlStep2].type()); -#ifdef HAVE_TEGRA_OPTIMIZATION - typedef tegra::LKTrackerInvoker LKTrackerInvoker; -#else typedef cv::detail::LKTrackerInvoker LKTrackerInvoker; -#endif - parallel_for_(Range(0, npoints), LKTrackerInvoker(prevPyr[level * lvlStep1], derivI, nextPyr[level * lvlStep2], prevPts, nextPts, status, err, diff --git a/modules/video/src/precomp.hpp b/modules/video/src/precomp.hpp index 5f1bbf827d..aac0c5734f 100644 --- a/modules/video/src/precomp.hpp +++ b/modules/video/src/precomp.hpp @@ -49,8 +49,4 @@ #include "opencv2/core/ocl.hpp" #include "opencv2/core.hpp" -#ifdef HAVE_TEGRA_OPTIMIZATION -#include "opencv2/video/video_tegra.hpp" -#endif - #endif From 250941bd47113c982ff684646279513c4b7efc6c Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 28 Mar 2018 15:34:59 +0300 Subject: [PATCH 12/14] next: drop WITH_CSTRIPES --- CMakeLists.txt | 2 -- cmake/OpenCVDetectCStripes.cmake | 11 -------- cmake/OpenCVFindLibsPerf.cmake | 11 ++------ cmake/templates/cvconfig.h.in | 3 --- modules/core/src/parallel.cpp | 45 +++++--------------------------- 5 files changed, 8 insertions(+), 64 deletions(-) delete mode 100644 cmake/OpenCVDetectCStripes.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d760804d2c..966505aacc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,6 @@ OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O" OFF OCV_OPTION(WITH_QTKIT "Use QTKit Video I/O backend" OFF IF APPLE ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF) -OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF (WIN32 AND NOT WINRT) ) OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32 OR MINGW) ) OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) ) OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) @@ -1331,7 +1330,6 @@ endif() # Order is similar to CV_PARALLEL_FRAMEWORK in core/src/parallel.cpp ocv_build_features_string(parallel_status EXCLUSIVE IF HAVE_TBB THEN "TBB (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" - IF HAVE_CSTRIPES THEN "C=" IF HAVE_OPENMP THEN "OpenMP" IF HAVE_GCD THEN "GCD" IF WINRT OR HAVE_CONCURRENCY THEN "Concurrency" diff --git a/cmake/OpenCVDetectCStripes.cmake b/cmake/OpenCVDetectCStripes.cmake deleted file mode 100644 index dce52d92b1..0000000000 --- a/cmake/OpenCVDetectCStripes.cmake +++ /dev/null @@ -1,11 +0,0 @@ -if(WIN32) - find_path( CSTRIPES_LIB_DIR - NAMES "C=.lib" - DOC "The path to C= lib and dll") - if(CSTRIPES_LIB_DIR) - ocv_include_directories("${CSTRIPES_LIB_DIR}/..") - link_directories("${CSTRIPES_LIB_DIR}") - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} "C=") - set(HAVE_CSTRIPES 1) - endif() -endif() diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 59c9c4ffca..e12a04656f 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -104,22 +104,15 @@ if(WITH_CLP) endif() endif(WITH_CLP) -# --- C= --- -if(WITH_CSTRIPES AND NOT HAVE_TBB) - include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake") -else() - set(HAVE_CSTRIPES 0) -endif() - # --- GCD --- -if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES) +if(APPLE AND NOT HAVE_TBB) set(HAVE_GCD 1) else() set(HAVE_GCD 0) endif() # --- Concurrency --- -if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES) +if(MSVC AND NOT HAVE_TBB) set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concurrencytest.cpp") file(WRITE "${_fname}" "#if _MSC_VER < 1600\n#error\n#endif\nint main() { return 0; }\n") try_compile(HAVE_CONCURRENCY "${CMAKE_BINARY_DIR}" "${_fname}") diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index d98b0c4159..f6171d74c6 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -46,9 +46,6 @@ /* Cocoa API */ #cmakedefine HAVE_COCOA -/* C= */ -#cmakedefine HAVE_CSTRIPES - /* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/ #cmakedefine HAVE_CUBLAS diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index ca3f9bdd21..829ccf4585 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -78,13 +78,12 @@ #endif /* IMPORTANT: always use the same order of defines - 1. HAVE_TBB - 3rdparty library, should be explicitly enabled - 2. HAVE_CSTRIPES - 3rdparty library, should be explicitly enabled - 3. HAVE_OPENMP - integrated to compiler, should be explicitly enabled - 4. HAVE_GCD - system wide, used automatically (APPLE only) - 5. WINRT - system wide, used automatically (Windows RT only) - 6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11) - 7. HAVE_PTHREADS_PF - pthreads if available + - HAVE_TBB - 3rdparty library, should be explicitly enabled + - HAVE_OPENMP - integrated to compiler, should be explicitly enabled + - HAVE_GCD - system wide, used automatically (APPLE only) + - WINRT - system wide, used automatically (Windows RT only) + - HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11) + - HAVE_PTHREADS_PF - pthreads if available */ #if defined HAVE_TBB @@ -96,9 +95,6 @@ #endif #undef min #undef max -#elif defined HAVE_CSTRIPES - #include "C=.h" - #undef shared #elif defined HAVE_OPENMP #include #elif defined HAVE_GCD @@ -113,8 +109,6 @@ #if defined HAVE_TBB # define CV_PARALLEL_FRAMEWORK "tbb" -#elif defined HAVE_CSTRIPES -# define CV_PARALLEL_FRAMEWORK "cstripes" #elif defined HAVE_OPENMP # define CV_PARALLEL_FRAMEWORK "openmp" #elif defined HAVE_GCD @@ -385,8 +379,6 @@ namespace tbb::parallel_for(tbb::blocked_range(range.start, range.end), *this); } }; -#elif defined HAVE_CSTRIPES || defined HAVE_OPENMP - typedef ParallelLoopBodyWrapper ProxyLoopBody; #elif defined HAVE_GCD typedef ParallelLoopBodyWrapper ProxyLoopBody; static void block_function(void* context, size_t index) @@ -419,8 +411,6 @@ static int numThreads = -1; #else static tbb::task_scheduler_init tbbScheduler(tbb::task_scheduler_init::deferred); #endif -#elif defined HAVE_CSTRIPES -// nothing for C= #elif defined HAVE_OPENMP static int numThreadsMax = omp_get_max_threads(); #elif defined HAVE_GCD @@ -520,17 +510,6 @@ static void parallel_for_impl(const cv::Range& range, const cv::ParallelLoopBody pbody(); #endif -#elif defined HAVE_CSTRIPES - - parallel(MAX(0, numThreads)) - { - int offset = stripeRange.start; - int len = stripeRange.end - offset; - Range r(offset + CPX_RANGE_START(len), offset + CPX_RANGE_END(len)); - pbody(r); - barrier(); - } - #elif defined HAVE_OPENMP #pragma omp parallel for schedule(dynamic) num_threads(numThreads > 0 ? numThreads : numThreadsMax) @@ -602,12 +581,6 @@ int cv::getNumThreads(void) : tbb::task_scheduler_init::default_num_threads(); #endif -#elif defined HAVE_CSTRIPES - - return numThreads > 0 - ? numThreads - : cv::getNumberOfCPUs(); - #elif defined HAVE_OPENMP return numThreads > 0 @@ -682,10 +655,6 @@ void cv::setNumThreads( int threads_ ) if(threads > 0) tbbScheduler.initialize(threads); #endif -#elif defined HAVE_CSTRIPES - - return; // nothing needed - #elif defined HAVE_OPENMP return; // nothing needed as num_threads clause is used in #pragma omp parallel for @@ -735,8 +704,6 @@ int cv::getThreadNum(void) #else return 0; #endif -#elif defined HAVE_CSTRIPES - return pix(); #elif defined HAVE_OPENMP return omp_get_thread_num(); #elif defined HAVE_GCD From c6aa97c9aab9d58855ad64a22ad0f4d1cb739ed8 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 3 Apr 2018 16:41:48 +0300 Subject: [PATCH 13/14] next(android): java3 -> java4 --- cmake/OpenCVGenAndroidMK.cmake | 2 +- .../android_binary_package/android_ocl_intro.markdown | 4 ++-- modules/java/android_sdk/build.gradle.in | 2 +- .../android/java/org/opencv/android/AsyncServiceHelper.java | 2 +- .../android/java/org/opencv/android/StaticHelper.java | 2 +- .../src/org/opencv/samples/tutorial4/NativePart.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/OpenCVGenAndroidMK.cmake b/cmake/OpenCVGenAndroidMK.cmake index 832ed67533..ebf25d72a6 100644 --- a/cmake/OpenCVGenAndroidMK.cmake +++ b/cmake/OpenCVGenAndroidMK.cmake @@ -48,7 +48,7 @@ if(ANDROID) string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}") if(BUILD_FAT_JAVA_LIB) - set(OPENCV_LIBS_CONFIGMAKE java3) + set(OPENCV_LIBS_CONFIGMAKE java4) else() set(OPENCV_LIBS_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}") endif() diff --git a/doc/tutorials/introduction/android_binary_package/android_ocl_intro.markdown b/doc/tutorials/introduction/android_binary_package/android_ocl_intro.markdown index 3dab6e8c98..b41f91b241 100644 --- a/doc/tutorials/introduction/android_binary_package/android_ocl_intro.markdown +++ b/doc/tutorials/introduction/android_binary_package/android_ocl_intro.markdown @@ -144,7 +144,7 @@ Here is a simple Java wrapper for our JNI stuff: public class NativeGLRenderer { static { - System.loadLibrary("opencv_java3"); // comment this when using OpenCV Manager + System.loadLibrary("opencv_java4"); // comment this when using OpenCV Manager System.loadLibrary("JNIrender"); } @@ -383,7 +383,7 @@ Unfortunately `UMat` keeps OpenCL _buffer_ internally, that can't be wrapped ove path/to/cmake.exe -GNinja -DCMAKE_MAKE_PROGRAM="path/to/ninja.exe" -DCMAKE_TOOLCHAIN_FILE=path/to/opencv/platforms/android/android.toolchain.cmake -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON path/to/opencv path/to/ninja.exe install/strip @endcode - To use your own modified `libopencv_java3.so` you have to keep inside your APK, not to use OpenCV Manager and load it manually via `System.loadLibrary("opencv_java3")`. + To use your own modified `libopencv_java4.so` you have to keep inside your APK, not to use OpenCV Manager and load it manually via `System.loadLibrary("opencv_java4")`. Performance notes ----------------- diff --git a/modules/java/android_sdk/build.gradle.in b/modules/java/android_sdk/build.gradle.in index 6d317fcd39..f4c260e40d 100644 --- a/modules/java/android_sdk/build.gradle.in +++ b/modules/java/android_sdk/build.gradle.in @@ -49,7 +49,7 @@ // - avoid using of "OpenCVLoader.initAsync()" approach - it is deprecated // It may load library with different version (from OpenCV Android Manager, which is installed separatelly on device) // -// - use "System.loadLibrary("opencv_java3")" or "OpenCVLoader.initDebug()" +// - use "System.loadLibrary("opencv_java4")" or "OpenCVLoader.initDebug()" // TODO: Add accurate API to load OpenCV native library // // diff --git a/modules/java/generator/android/java/org/opencv/android/AsyncServiceHelper.java b/modules/java/generator/android/java/org/opencv/android/AsyncServiceHelper.java index 04a4ac6257..a718ca3c5d 100644 --- a/modules/java/generator/android/java/org/opencv/android/AsyncServiceHelper.java +++ b/modules/java/generator/android/java/org/opencv/android/AsyncServiceHelper.java @@ -376,7 +376,7 @@ class AsyncServiceHelper else { // If the dependencies list is not defined or empty. - String AbsLibraryPath = Path + File.separator + "libopencv_java3.so"; + String AbsLibraryPath = Path + File.separator + "libopencv_java4.so"; result = loadLibrary(AbsLibraryPath); } diff --git a/modules/java/generator/android/java/org/opencv/android/StaticHelper.java b/modules/java/generator/android/java/org/opencv/android/StaticHelper.java index f670d933e6..934dd7570c 100644 --- a/modules/java/generator/android/java/org/opencv/android/StaticHelper.java +++ b/modules/java/generator/android/java/org/opencv/android/StaticHelper.java @@ -92,7 +92,7 @@ class StaticHelper { else { // If dependencies list is not defined or empty. - result = loadLibrary("opencv_java3"); + result = loadLibrary("opencv_java4"); } return result; diff --git a/samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/NativePart.java b/samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/NativePart.java index e5f11ba3ae..e3d11709a9 100644 --- a/samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/NativePart.java +++ b/samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/NativePart.java @@ -3,7 +3,7 @@ package org.opencv.samples.tutorial4; public class NativePart { static { - System.loadLibrary("opencv_java3"); + System.loadLibrary("opencv_java4"); System.loadLibrary("JNIpart"); } From c917be2189fed923f2458f7e1ef972b0a4706259 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 4 Apr 2018 16:03:26 +0300 Subject: [PATCH 14/14] next(core): use C++11 classes for cv::Mutex/cv::AutoLock --- modules/core/include/opencv2/core/utility.hpp | 32 +------ modules/core/src/system.cpp | 87 ------------------- 2 files changed, 4 insertions(+), 115 deletions(-) diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 092f732c78..e37f261a82 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -58,6 +58,8 @@ #include +#include // std::mutex, std::lock_guard + namespace cv { @@ -648,34 +650,8 @@ void Mat::forEach_impl(const Functor& operation) { /////////////////////////// Synchronization Primitives /////////////////////////////// -class CV_EXPORTS Mutex -{ -public: - Mutex(); - ~Mutex(); - Mutex(const Mutex& m); - Mutex& operator = (const Mutex& m); - - void lock(); - bool trylock(); - void unlock(); - - struct Impl; -protected: - Impl* impl; -}; - -class CV_EXPORTS AutoLock -{ -public: - AutoLock(Mutex& m) : mutex(&m) { mutex->lock(); } - ~AutoLock() { mutex->unlock(); } -protected: - Mutex* mutex; -private: - AutoLock(const AutoLock&); - AutoLock& operator = (const AutoLock&); -}; +typedef std::recursive_mutex Mutex; +typedef std::lock_guard AutoLock; // TLS interface class CV_EXPORTS TLSDataContainer diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 1d8d8557ee..574622a267 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1101,93 +1101,6 @@ cvErrorFromIppStatus( int status ) namespace cv { bool __termination = false; -} - -namespace cv -{ - -#if defined _WIN32 || defined WINCE - -struct Mutex::Impl -{ - Impl() - { -#if (_WIN32_WINNT >= 0x0600) - ::InitializeCriticalSectionEx(&cs, 1000, 0); -#else - ::InitializeCriticalSection(&cs); -#endif - refcount = 1; - } - ~Impl() { DeleteCriticalSection(&cs); } - - void lock() { EnterCriticalSection(&cs); } - bool trylock() { return TryEnterCriticalSection(&cs) != 0; } - void unlock() { LeaveCriticalSection(&cs); } - - CRITICAL_SECTION cs; - int refcount; -}; - -#else - -struct Mutex::Impl -{ - Impl() - { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mt, &attr); - pthread_mutexattr_destroy(&attr); - - refcount = 1; - } - ~Impl() { pthread_mutex_destroy(&mt); } - - void lock() { pthread_mutex_lock(&mt); } - bool trylock() { return pthread_mutex_trylock(&mt) == 0; } - void unlock() { pthread_mutex_unlock(&mt); } - - pthread_mutex_t mt; - int refcount; -}; - -#endif - -Mutex::Mutex() -{ - impl = new Mutex::Impl; -} - -Mutex::~Mutex() -{ - if( CV_XADD(&impl->refcount, -1) == 1 ) - delete impl; - impl = 0; -} - -Mutex::Mutex(const Mutex& m) -{ - impl = m.impl; - CV_XADD(&impl->refcount, 1); -} - -Mutex& Mutex::operator = (const Mutex& m) -{ - if (this != &m) - { - CV_XADD(&m.impl->refcount, 1); - if( CV_XADD(&impl->refcount, -1) == 1 ) - delete impl; - impl = m.impl; - } - return *this; -} - -void Mutex::lock() { impl->lock(); } -void Mutex::unlock() { impl->unlock(); } -bool Mutex::trylock() { return impl->trylock(); } //////////////////////////////// thread-local storage ////////////////////////////////