From 89356ff16d1f4c8c88d8bf9e3223f429196ae607 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 14 Mar 2013 20:10:54 +0400 Subject: [PATCH] Move non-CV functionality from core.hpp to separate utility.hpp header --- apps/sft/include/sft/common.hpp | 1 + include/opencv/cv.h | 1 + modules/calib3d/src/precomp.hpp | 5 +- modules/calib3d/test/test_precomp.hpp | 2 +- .../contrib/src/detection_based_tracker.cpp | 1 + modules/contrib/src/precomp.hpp | 2 + modules/core/include/opencv2/core.hpp | 297 +----------- modules/core/include/opencv2/core/core_c.h | 12 - modules/core/include/opencv2/core/cvdef.h | 17 +- modules/core/include/opencv2/core/mat.hpp | 5 - .../core/include/opencv2/core/operations.hpp | 108 ----- modules/core/include/opencv2/core/utility.hpp | 459 ++++++++++++++++++ modules/core/src/precomp.hpp | 1 + modules/core/test/test_precomp.hpp | 2 +- modules/features2d/src/precomp.hpp | 2 + modules/flann/src/precomp.hpp | 1 + modules/flann/test/test_precomp.hpp | 1 - modules/highgui/src/precomp.hpp | 2 + modules/highgui/test/test_precomp.hpp | 2 +- modules/imgproc/src/precomp.hpp | 2 + modules/imgproc/test/test_precomp.hpp | 2 +- modules/java/generator/config/core.filelist | 1 + modules/java/generator/src/cpp/common.h | 2 + .../java/generator/src/cpp/core_manual.cpp | 2 + modules/legacy/src/precomp.hpp | 7 +- modules/legacy/test/test_precomp.hpp | 2 +- modules/ml/src/precomp.hpp | 1 + modules/ml/test/test_precomp.hpp | 4 +- modules/nonfree/src/precomp.hpp | 2 + modules/nonfree/test/test_precomp.hpp | 2 +- modules/objdetect/src/precomp.hpp | 2 + modules/ocl/perf/precomp.hpp | 4 +- modules/ocl/src/precomp.hpp | 1 + modules/ocl/test/precomp.hpp | 6 +- modules/photo/test/test_precomp.hpp | 2 +- modules/python/CMakeLists.txt | 1 + modules/python/src2/cv2.cpp | 1 + modules/ts/include/opencv2/ts.hpp | 17 +- modules/ts/src/precomp.hpp | 5 +- modules/ts/src/ts.cpp | 16 - modules/video/perf/perf_precomp.hpp | 2 +- modules/video/src/precomp.hpp | 5 +- modules/video/test/test_precomp.hpp | 2 +- samples/c/bgfg_codebook.cpp | 7 +- samples/c/find_obj_ferns.cpp | 12 +- samples/c/mser_sample.cpp | 7 +- samples/cpp/bgfg_gmg.cpp | 1 + samples/cpp/bgfg_segm.cpp | 7 +- samples/cpp/brief_match_test.cpp | 11 +- samples/cpp/build3dmodel.cpp | 11 +- samples/cpp/calibration.cpp | 9 +- samples/cpp/camshiftdemo.cpp | 5 +- samples/cpp/chamfer.cpp | 7 +- samples/cpp/connected_components.cpp | 5 +- samples/cpp/demhist.cpp | 5 +- .../cpp/detection_based_tracker_sample.cpp | 9 +- ...detector_descriptor_matcher_evaluation.cpp | 7 +- samples/cpp/dft.cpp | 7 +- samples/cpp/distrans.cpp | 5 +- samples/cpp/edge.cpp | 5 +- samples/cpp/facerec_demo.cpp | 7 +- samples/cpp/freak_demo.cpp | 11 +- samples/cpp/image_alignment.cpp | 8 +- samples/cpp/linemod.cpp | 9 +- samples/cpp/opencv_version.cpp | 2 +- samples/cpp/peopledetect.cpp | 1 + samples/cpp/select3dobj.cpp | 9 +- samples/cpp/simpleflow_demo.cpp | 5 +- samples/cpp/stereo_match.cpp | 1 + samples/cpp/stitching_detailed.cpp | 3 +- .../camera_calibration/camera_calibration.cpp | 9 +- .../how_to_scan_images/how_to_scan_images.cpp | 5 +- .../mat_mask_operations.cpp | 7 +- .../gpu-basics-similarity.cpp | 9 +- samples/cpp/tvl1_optical_flow.cpp | 5 +- samples/cpp/videostab.cpp | 1 + samples/cpp/watershed.cpp | 5 +- samples/gpu/bgfg_segm.cpp | 7 +- samples/gpu/brox_optical_flow.cpp | 8 +- samples/gpu/farneback_optical_flow.cpp | 9 +- samples/gpu/generalized_hough.cpp | 11 +- samples/gpu/hog.cpp | 5 +- samples/gpu/houghlines.cpp | 9 +- samples/gpu/optical_flow.cpp | 7 +- samples/gpu/performance/performance.h | 4 +- samples/gpu/pyrlk_optical_flow.cpp | 12 +- samples/gpu/softcascade.cpp | 1 + samples/gpu/stereo_match.cpp | 5 +- samples/ocl/hog.cpp | 5 +- samples/ocl/performance.cpp | 18 +- 90 files changed, 709 insertions(+), 621 deletions(-) create mode 100644 modules/core/include/opencv2/core/utility.hpp diff --git a/apps/sft/include/sft/common.hpp b/apps/sft/include/sft/common.hpp index 93439a48e..7e5c0ff26 100644 --- a/apps/sft/include/sft/common.hpp +++ b/apps/sft/include/sft/common.hpp @@ -44,6 +44,7 @@ #define __SFT_COMMON_HPP__ #include +#include #include namespace cv {using namespace softcascade;} diff --git a/include/opencv/cv.h b/include/opencv/cv.h index c878e6881..4b98ff3fb 100644 --- a/include/opencv/cv.h +++ b/include/opencv/cv.h @@ -62,6 +62,7 @@ #include "opencv2/core/core_c.h" #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" diff --git a/modules/calib3d/src/precomp.hpp b/modules/calib3d/src/precomp.hpp index 5951ea1fd..7a7140d59 100644 --- a/modules/calib3d/src/precomp.hpp +++ b/modules/calib3d/src/precomp.hpp @@ -49,8 +49,11 @@ #include "opencv2/calib3d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" -#include "opencv2/core/internal.hpp" #include "opencv2/features2d.hpp" + +#include "opencv2/core/utility.hpp" +#include "opencv2/core/internal.hpp" + #include #ifdef HAVE_TEGRA_OPTIMIZATION diff --git a/modules/calib3d/test/test_precomp.hpp b/modules/calib3d/test/test_precomp.hpp index fee6551f0..de30e8029 100644 --- a/modules/calib3d/test/test_precomp.hpp +++ b/modules/calib3d/test/test_precomp.hpp @@ -9,12 +9,12 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/calib3d.hpp" #include "opencv2/highgui.hpp" -#include namespace cvtest { diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp index 117a6e916..49d09d1bf 100644 --- a/modules/contrib/src/detection_based_tracker.cpp +++ b/modules/contrib/src/detection_based_tracker.cpp @@ -1,5 +1,6 @@ #if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID) #include "opencv2/contrib/detection_based_tracker.hpp" +#include "opencv2/core/utility.hpp" #include diff --git a/modules/contrib/src/precomp.hpp b/modules/contrib/src/precomp.hpp index 7819148dd..59c76cf16 100644 --- a/modules/contrib/src/precomp.hpp +++ b/modules/contrib/src/precomp.hpp @@ -52,6 +52,8 @@ #include "opencv2/objdetect.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" namespace cv diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 5e204e841..337ddb059 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -101,13 +101,6 @@ template class CV_EXPORTS MatIterator_; template class CV_EXPORTS MatConstIterator_; template class CV_EXPORTS MatCommaInitializer_; -template class CV_EXPORTS AutoBuffer; - -CV_EXPORTS std::string format( const char* fmt, ... ); -CV_EXPORTS std::string tempfile( const char* suffix CV_DEFAULT(0)); - -CV_EXPORTS void glob(std::string pattern, std::vector& result, bool recursive = false); - // matrix decomposition types enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 }; enum { NORM_INF=1, NORM_L1=2, NORM_L2=4, NORM_L2SQR=5, NORM_HAMMING=6, NORM_HAMMING2=7, NORM_TYPE_MASK=7, NORM_RELATIVE=8, NORM_MINMAX=32 }; @@ -162,34 +155,6 @@ public: */ CV_EXPORTS void error( const Exception& exc ); -//! Sets/resets the break-on-error mode. - -/*! - When the break-on-error mode is set, the default error handler - issues a hardware exception, which can make debugging more convenient. - - \return the previous state - */ -CV_EXPORTS bool setBreakOnError(bool flag); - -typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, - const char* err_msg, const char* file_name, - int line, void* userdata ); - -//! Sets the new error handler and the optional user data. - -/*! - The function sets the new error handler, called from cv::error(). - - \param errCallback the new error handler. If NULL, the default error handler is used. - \param userdata the optional user data pointer, passed to the callback. - \param prevUserdata the optional output parameter where the previous user data pointer is stored - - \return the previous error handler -*/ -CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, - void* userdata=0, void** prevUserdata=0); - #ifdef __GNUC__ #define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, __func__, __FILE__, __LINE__) ) #define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, __func__, __FILE__, __LINE__) ) @@ -206,70 +171,6 @@ CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, #define CV_DbgAssert(expr) #endif -CV_EXPORTS void setNumThreads(int nthreads); -CV_EXPORTS int getNumThreads(); -CV_EXPORTS int getThreadNum(); - -CV_EXPORTS_W const std::string& getBuildInformation(); - -//! Returns the number of ticks. - -/*! - The function returns the number of ticks since the certain event (e.g. when the machine was turned on). - It can be used to initialize cv::RNG or to measure a function execution time by reading the tick count - before and after the function call. The granularity of ticks depends on the hardware and OS used. Use - cv::getTickFrequency() to convert ticks to seconds. -*/ -CV_EXPORTS_W int64 getTickCount(); - -/*! - Returns the number of ticks per seconds. - - The function returns the number of ticks (as returned by cv::getTickCount()) per second. - The following code computes the execution time in milliseconds: - - \code - double exec_time = (double)getTickCount(); - // do something ... - exec_time = ((double)getTickCount() - exec_time)*1000./getTickFrequency(); - \endcode -*/ -CV_EXPORTS_W double getTickFrequency(); - -/*! - Returns the number of CPU ticks. - - On platforms where the feature is available, the function returns the number of CPU ticks - since the certain event (normally, the system power-on moment). Using this function - one can accurately measure the execution time of very small code fragments, - for which cv::getTickCount() granularity is not enough. -*/ -CV_EXPORTS_W int64 getCPUTickCount(); - -/*! - Returns SSE etc. support status - - The function returns true if certain hardware features are available. - Currently, the following features are recognized: - - CV_CPU_MMX - MMX - - CV_CPU_SSE - SSE - - CV_CPU_SSE2 - SSE 2 - - CV_CPU_SSE3 - SSE 3 - - CV_CPU_SSSE3 - SSSE 3 - - CV_CPU_SSE4_1 - SSE 4.1 - - CV_CPU_SSE4_2 - SSE 4.2 - - CV_CPU_POPCNT - POPCOUNT - - CV_CPU_AVX - AVX - - \note {Note that the function output is not static. Once you called cv::useOptimized(false), - most of the hardware acceleration is disabled and thus the function will returns false, - until you call cv::useOptimized(true)} -*/ -CV_EXPORTS_W bool checkHardwareSupport(int feature); - -//! returns the number of CPUs (including hyper-threading) -CV_EXPORTS_W int getNumberOfCPUs(); - /*! Allocates memory buffer @@ -300,45 +201,6 @@ template static inline void deallocate(_Tp* ptr, size_t) delete[] ptr; } -/*! - Aligns pointer by the certain number of bytes - - This small inline function aligns the pointer by the certian number of bytes by shifting - it forward by 0 or a positive offset. -*/ -template static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)) -{ - return (_Tp*)(((size_t)ptr + n-1) & -n); -} - -/*! - Aligns buffer size by the certain number of bytes - - This small inline function aligns a buffer size by the certian number of bytes by enlarging it. -*/ -static inline size_t alignSize(size_t sz, int n) -{ - return (sz + n-1) & -n; -} - -/*! - Turns on/off available optimization - - The function turns on or off the optimized code in OpenCV. Some optimization can not be enabled - or disabled, but, for example, most of SSE code in OpenCV can be temporarily turned on or off this way. - - \note{Since optimization may imply using special data structures, it may be unsafe - to call this function anywhere in the code. Instead, call it somewhere at the top level.} -*/ -CV_EXPORTS_W void setUseOptimized(bool onoff); - -/*! - Returns the current optimization status - - The function returns the current optimization status, which is controlled by cv::setUseOptimized(). -*/ -CV_EXPORTS_W bool useOptimized(); - /*! The STL-compilant memory Allocator based on cv::fastMalloc() and cv::fastFree() */ @@ -1421,8 +1283,6 @@ CV_EXPORTS OutputArray noArray(); enum { MAGIC_MASK=0xFFFF0000, TYPE_MASK=0x00000FFF, DEPTH_MASK=7 }; -static inline size_t getElemSize(int type) { return CV_ELEM_SIZE(type); } - /*! Custom array allocator @@ -2084,10 +1944,6 @@ CV_EXPORTS BinaryFunc getCopyMaskFunc(size_t esz); //! swaps two matrices CV_EXPORTS void swap(Mat& a, Mat& b); -//! converts array (CvMat or IplImage) to cv::Mat -CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, - bool allowND=true, int coiMode=0, - AutoBuffer* buf=0); //! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); //! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage @@ -3088,73 +2944,6 @@ public: Vec<_Tp, m> operator *() const; }; -/*! - Automatically Allocated Buffer Class - - The class is used for temporary buffers in functions and methods. - If a temporary buffer is usually small (a few K's of memory), - but its size depends on the parameters, it makes sense to create a small - fixed-size array on stack and use it if it's large enough. If the required buffer size - is larger than the fixed size, another buffer of sufficient size is allocated dynamically - and released after the processing. Therefore, in typical cases, when the buffer size is small, - there is no overhead associated with malloc()/free(). - At the same time, there is no limit on the size of processed data. - - This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and - the number of stack-allocated elements. Here is how the class is used: - - \code - void my_func(const cv::Mat& m) - { - cv::AutoBuffer buf; // create automatic buffer containing 1000 floats - - buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, - // otherwise the buffer of "m.rows" floats will be allocated - // dynamically and deallocated in cv::AutoBuffer destructor - ... - } - \endcode -*/ -template class CV_EXPORTS AutoBuffer -{ -public: - typedef _Tp value_type; - - //! the default contructor - AutoBuffer(); - //! constructor taking the real buffer size - AutoBuffer(size_t _size); - - //! the copy constructor - AutoBuffer(const AutoBuffer<_Tp, fixed_size>& buf); - //! the assignment operator - AutoBuffer<_Tp, fixed_size>& operator = (const AutoBuffer<_Tp, fixed_size>& buf); - - //! destructor. calls deallocate() - ~AutoBuffer(); - - //! allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used - void allocate(size_t _size); - //! deallocates the buffer if it was dynamically allocated - void deallocate(); - //! resizes the buffer and preserves the content - void resize(size_t _size); - //! returns the current buffer size - size_t size() const; - //! returns pointer to the real buffer, stack-allocated or head-allocated - operator _Tp* (); - //! returns read-only pointer to the real buffer, stack-allocated or head-allocated - operator const _Tp* () const; - -protected: - //! pointer to the real buffer, can point to buf if the buffer is small enough - _Tp* ptr; - //! size of the real buffer - size_t sz; - //! pre-allocated buffer - _Tp buf[fixed_size]; -}; - /////////////////////////// multi-dimensional dense matrix ////////////////////////// /*! @@ -4628,91 +4417,7 @@ template<> struct ParamType enum { type = Param::UCHAR }; }; -// The CommandLineParser class is designed for command line arguments parsing - -class CV_EXPORTS CommandLineParser -{ - public: - CommandLineParser(int argc, const char* const argv[], const std::string& keys); - CommandLineParser(const CommandLineParser& parser); - CommandLineParser& operator = (const CommandLineParser& parser); - - std::string getPathToApplication() const; - - template - T get(const std::string& name, bool space_delete = true) const - { - T val = T(); - getByName(name, space_delete, ParamType::type, (void*)&val); - return val; - } - - template - T get(int index, bool space_delete = true) const - { - T val = T(); - getByIndex(index, space_delete, ParamType::type, (void*)&val); - return val; - } - - bool has(const std::string& name) const; - - bool check() const; - - void about(const std::string& message); - - void printMessage() const; - void printErrors() const; - -protected: - void getByName(const std::string& name, bool space_delete, int type, void* dst) const; - void getByIndex(int index, bool space_delete, int type, void* dst) const; - - struct Impl; - Impl* impl; -}; - -/////////////////////////////// Parallel Primitives ////////////////////////////////// - -// a base body class -class CV_EXPORTS ParallelLoopBody -{ -public: - virtual ~ParallelLoopBody(); - virtual void operator() (const Range& range) const = 0; -}; - -CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.); - -/////////////////////////// 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; -}; - -} +} //namespace cv #endif // __cplusplus diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index df763ab9a..4c4b39046 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1696,18 +1696,6 @@ CVAPI(double) cvGetTickFrequency( void ); /*********************************** CPU capabilities ***********************************/ -#define CV_CPU_NONE 0 -#define CV_CPU_MMX 1 -#define CV_CPU_SSE 2 -#define CV_CPU_SSE2 3 -#define CV_CPU_SSE3 4 -#define CV_CPU_SSSE3 5 -#define CV_CPU_SSE4_1 6 -#define CV_CPU_SSE4_2 7 -#define CV_CPU_POPCNT 8 -#define CV_CPU_AVX 10 -#define CV_HARDWARE_MAX_FEATURE 255 - CVAPI(int) cvCheckHardwareSupport(int feature); /*********************************** Multi-Threading ************************************/ diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 06b2b5f25..903332e6d 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -97,7 +97,20 @@ # endif #endif -/* intrinsics support */ +/* CPU features and intrinsics support */ +#define CV_CPU_NONE 0 +#define CV_CPU_MMX 1 +#define CV_CPU_SSE 2 +#define CV_CPU_SSE2 3 +#define CV_CPU_SSE3 4 +#define CV_CPU_SSSE3 5 +#define CV_CPU_SSE4_1 6 +#define CV_CPU_SSE4_2 7 +#define CV_CPU_POPCNT 8 +#define CV_CPU_AVX 10 +#define CV_CPU_NEON 11 +#define CV_HARDWARE_MAX_FEATURE 255 + #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) # include "emmintrin.h" # define CV_SSE 1 @@ -421,4 +434,4 @@ CV_INLINE int cvIsInf( double value ) CV_INLINE CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } #endif -#endif // __OPENCV_CORE_CVDEF_H__ \ No newline at end of file +#endif // __OPENCV_CORE_CVDEF_H__ diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 8e7890568..6b0c47943 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -748,11 +748,6 @@ inline Mat::MStep& Mat::MStep::operator = (size_t s) return *this; } -static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) -{ - return cvarrToMat(arr, copyData, true, coiMode); -} - ///////////////////////////////////////////// SVD ////////////////////////////////////////////////////// inline SVD::SVD() {} diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index c259b892b..dd09f41aa 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -2482,114 +2482,6 @@ inline Point LineIterator::pos() const return p; } -/////////////////////////////// AutoBuffer //////////////////////////////////////// - -template inline -AutoBuffer<_Tp, fixed_size>::AutoBuffer() -{ - ptr = buf; - sz = fixed_size; -} - -template inline -AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size) -{ - ptr = buf; - sz = fixed_size; - allocate(_size); -} - -template inline -AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf ) -{ - ptr = buf; - sz = fixed_size; - allocate(abuf.size); - for( size_t i = 0; i < sz; i++ ) - ptr[i] = abuf.ptr[i]; -} - -template inline AutoBuffer<_Tp, fixed_size>& -AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf) -{ - if( this != &abuf ) - { - deallocate(); - allocate(abuf.size); - for( size_t i = 0; i < sz; i++ ) - ptr[i] = abuf.ptr[i]; - } - return *this; -} - -template inline -AutoBuffer<_Tp, fixed_size>::~AutoBuffer() -{ deallocate(); } - -template inline void -AutoBuffer<_Tp, fixed_size>::allocate(size_t _size) -{ - if(_size <= sz) - { - sz = _size; - return; - } - deallocate(); - if(_size > fixed_size) - { - ptr = new _Tp[_size]; - sz = _size; - } -} - -template inline void -AutoBuffer<_Tp, fixed_size>::deallocate() -{ - if( ptr != buf ) - { - delete[] ptr; - ptr = buf; - sz = fixed_size; - } -} - -template inline void -AutoBuffer<_Tp, fixed_size>::resize(size_t _size) -{ - if(_size <= sz) - { - sz = _size; - return; - } - size_t i, prevsize = sz, minsize = MIN(prevsize, _size); - _Tp* prevptr = ptr; - - ptr = _size > fixed_size ? new _Tp[_size] : buf; - sz = _size; - - if( ptr != prevptr ) - for( i = 0; i < minsize; i++ ) - ptr[i] = prevptr[i]; - for( i = prevsize; i < _size; i++ ) - ptr[i] = _Tp(); - - if( prevptr != buf ) - delete[] prevptr; -} - -template inline size_t -AutoBuffer<_Tp, fixed_size>::size() const -{ return sz; } - -template inline -AutoBuffer<_Tp, fixed_size>::operator _Tp* () -{ return ptr; } - -template inline -AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const -{ return ptr; } - - /////////////////////////////////// Ptr //////////////////////////////////////// template inline Ptr<_Tp>::Ptr() : obj(0), refcount(0) {} diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp new file mode 100644 index 000000000..6a08c37af --- /dev/null +++ b/modules/core/include/opencv2/core/utility.hpp @@ -0,0 +1,459 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __OPENCV_CORE_UTILITY_H__ +#define __OPENCV_CORE_UTILITY_H__ + +#include "opencv2/core.hpp" + +namespace cv +{ + +/*! + Automatically Allocated Buffer Class + + The class is used for temporary buffers in functions and methods. + If a temporary buffer is usually small (a few K's of memory), + but its size depends on the parameters, it makes sense to create a small + fixed-size array on stack and use it if it's large enough. If the required buffer size + is larger than the fixed size, another buffer of sufficient size is allocated dynamically + and released after the processing. Therefore, in typical cases, when the buffer size is small, + there is no overhead associated with malloc()/free(). + At the same time, there is no limit on the size of processed data. + + This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and + the number of stack-allocated elements. Here is how the class is used: + + \code + void my_func(const cv::Mat& m) + { + cv::AutoBuffer buf; // create automatic buffer containing 1000 floats + + buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, + // otherwise the buffer of "m.rows" floats will be allocated + // dynamically and deallocated in cv::AutoBuffer destructor + ... + } + \endcode +*/ +template class CV_EXPORTS AutoBuffer +{ +public: + typedef _Tp value_type; + + //! the default contructor + AutoBuffer(); + //! constructor taking the real buffer size + AutoBuffer(size_t _size); + + //! the copy constructor + AutoBuffer(const AutoBuffer<_Tp, fixed_size>& buf); + //! the assignment operator + AutoBuffer<_Tp, fixed_size>& operator = (const AutoBuffer<_Tp, fixed_size>& buf); + + //! destructor. calls deallocate() + ~AutoBuffer(); + + //! allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used + void allocate(size_t _size); + //! deallocates the buffer if it was dynamically allocated + void deallocate(); + //! resizes the buffer and preserves the content + void resize(size_t _size); + //! returns the current buffer size + size_t size() const; + //! returns pointer to the real buffer, stack-allocated or head-allocated + operator _Tp* (); + //! returns read-only pointer to the real buffer, stack-allocated or head-allocated + operator const _Tp* () const; + +protected: + //! pointer to the real buffer, can point to buf if the buffer is small enough + _Tp* ptr; + //! size of the real buffer + size_t sz; + //! pre-allocated buffer + _Tp buf[fixed_size]; +}; + +//! Sets/resets the break-on-error mode. + +/*! + When the break-on-error mode is set, the default error handler + issues a hardware exception, which can make debugging more convenient. + + \return the previous state + */ +CV_EXPORTS bool setBreakOnError(bool flag); + +typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, + int line, void* userdata ); + +//! Sets the new error handler and the optional user data. + +/*! + The function sets the new error handler, called from cv::error(). + + \param errCallback the new error handler. If NULL, the default error handler is used. + \param userdata the optional user data pointer, passed to the callback. + \param prevUserdata the optional output parameter where the previous user data pointer is stored + + \return the previous error handler +*/ +CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0); + +CV_EXPORTS std::string format( const char* fmt, ... ); +CV_EXPORTS std::string tempfile( const char* suffix CV_DEFAULT(0)); +CV_EXPORTS void glob(std::string pattern, std::vector& result, bool recursive = false); +CV_EXPORTS void setNumThreads(int nthreads); +CV_EXPORTS int getNumThreads(); +CV_EXPORTS int getThreadNum(); + +CV_EXPORTS_W const std::string& getBuildInformation(); + +//! Returns the number of ticks. + +/*! + The function returns the number of ticks since the certain event (e.g. when the machine was turned on). + It can be used to initialize cv::RNG or to measure a function execution time by reading the tick count + before and after the function call. The granularity of ticks depends on the hardware and OS used. Use + cv::getTickFrequency() to convert ticks to seconds. +*/ +CV_EXPORTS_W int64 getTickCount(); + +/*! + Returns the number of ticks per seconds. + + The function returns the number of ticks (as returned by cv::getTickCount()) per second. + The following code computes the execution time in milliseconds: + + \code + double exec_time = (double)getTickCount(); + // do something ... + exec_time = ((double)getTickCount() - exec_time)*1000./getTickFrequency(); + \endcode +*/ +CV_EXPORTS_W double getTickFrequency(); + +/*! + Returns the number of CPU ticks. + + On platforms where the feature is available, the function returns the number of CPU ticks + since the certain event (normally, the system power-on moment). Using this function + one can accurately measure the execution time of very small code fragments, + for which cv::getTickCount() granularity is not enough. +*/ +CV_EXPORTS_W int64 getCPUTickCount(); + +/*! + Returns SSE etc. support status + + The function returns true if certain hardware features are available. + Currently, the following features are recognized: + - CV_CPU_MMX - MMX + - CV_CPU_SSE - SSE + - CV_CPU_SSE2 - SSE 2 + - CV_CPU_SSE3 - SSE 3 + - CV_CPU_SSSE3 - SSSE 3 + - CV_CPU_SSE4_1 - SSE 4.1 + - CV_CPU_SSE4_2 - SSE 4.2 + - CV_CPU_POPCNT - POPCOUNT + - CV_CPU_AVX - AVX + + \note {Note that the function output is not static. Once you called cv::useOptimized(false), + most of the hardware acceleration is disabled and thus the function will returns false, + until you call cv::useOptimized(true)} +*/ +CV_EXPORTS_W bool checkHardwareSupport(int feature); + +//! returns the number of CPUs (including hyper-threading) +CV_EXPORTS_W int getNumberOfCPUs(); + + +/*! + Aligns pointer by the certain number of bytes + + This small inline function aligns the pointer by the certian number of bytes by shifting + it forward by 0 or a positive offset. +*/ +template static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)) +{ + return (_Tp*)(((size_t)ptr + n-1) & -n); +} + +/*! + Aligns buffer size by the certain number of bytes + + This small inline function aligns a buffer size by the certian number of bytes by enlarging it. +*/ +static inline size_t alignSize(size_t sz, int n) +{ + return (sz + n-1) & -n; +} + +/*! + Turns on/off available optimization + + The function turns on or off the optimized code in OpenCV. Some optimization can not be enabled + or disabled, but, for example, most of SSE code in OpenCV can be temporarily turned on or off this way. + + \note{Since optimization may imply using special data structures, it may be unsafe + to call this function anywhere in the code. Instead, call it somewhere at the top level.} +*/ +CV_EXPORTS_W void setUseOptimized(bool onoff); + +/*! + Returns the current optimization status + + The function returns the current optimization status, which is controlled by cv::setUseOptimized(). +*/ +CV_EXPORTS_W bool useOptimized(); + +static inline size_t getElemSize(int type) { return CV_ELEM_SIZE(type); } + +/////////////////////////////// Parallel Primitives ////////////////////////////////// + +// a base body class +class CV_EXPORTS ParallelLoopBody +{ +public: + virtual ~ParallelLoopBody(); + virtual void operator() (const Range& range) const = 0; +}; + +CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.); + +/////////////////////////// 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; +}; + +// The CommandLineParser class is designed for command line arguments parsing + +class CV_EXPORTS CommandLineParser +{ + public: + CommandLineParser(int argc, const char* const argv[], const std::string& keys); + CommandLineParser(const CommandLineParser& parser); + CommandLineParser& operator = (const CommandLineParser& parser); + + std::string getPathToApplication() const; + + template + T get(const std::string& name, bool space_delete = true) const + { + T val = T(); + getByName(name, space_delete, ParamType::type, (void*)&val); + return val; + } + + template + T get(int index, bool space_delete = true) const + { + T val = T(); + getByIndex(index, space_delete, ParamType::type, (void*)&val); + return val; + } + + bool has(const std::string& name) const; + + bool check() const; + + void about(const std::string& message); + + void printMessage() const; + void printErrors() const; + +protected: + void getByName(const std::string& name, bool space_delete, int type, void* dst) const; + void getByIndex(int index, bool space_delete, int type, void* dst) const; + + struct Impl; + Impl* impl; +}; + +/////////////////////////////// AutoBuffer implementation //////////////////////////////////////// + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer() +{ + ptr = buf; + sz = fixed_size; +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size) +{ + ptr = buf; + sz = fixed_size; + allocate(_size); +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf ) +{ + ptr = buf; + sz = fixed_size; + allocate(abuf.size); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; +} + +template inline AutoBuffer<_Tp, fixed_size>& +AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf) +{ + if( this != &abuf ) + { + deallocate(); + allocate(abuf.size); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; + } + return *this; +} + +template inline +AutoBuffer<_Tp, fixed_size>::~AutoBuffer() +{ deallocate(); } + +template inline void +AutoBuffer<_Tp, fixed_size>::allocate(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + deallocate(); + if(_size > fixed_size) + { + ptr = new _Tp[_size]; + sz = _size; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::deallocate() +{ + if( ptr != buf ) + { + delete[] ptr; + ptr = buf; + sz = fixed_size; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::resize(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + size_t i, prevsize = sz, minsize = MIN(prevsize, _size); + _Tp* prevptr = ptr; + + ptr = _size > fixed_size ? new _Tp[_size] : buf; + sz = _size; + + if( ptr != prevptr ) + for( i = 0; i < minsize; i++ ) + ptr[i] = prevptr[i]; + for( i = prevsize; i < _size; i++ ) + ptr[i] = _Tp(); + + if( prevptr != buf ) + delete[] prevptr; +} + +template inline size_t +AutoBuffer<_Tp, fixed_size>::size() const +{ return sz; } + +template inline +AutoBuffer<_Tp, fixed_size>::operator _Tp* () +{ return ptr; } + +template inline +AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const +{ return ptr; } + +// TODO: move them to core_c.h +//! converts array (CvMat or IplImage) to cv::Mat +CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, + bool allowND=true, int coiMode=0, + AutoBuffer* buf=0); + +static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) +{ + return cvarrToMat(arr, copyData, true, coiMode); +} + +} //namespace cv + +#endif //__OPENCV_CORE_UTILITY_H__ diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 30ce3d17b..1fa2ae343 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -48,6 +48,7 @@ #endif #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "opencv2/core/core_c.h" #include "opencv2/core/internal.hpp" diff --git a/modules/core/test/test_precomp.hpp b/modules/core/test/test_precomp.hpp index 6c0f493d4..948293a46 100644 --- a/modules/core/test/test_precomp.hpp +++ b/modules/core/test/test_precomp.hpp @@ -9,8 +9,8 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/core/core_c.h" -#include #endif diff --git a/modules/features2d/src/precomp.hpp b/modules/features2d/src/precomp.hpp index 62936b48f..bcaa9b26e 100644 --- a/modules/features2d/src/precomp.hpp +++ b/modules/features2d/src/precomp.hpp @@ -50,6 +50,8 @@ #include "opencv2/features2d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include diff --git a/modules/flann/src/precomp.hpp b/modules/flann/src/precomp.hpp index 0d2647932..7f924694c 100644 --- a/modules/flann/src/precomp.hpp +++ b/modules/flann/src/precomp.hpp @@ -9,6 +9,7 @@ # include "cvconfig.h" #endif #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include "opencv2/flann/miniflann.hpp" diff --git a/modules/flann/test/test_precomp.hpp b/modules/flann/test/test_precomp.hpp index b5cd17461..cbee8957f 100644 --- a/modules/flann/test/test_precomp.hpp +++ b/modules/flann/test/test_precomp.hpp @@ -10,7 +10,6 @@ #define __OPENCV_TEST_PRECOMP_HPP__ #include "opencv2/ts.hpp" -#include "opencv2/core.hpp" #include "opencv2/flann.hpp" #include diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index d83401cd6..26aae1d2d 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -47,6 +47,8 @@ #include "opencv2/highgui.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/imgproc/imgproc_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index ba4241e25..4d36cdd64 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -13,10 +13,10 @@ # include "cvconfig.h" #endif +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" -#include #if defined(HAVE_VIDEOINPUT) || \ defined(HAVE_TYZX) || \ diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp index c3e693c31..cde17ae05 100644 --- a/modules/imgproc/src/precomp.hpp +++ b/modules/imgproc/src/precomp.hpp @@ -49,6 +49,8 @@ #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include #include diff --git a/modules/imgproc/test/test_precomp.hpp b/modules/imgproc/test/test_precomp.hpp index 9e937b941..43866800a 100644 --- a/modules/imgproc/test/test_precomp.hpp +++ b/modules/imgproc/test/test_precomp.hpp @@ -9,11 +9,11 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/highgui.hpp" #include "opencv2/highgui/highgui_c.h" -#include #endif diff --git a/modules/java/generator/config/core.filelist b/modules/java/generator/config/core.filelist index 96c377786..d0905a3c2 100644 --- a/modules/java/generator/config/core.filelist +++ b/modules/java/generator/config/core.filelist @@ -1,2 +1,3 @@ include/opencv2/core.hpp +include/opencv2/core/utility.hpp ../java/generator/src/cpp/core_manual.hpp diff --git a/modules/java/generator/src/cpp/common.h b/modules/java/generator/src/cpp/common.h index b67f633f7..db343823f 100644 --- a/modules/java/generator/src/cpp/common.h +++ b/modules/java/generator/src/cpp/common.h @@ -20,6 +20,8 @@ # define LOGD(...) #endif +#include "opencv2/core/utility.hpp" + #include "converters.h" #include "core_manual.hpp" diff --git a/modules/java/generator/src/cpp/core_manual.cpp b/modules/java/generator/src/cpp/core_manual.cpp index d7ba5b994..8a45528fc 100644 --- a/modules/java/generator/src/cpp/core_manual.cpp +++ b/modules/java/generator/src/cpp/core_manual.cpp @@ -1,6 +1,8 @@ #define LOG_TAG "org.opencv.core.Core" #include "common.h" +#include "opencv2/core/utility.hpp" + static int quietCallback( int, const char*, const char*, const char*, int, void* ) { return 0; diff --git a/modules/legacy/src/precomp.hpp b/modules/legacy/src/precomp.hpp index 6e40e3ffd..91ab6e3de 100644 --- a/modules/legacy/src/precomp.hpp +++ b/modules/legacy/src/precomp.hpp @@ -47,15 +47,14 @@ #include "opencv2/legacy.hpp" -#include "opencv2/core/internal.hpp" #include "opencv2/video.hpp" - #include "opencv2/legacy/blobtrack.hpp" #include "opencv2/legacy/compat.hpp" -#include "_matrix.h" +#include "opencv2/core/utility.hpp" +#include "opencv2/core/internal.hpp" -typedef unsigned short ushort; +#include "_matrix.h" CV_INLINE bool operator == (CvSize size1, CvSize size2 ); CV_INLINE bool operator == (CvSize size1, CvSize size2 ) diff --git a/modules/legacy/test/test_precomp.hpp b/modules/legacy/test/test_precomp.hpp index ccfb359fb..52b92fb6c 100644 --- a/modules/legacy/test/test_precomp.hpp +++ b/modules/legacy/test/test_precomp.hpp @@ -9,12 +9,12 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/highgui.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/legacy.hpp" -#include #endif diff --git a/modules/ml/src/precomp.hpp b/modules/ml/src/precomp.hpp index 112e07791..c18024465 100644 --- a/modules/ml/src/precomp.hpp +++ b/modules/ml/src/precomp.hpp @@ -47,6 +47,7 @@ #include "opencv2/ml.hpp" #include "opencv2/core/core_c.h" +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include diff --git a/modules/ml/test/test_precomp.hpp b/modules/ml/test/test_precomp.hpp index f311d4878..e68e5513b 100644 --- a/modules/ml/test/test_precomp.hpp +++ b/modules/ml/test/test_precomp.hpp @@ -9,11 +9,11 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include +#include #include "opencv2/ts.hpp" #include "opencv2/ml.hpp" #include "opencv2/core/core_c.h" -#include -#include #define CV_NBAYES "nbayes" #define CV_KNEAREST "knearest" diff --git a/modules/nonfree/src/precomp.hpp b/modules/nonfree/src/precomp.hpp index ea0aa6bd4..f4494d442 100644 --- a/modules/nonfree/src/precomp.hpp +++ b/modules/nonfree/src/precomp.hpp @@ -49,6 +49,8 @@ #include "opencv2/nonfree.hpp" #include "opencv2/imgproc.hpp" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #endif diff --git a/modules/nonfree/test/test_precomp.hpp b/modules/nonfree/test/test_precomp.hpp index daa79c90d..4a14b31fb 100644 --- a/modules/nonfree/test/test_precomp.hpp +++ b/modules/nonfree/test/test_precomp.hpp @@ -9,10 +9,10 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/highgui.hpp" #include "opencv2/nonfree.hpp" -#include #endif diff --git a/modules/objdetect/src/precomp.hpp b/modules/objdetect/src/precomp.hpp index 2b237a156..be3547c75 100644 --- a/modules/objdetect/src/precomp.hpp +++ b/modules/objdetect/src/precomp.hpp @@ -51,6 +51,8 @@ #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/core_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include "opencv2/opencv_modules.hpp" diff --git a/modules/ocl/perf/precomp.hpp b/modules/ocl/perf/precomp.hpp index ac7bd8be5..d8b4931ff 100644 --- a/modules/ocl/perf/precomp.hpp +++ b/modules/ocl/perf/precomp.hpp @@ -62,14 +62,12 @@ #include #include #include "cvconfig.h" -#include "opencv2/core.hpp" #include "opencv2/highgui.hpp" -//#include "opencv2/calib3d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" #include "opencv2/ts.hpp" -#include "opencv2/ts/ts_perf.hpp" #include "opencv2/ocl.hpp" +//#include "opencv2/calib3d.hpp" //#include "opencv2/nonfree.hpp" #include "utility.hpp" diff --git a/modules/ocl/src/precomp.hpp b/modules/ocl/src/precomp.hpp index 5cbc5364f..873e11b80 100644 --- a/modules/ocl/src/precomp.hpp +++ b/modules/ocl/src/precomp.hpp @@ -69,6 +69,7 @@ #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/core_c.h" +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" //#include "opencv2/highgui.hpp" diff --git a/modules/ocl/test/precomp.hpp b/modules/ocl/test/precomp.hpp index 25c95eb77..755a2d2bc 100644 --- a/modules/ocl/test/precomp.hpp +++ b/modules/ocl/test/precomp.hpp @@ -62,14 +62,12 @@ #include #include #include "cvconfig.h" -#include "opencv2/core.hpp" +#include "opencv2/ts.hpp" #include "opencv2/highgui.hpp" -//#include "opencv2/calib3d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" -#include "opencv2/ts.hpp" -#include "opencv2/ts/ts_perf.hpp" #include "opencv2/ocl.hpp" +//#include "opencv2/calib3d.hpp" //#include "opencv2/nonfree.hpp" #include "utility.hpp" diff --git a/modules/photo/test/test_precomp.hpp b/modules/photo/test/test_precomp.hpp index 278abb496..5b22a1c75 100644 --- a/modules/photo/test/test_precomp.hpp +++ b/modules/photo/test/test_precomp.hpp @@ -9,9 +9,9 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/photo.hpp" #include "opencv2/highgui.hpp" -#include #endif diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index d39e91921..5a42a7b62 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -24,6 +24,7 @@ ocv_module_include_directories( set(opencv_hdrs "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp" "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp" "${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp" "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/background_segm.hpp" diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index bbdd5abbe..06c0f3515 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -9,6 +9,7 @@ #include "numpy/ndarrayobject.h" #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "opencv2/contrib.hpp" #include "opencv2/flann/miniflann.hpp" #include "opencv2/imgproc.hpp" diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 61e75be38..e2735da3e 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -36,6 +36,7 @@ #endif #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" namespace cvtest { @@ -478,26 +479,10 @@ protected: virtual int run_test_case( int expected_code, const string& descr ); virtual void run_func(void) = 0; int test_case_idx; - int progress; - double t, freq; template int run_test_case( int expected_code, const string& _descr, F f) { - double new_t = (double)cv::getTickCount(), dt; - if( test_case_idx < 0 ) - { - test_case_idx = 0; - progress = 0; - dt = 0; - } - else - { - dt = (new_t - t)/(freq*1000); - t = new_t; - } - progress = update_progress(progress, test_case_idx, 0, dt); - int errcount = 0; bool thrown = false; const char* descr = _descr.c_str() ? _descr.c_str() : ""; diff --git a/modules/ts/src/precomp.hpp b/modules/ts/src/precomp.hpp index 0bc076376..a4306d2d8 100644 --- a/modules/ts/src/precomp.hpp +++ b/modules/ts/src/precomp.hpp @@ -1,6 +1,9 @@ -#include "opencv2/core/core_c.h" #include "opencv2/ts.hpp" +#include "opencv2/core/core_c.h" +#include "opencv2/core/utility.hpp" + + #ifdef GTEST_LINKED_AS_SHARED_LIBRARY #error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined #endif diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp index 7ce37752d..65a9727e7 100644 --- a/modules/ts/src/ts.cpp +++ b/modules/ts/src/ts.cpp @@ -321,9 +321,7 @@ int BaseTest::update_progress( int progress, int test_case_idx, int count, doubl BadArgTest::BadArgTest() { - progress = -1; test_case_idx = -1; - freq = cv::getTickFrequency(); // oldErrorCbk = 0; // oldErrorCbkData = 0; } @@ -334,20 +332,6 @@ BadArgTest::~BadArgTest(void) int BadArgTest::run_test_case( int expected_code, const string& _descr ) { - double new_t = (double)cv::getTickCount(), dt; - if( test_case_idx < 0 ) - { - test_case_idx = 0; - progress = 0; - dt = 0; - } - else - { - dt = (new_t - t)/(freq*1000); - t = new_t; - } - progress = update_progress(progress, test_case_idx, 0, dt); - int errcount = 0; bool thrown = false; const char* descr = _descr.c_str() ? _descr.c_str() : ""; diff --git a/modules/video/perf/perf_precomp.hpp b/modules/video/perf/perf_precomp.hpp index 94f8d9223..0ea88f0da 100644 --- a/modules/video/perf/perf_precomp.hpp +++ b/modules/video/perf/perf_precomp.hpp @@ -9,10 +9,10 @@ #ifndef __OPENCV_VIDEO_PRECOMP_HPP__ #define __OPENCV_VIDEO_PRECOMP_HPP__ +#include "opencv2/ts.hpp" #include #include #include -#include "opencv2/ts.hpp" #ifdef GTEST_CREATE_SHARED_LIBRARY #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined diff --git a/modules/video/src/precomp.hpp b/modules/video/src/precomp.hpp index 58fc55086..0b9e58283 100644 --- a/modules/video/src/precomp.hpp +++ b/modules/video/src/precomp.hpp @@ -47,9 +47,10 @@ #include "cvconfig.h" #endif -#include "opencv2/video/tracking.hpp" -#include "opencv2/video/background_segm.hpp" +#include "opencv2/video.hpp" #include "opencv2/imgproc/imgproc_c.h" + +#include "opencv2/core/utility.hpp" #include "opencv2/core/internal.hpp" #include diff --git a/modules/video/test/test_precomp.hpp b/modules/video/test/test_precomp.hpp index 7025dff8f..524ba80fc 100644 --- a/modules/video/test/test_precomp.hpp +++ b/modules/video/test/test_precomp.hpp @@ -9,11 +9,11 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/video.hpp" #include "opencv2/highgui.hpp" -#include #endif diff --git a/samples/c/bgfg_codebook.cpp b/samples/c/bgfg_codebook.cpp index 3054e9971..569a2788d 100644 --- a/samples/c/bgfg_codebook.cpp +++ b/samples/c/bgfg_codebook.cpp @@ -20,11 +20,12 @@ Or: http://oreilly.com/catalog/9780596516130/ ISBN-10: 0596516134 or: ISBN-13: 978-0596516130 ************************************************** */ -#include "opencv2/core/core.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "opencv2/video/background_segm.hpp" #include "opencv2/imgproc/imgproc_c.h" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/legacy/legacy.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/legacy.hpp" #include #include diff --git a/samples/c/find_obj_ferns.cpp b/samples/c/find_obj_ferns.cpp index 9d19c198f..093d08f36 100644 --- a/samples/c/find_obj_ferns.cpp +++ b/samples/c/find_obj_ferns.cpp @@ -1,9 +1,9 @@ -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/objdetect/objdetect.hpp" -#include "opencv2/legacy/legacy.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/objdetect.hpp" +#include "opencv2/legacy.hpp" #include #include diff --git a/samples/c/mser_sample.cpp b/samples/c/mser_sample.cpp index e0217a2d3..b6b96c343 100644 --- a/samples/c/mser_sample.cpp +++ b/samples/c/mser_sample.cpp @@ -2,9 +2,10 @@ * Copyright (C) 2009, Liu Liu All rights reserved. */ -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/imgproc/imgproc.hpp" +#include +#include "opencv2/highgui.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/imgproc.hpp" #include #include diff --git a/samples/cpp/bgfg_gmg.cpp b/samples/cpp/bgfg_gmg.cpp index 3d2da44ab..94640d076 100644 --- a/samples/cpp/bgfg_gmg.cpp +++ b/samples/cpp/bgfg_gmg.cpp @@ -6,6 +6,7 @@ */ #include +#include #include using namespace cv; diff --git a/samples/cpp/bgfg_segm.cpp b/samples/cpp/bgfg_segm.cpp index 399c7ad28..27abe6ff9 100644 --- a/samples/cpp/bgfg_segm.cpp +++ b/samples/cpp/bgfg_segm.cpp @@ -1,7 +1,8 @@ -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/imgproc.hpp" #include "opencv2/video/background_segm.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/highgui.hpp" #include using namespace std; diff --git a/samples/cpp/brief_match_test.cpp b/samples/cpp/brief_match_test.cpp index dea48d38e..13902206a 100644 --- a/samples/cpp/brief_match_test.cpp +++ b/samples/cpp/brief_match_test.cpp @@ -4,11 +4,12 @@ * Created on: Oct 17, 2010 * Author: ethan */ -#include "opencv2/core/core.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/calib3d.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/cpp/build3dmodel.cpp b/samples/cpp/build3dmodel.cpp index b896a3936..2ce1abd2d 100644 --- a/samples/cpp/build3dmodel.cpp +++ b/samples/cpp/build3dmodel.cpp @@ -1,8 +1,9 @@ -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/calib3d.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/highgui.hpp" #include diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index f4ff81077..8cbf6c538 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -1,7 +1,8 @@ -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/calib3d.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/cpp/camshiftdemo.cpp b/samples/cpp/camshiftdemo.cpp index 36316e636..44bce7637 100644 --- a/samples/cpp/camshiftdemo.cpp +++ b/samples/cpp/camshiftdemo.cpp @@ -1,6 +1,7 @@ +#include #include "opencv2/video/tracking.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/cpp/chamfer.cpp b/samples/cpp/chamfer.cpp index 8a51b0bae..a7d3578d4 100644 --- a/samples/cpp/chamfer.cpp +++ b/samples/cpp/chamfer.cpp @@ -1,6 +1,7 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/contrib/contrib.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/contrib.hpp" #include diff --git a/samples/cpp/connected_components.cpp b/samples/cpp/connected_components.cpp index d20991ecd..50c677d37 100644 --- a/samples/cpp/connected_components.cpp +++ b/samples/cpp/connected_components.cpp @@ -1,5 +1,6 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include using namespace cv; diff --git a/samples/cpp/demhist.cpp b/samples/cpp/demhist.cpp index 8b9189f32..eef25964a 100644 --- a/samples/cpp/demhist.cpp +++ b/samples/cpp/demhist.cpp @@ -1,5 +1,6 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include diff --git a/samples/cpp/detection_based_tracker_sample.cpp b/samples/cpp/detection_based_tracker_sample.cpp index 61106f3a9..2b9eef1a9 100644 --- a/samples/cpp/detection_based_tracker_sample.cpp +++ b/samples/cpp/detection_based_tracker_sample.cpp @@ -1,10 +1,11 @@ #if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID) -#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include "opencv2/contrib/detection_based_tracker.hpp" #include diff --git a/samples/cpp/detector_descriptor_matcher_evaluation.cpp b/samples/cpp/detector_descriptor_matcher_evaluation.cpp index bf92e7da3..194cddfe3 100644 --- a/samples/cpp/detector_descriptor_matcher_evaluation.cpp +++ b/samples/cpp/detector_descriptor_matcher_evaluation.cpp @@ -39,9 +39,10 @@ // //M*/ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/features2d/features2d.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/features2d.hpp" #include #include diff --git a/samples/cpp/dft.cpp b/samples/cpp/dft.cpp index d538c103e..234dc9a4e 100644 --- a/samples/cpp/dft.cpp +++ b/samples/cpp/dft.cpp @@ -1,6 +1,7 @@ -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include diff --git a/samples/cpp/distrans.cpp b/samples/cpp/distrans.cpp index 472c168e3..71ed71a98 100644 --- a/samples/cpp/distrans.cpp +++ b/samples/cpp/distrans.cpp @@ -1,5 +1,6 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include diff --git a/samples/cpp/edge.cpp b/samples/cpp/edge.cpp index c6a8db3b6..0944c90ee 100644 --- a/samples/cpp/edge.cpp +++ b/samples/cpp/edge.cpp @@ -1,5 +1,6 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include diff --git a/samples/cpp/facerec_demo.cpp b/samples/cpp/facerec_demo.cpp index 6402082e8..81953e3c8 100644 --- a/samples/cpp/facerec_demo.cpp +++ b/samples/cpp/facerec_demo.cpp @@ -16,9 +16,10 @@ * See */ -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/contrib/contrib.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/contrib.hpp" #include #include diff --git a/samples/cpp/freak_demo.cpp b/samples/cpp/freak_demo.cpp index 60778fd4e..d6ea45ac0 100644 --- a/samples/cpp/freak_demo.cpp +++ b/samples/cpp/freak_demo.cpp @@ -38,11 +38,12 @@ #include #include -#include -#include -#include -#include -#include +#include +#include "opencv2/core/utility.hpp" +#include +#include +#include +#include using namespace cv; diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp index 179a75184..08f9c0dd2 100644 --- a/samples/cpp/image_alignment.cpp +++ b/samples/cpp/image_alignment.cpp @@ -13,10 +13,10 @@ * Authors: G. Evangelidis, INRIA, Grenoble, France * M. Asbach, Fraunhofer IAIS, St. Augustin, Germany */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/samples/cpp/linemod.cpp b/samples/cpp/linemod.cpp index 8f0c71a31..267103788 100644 --- a/samples/cpp/linemod.cpp +++ b/samples/cpp/linemod.cpp @@ -1,8 +1,9 @@ -#include +#include +#include #include // cvFindContours -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/samples/cpp/opencv_version.cpp b/samples/cpp/opencv_version.cpp index b735f2a6c..ec9b47d58 100644 --- a/samples/cpp/opencv_version.cpp +++ b/samples/cpp/opencv_version.cpp @@ -1,4 +1,4 @@ -#include "opencv2/core/core.hpp" +#include #include const char* keys = diff --git a/samples/cpp/peopledetect.cpp b/samples/cpp/peopledetect.cpp index fee17897b..ff79ee68f 100644 --- a/samples/cpp/peopledetect.cpp +++ b/samples/cpp/peopledetect.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/samples/cpp/select3dobj.cpp b/samples/cpp/select3dobj.cpp index a21ee2d29..8652f7ebf 100644 --- a/samples/cpp/select3dobj.cpp +++ b/samples/cpp/select3dobj.cpp @@ -8,10 +8,11 @@ * */ -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/calib3d.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/cpp/simpleflow_demo.cpp b/samples/cpp/simpleflow_demo.cpp index 2562a2bb6..c9cde783d 100644 --- a/samples/cpp/simpleflow_demo.cpp +++ b/samples/cpp/simpleflow_demo.cpp @@ -1,6 +1,7 @@ +#include #include "opencv2/video/tracking.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/cpp/stereo_match.cpp b/samples/cpp/stereo_match.cpp index 7e1f6cb68..743185e45 100644 --- a/samples/cpp/stereo_match.cpp +++ b/samples/cpp/stereo_match.cpp @@ -11,6 +11,7 @@ #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/contrib/contrib.hpp" +#include "opencv2/core/utility.hpp" #include diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 73d139e41..29cffca1b 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -45,7 +45,8 @@ #include #include #include "opencv2/opencv_modules.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/highgui.hpp" #include "opencv2/stitching/detail/autocalib.hpp" #include "opencv2/stitching/detail/blenders.hpp" #include "opencv2/stitching/detail/camera.hpp" diff --git a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp index aa4a0361d..aeac2c823 100644 --- a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp +++ b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp @@ -3,10 +3,11 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include using namespace cv; using namespace std; diff --git a/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp b/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp index 49aca426e..421c8a620 100644 --- a/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp +++ b/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp @@ -1,5 +1,6 @@ -#include -#include +#include +#include +#include #include #include diff --git a/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp b/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp index 94e0a29a6..429f52ead 100644 --- a/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp +++ b/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp @@ -1,6 +1,7 @@ -#include -#include -#include +#include +#include +#include +#include #include using namespace std; diff --git a/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp b/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp index 0bcb6fafe..f3f2b683d 100644 --- a/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp +++ b/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp @@ -1,10 +1,11 @@ #include // Console I/O #include // String to number conversion -#include // Basic OpenCV structures -#include // Image processing methods for the CPU -#include // Read images -#include // GPU structures and methods +#include // Basic OpenCV structures +#include +#include // Image processing methods for the CPU +#include // Read images +#include // GPU structures and methods using namespace std; using namespace cv; diff --git a/samples/cpp/tvl1_optical_flow.cpp b/samples/cpp/tvl1_optical_flow.cpp index 4f9a02b5a..f5e71863c 100644 --- a/samples/cpp/tvl1_optical_flow.cpp +++ b/samples/cpp/tvl1_optical_flow.cpp @@ -1,8 +1,9 @@ #include #include -#include "opencv2/video/tracking.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/video.hpp" +#include "opencv2/highgui.hpp" using namespace cv; using namespace std; diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index effd9e61f..025a0279b 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -4,6 +4,7 @@ #include #include #include "opencv2/core.hpp" +#include #include "opencv2/video.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/highgui.hpp" diff --git a/samples/cpp/watershed.cpp b/samples/cpp/watershed.cpp index de7f5256f..923b8bf83 100644 --- a/samples/cpp/watershed.cpp +++ b/samples/cpp/watershed.cpp @@ -1,5 +1,6 @@ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" #include #include diff --git a/samples/gpu/bgfg_segm.cpp b/samples/gpu/bgfg_segm.cpp index 9456b15e8..e7db9a168 100644 --- a/samples/gpu/bgfg_segm.cpp +++ b/samples/gpu/bgfg_segm.cpp @@ -1,9 +1,10 @@ #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/gpu.hpp" +#include "opencv2/highgui.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/brox_optical_flow.cpp b/samples/gpu/brox_optical_flow.cpp index 56832c4de..1d92e4b3f 100644 --- a/samples/gpu/brox_optical_flow.cpp +++ b/samples/gpu/brox_optical_flow.cpp @@ -3,10 +3,10 @@ #include #include -#include "cvconfig.h" -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/gpu/gpu.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/gpu.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/farneback_optical_flow.cpp b/samples/gpu/farneback_optical_flow.cpp index 77ee49e1a..c93ceb055 100644 --- a/samples/gpu/farneback_optical_flow.cpp +++ b/samples/gpu/farneback_optical_flow.cpp @@ -2,10 +2,11 @@ #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/video/video.hpp" -#include "opencv2/gpu/gpu.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/video.hpp" +#include "opencv2/gpu.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/generalized_hough.cpp b/samples/gpu/generalized_hough.cpp index c41e7903c..3febbf0f5 100644 --- a/samples/gpu/generalized_hough.cpp +++ b/samples/gpu/generalized_hough.cpp @@ -2,11 +2,12 @@ #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/contrib/contrib.hpp" +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/gpu.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/contrib.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/hog.cpp b/samples/gpu/hog.cpp index 2e0b70bcf..59bddb187 100644 --- a/samples/gpu/hog.cpp +++ b/samples/gpu/hog.cpp @@ -4,8 +4,9 @@ #include #include #include -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/gpu.hpp" +#include "opencv2/highgui.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/houghlines.cpp b/samples/gpu/houghlines.cpp index e98dcc6e7..f104e16fa 100644 --- a/samples/gpu/houghlines.cpp +++ b/samples/gpu/houghlines.cpp @@ -1,10 +1,11 @@ #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/gpu/gpu.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/gpu.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/optical_flow.cpp b/samples/gpu/optical_flow.cpp index 3f74d1b67..cae00fcc3 100644 --- a/samples/gpu/optical_flow.cpp +++ b/samples/gpu/optical_flow.cpp @@ -1,9 +1,10 @@ #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/gpu/gpu.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/highgui.hpp" +#include "opencv2/gpu.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/performance/performance.h b/samples/gpu/performance/performance.h index 4f58061ac..8ee007f0a 100644 --- a/samples/gpu/performance/performance.h +++ b/samples/gpu/performance/performance.h @@ -6,8 +6,8 @@ #include #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/gpu/gpu.hpp" +#include +#include "opencv2/gpu.hpp" #define TAB " " diff --git a/samples/gpu/pyrlk_optical_flow.cpp b/samples/gpu/pyrlk_optical_flow.cpp index c2e765da1..95170cc7e 100644 --- a/samples/gpu/pyrlk_optical_flow.cpp +++ b/samples/gpu/pyrlk_optical_flow.cpp @@ -1,12 +1,12 @@ #include #include -#include "cvconfig.h" -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/video/video.hpp" -#include "opencv2/gpu/gpu.hpp" +#include "opencv2/core.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/video.hpp" +#include "opencv2/gpu.hpp" using namespace std; using namespace cv; diff --git a/samples/gpu/softcascade.cpp b/samples/gpu/softcascade.cpp index acc43af1b..980d6ffdf 100644 --- a/samples/gpu/softcascade.cpp +++ b/samples/gpu/softcascade.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/samples/gpu/stereo_match.cpp b/samples/gpu/stereo_match.cpp index 62745d749..4b849a8c0 100644 --- a/samples/gpu/stereo_match.cpp +++ b/samples/gpu/stereo_match.cpp @@ -3,8 +3,9 @@ #include #include #include -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/gpu.hpp" +#include "opencv2/highgui.hpp" using namespace cv; using namespace std; diff --git a/samples/ocl/hog.cpp b/samples/ocl/hog.cpp index 76b6d2830..c1623db8b 100644 --- a/samples/ocl/hog.cpp +++ b/samples/ocl/hog.cpp @@ -4,8 +4,9 @@ #include #include #include -#include "opencv2/ocl/ocl.hpp" -#include "opencv2/highgui/highgui.hpp" +#include +#include "opencv2/ocl.hpp" +#include "opencv2/highgui.hpp" using namespace std; using namespace cv; diff --git a/samples/ocl/performance.cpp b/samples/ocl/performance.cpp index 262e4320b..2c999ac69 100644 --- a/samples/ocl/performance.cpp +++ b/samples/ocl/performance.cpp @@ -5,17 +5,17 @@ #include #include #include -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/video/video.hpp" -#include "opencv2/nonfree/nonfree.hpp" -#include "opencv2/objdetect/objdetect.hpp" -#include "opencv2/features2d/features2d.hpp" +#include +#include "opencv2/imgproc.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/calib3d.hpp" +#include "opencv2/video.hpp" +#include "opencv2/nonfree.hpp" +#include "opencv2/objdetect.hpp" +#include "opencv2/features2d.hpp" #define USE_OPENCL #ifdef USE_OPENCL -#include "opencv2/ocl/ocl.hpp" +#include "opencv2/ocl.hpp" #endif #define TAB " "