Make core/internal.hpp a private header

This commit is contained in:
Andrey Kamaev 2013-04-01 17:29:10 +04:00
parent d62bc8cfbf
commit 517062039e
54 changed files with 364 additions and 264 deletions

View File

@ -5,6 +5,48 @@
#include <queue>
#include "cxmisc.h"
#include "cvconfig.h"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
# else
# undef HAVE_TBB
# endif
#endif
#ifdef HAVE_TBB
typedef tbb::blocked_range<int> BlockedRange;
template<typename Body> static inline
void parallel_for( const BlockedRange& range, const Body& body )
{
tbb::parallel_for(range, body);
}
#else
class BlockedRange
{
public:
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
int begin() const { return _begin; }
int end() const { return _end; }
int grainsize() const { return _grainsize; }
protected:
int _begin, _end, _grainsize;
};
template<typename Body> static inline
void parallel_for( const BlockedRange& range, const Body& body )
{
body(range);
}
#endif
using namespace std;
static inline double
@ -26,6 +68,12 @@ public:
const T* arr;
};
static inline int cvAlign( int size, int align )
{
CV_DbgAssert( (align & (align-1)) == 0 && size < INT_MAX );
return (size + align - 1) & -align;
}
#define CV_THRESHOLD_EPS (0.00001F)
static const int MinBlockSize = 1 << 16;

View File

@ -535,7 +535,7 @@ macro(ocv_create_module)
if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
if(hdr2 MATCHES "^(opencv2/.*)[^/]+.h(..)?$" AND NOT hdr2 MATCHES "opencv2/${the_module}/private.*")
install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT main)
endif()
endforeach()

View File

@ -1,6 +1,8 @@
#ifndef __OPENCV_OLD_CXMISC_H__
#define __OPENCV_OLD_CXMISC_H__
#include "opencv2/core/internal.hpp"
#ifdef __cplusplus
# include "opencv2/core/utility.hpp"
#endif
#endif

View File

@ -1,5 +1,8 @@
#include "perf_precomp.hpp"
#include "opencv2/core/internal.hpp"
#ifdef HAVE_TBB
#include "tbb/task_scheduler_init.h"
#endif
using namespace std;
using namespace cv;

View File

@ -42,19 +42,13 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/features2d.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include <vector>
#include "opencv2/core/private.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/calib3d/calib3d_tegra.hpp"

View File

@ -41,7 +41,10 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/core/internal.hpp"
#ifdef HAVE_TBB
#include "tbb/task_scheduler_init.h"
#endif
using namespace cv;
using namespace std;

View File

@ -43,18 +43,14 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/contrib.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
namespace cv
{

View File

@ -54,7 +54,6 @@
#include <iostream>
#include <limits>
#include "opencv2/core/internal.hpp"
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
# ifdef ANDROID
template <typename Scalar> Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); }

View File

@ -808,107 +808,6 @@ inline FileNode FileStorage::getFirstTopLevelNode() const
return it != r.end() ? *it : FileNode();
}
//////////////////////////////////////// Various algorithms ////////////////////////////////////
// This function splits the input sequence or set into one or more equivalence classes and
// returns the vector of labels - 0-based class indexes for each element.
// predicate(a,b) returns true if the two sequence elements certainly belong to the same class.
//
// The algorithm is described in "Introduction to Algorithms"
// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets"
template<typename _Tp, class _EqPredicate> int
partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
_EqPredicate predicate=_EqPredicate())
{
int i, j, N = (int)_vec.size();
const _Tp* vec = &_vec[0];
const int PARENT=0;
const int RANK=1;
std::vector<int> _nodes(N*2);
int (*nodes)[2] = (int(*)[2])&_nodes[0];
// The first O(N) pass: create N single-vertex trees
for(i = 0; i < N; i++)
{
nodes[i][PARENT]=-1;
nodes[i][RANK] = 0;
}
// The main O(N^2) pass: merge connected components
for( i = 0; i < N; i++ )
{
int root = i;
// find root
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
for( j = 0; j < N; j++ )
{
if( i == j || !predicate(vec[i], vec[j]))
continue;
int root2 = j;
while( nodes[root2][PARENT] >= 0 )
root2 = nodes[root2][PARENT];
if( root2 != root )
{
// unite both trees
int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
if( rank > rank2 )
nodes[root2][PARENT] = root;
else
{
nodes[root][PARENT] = root2;
nodes[root2][RANK] += rank == rank2;
root = root2;
}
CV_Assert( nodes[root][PARENT] < 0 );
int k = j, parent;
// compress the path from node2 to root
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
// compress the path from node to root
k = i;
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
}
}
}
// Final O(N) pass: enumerate classes
labels.resize(N);
int nclasses = 0;
for( i = 0; i < N; i++ )
{
int root = i;
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
// re-use the rank as the class label
if( nodes[root][RANK] >= 0 )
nodes[root][RANK] = ~nclasses++;
labels[i] = ~nodes[root][RANK];
}
return nclasses;
}
//////////////////////////////////////////////////////////////////////////////
class CV_EXPORTS Formatter

View File

@ -151,6 +151,7 @@ namespace cv
}
/****************************************************************************************\
* Common declarations *
\****************************************************************************************/
@ -187,6 +188,8 @@ static inline cv::Size cvGetMatSize( const CvMat* mat )
return cv::Size(mat->cols, mat->rows);
}
/****************************************************************************************\
* Structures and macros for integration with IPP *
\****************************************************************************************/
@ -245,4 +248,111 @@ typedef enum CvStatus
}
CvStatus;
/****************************************************************************************\
* Auxiliary algorithms *
\****************************************************************************************/
namespace cv
{
// This function splits the input sequence or set into one or more equivalence classes and
// returns the vector of labels - 0-based class indexes for each element.
// predicate(a,b) returns true if the two sequence elements certainly belong to the same class.
//
// The algorithm is described in "Introduction to Algorithms"
// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets"
template<typename _Tp, class _EqPredicate> int
partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
_EqPredicate predicate=_EqPredicate())
{
int i, j, N = (int)_vec.size();
const _Tp* vec = &_vec[0];
const int PARENT=0;
const int RANK=1;
std::vector<int> _nodes(N*2);
int (*nodes)[2] = (int(*)[2])&_nodes[0];
// The first O(N) pass: create N single-vertex trees
for(i = 0; i < N; i++)
{
nodes[i][PARENT]=-1;
nodes[i][RANK] = 0;
}
// The main O(N^2) pass: merge connected components
for( i = 0; i < N; i++ )
{
int root = i;
// find root
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
for( j = 0; j < N; j++ )
{
if( i == j || !predicate(vec[i], vec[j]))
continue;
int root2 = j;
while( nodes[root2][PARENT] >= 0 )
root2 = nodes[root2][PARENT];
if( root2 != root )
{
// unite both trees
int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
if( rank > rank2 )
nodes[root2][PARENT] = root;
else
{
nodes[root][PARENT] = root2;
nodes[root2][RANK] += rank == rank2;
root = root2;
}
CV_Assert( nodes[root][PARENT] < 0 );
int k = j, parent;
// compress the path from node2 to root
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
// compress the path from node to root
k = i;
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
}
}
}
// Final O(N) pass: enumerate classes
labels.resize(N);
int nclasses = 0;
for( i = 0; i < N; i++ )
{
int root = i;
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
// re-use the rank as the class label
if( nodes[root][RANK] >= 0 )
nodes[root][RANK] = ~nclasses++;
labels[i] = ~nodes[root][RANK];
}
return nclasses;
}
} // namespace cv
#endif // __OPENCV_CORE_PRIVATE_HPP__

View File

@ -40,10 +40,7 @@
//
//M*/
#include <sstream>
#include "cvconfig.h"
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "precomp.hpp"
#include "gl_core_3_1.hpp"
#ifdef HAVE_OPENGL

View File

@ -43,15 +43,12 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/core/utility.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/core/private.hpp"
#include <assert.h>
#include <ctype.h>
#include <float.h>

View File

@ -41,7 +41,6 @@
#include "precomp.hpp"
#include "opencv2/core/internal.hpp"
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 2
#include <Eigen/Array>
#endif

View File

@ -43,16 +43,12 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/features2d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#include <algorithm>

View File

@ -266,7 +266,7 @@ private:
const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT);
if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound)
{
CV_Error(CV_StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound));
CV_Error(cv::Error::StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound));
}
speed_level_ = kHash;

View File

@ -5,12 +5,8 @@
#include <cstdarg>
#include <sstream>
#ifdef HAVE_CVCONFIG_H
# include "cvconfig.h"
#endif
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/flann/dist.h"
@ -24,5 +20,7 @@
#include "opencv2/flann/all_indices.h"
#include "opencv2/flann/flann_base.hpp"
#include "opencv2/core/private.hpp"
#endif

View File

@ -54,8 +54,6 @@
#include <cstdio>
#include <iostream>
#include "cvconfig.h"
#ifdef HAVE_CUDA
#include <cuda_runtime.h>
#endif
@ -72,6 +70,8 @@
#include "opencv2/legacy.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/core/private.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif

View File

@ -47,10 +47,6 @@
#pragma warning( disable: 4251 4710 4711 4514 4996 )
#endif
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include <cstring>
#include <iostream>
#include <limits>
@ -71,9 +67,10 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/calib3d.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/video.hpp"
#include "opencv2/core/private.hpp"
#if defined WIN32 || defined WINCE
#include <windows.h>
#undef small

View File

@ -64,8 +64,6 @@
#include <iterator>
#include <stdexcept>
#include "cvconfig.h"
#ifdef HAVE_CUDA
#include <cuda.h>
#include <cuda_runtime.h>
@ -83,6 +81,8 @@
#include "interpolation.hpp"
#include "main_test_nvidia.h"
#include "opencv2/core/private.hpp"
#endif
#endif

View File

@ -42,14 +42,12 @@
#ifndef __HIGHGUI_H_
#define __HIGHGUI_H_
#include "cvconfig.h"
#include "opencv2/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#include <stdlib.h>
#include <stdio.h>

View File

@ -9,15 +9,13 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#ifdef HAVE_CVCONFIG_H
# include "cvconfig.h"
#endif
#include <iostream>
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/private.hpp"
#if defined(HAVE_VIDEOINPUT) || \
defined(HAVE_TYZX) || \
defined(HAVE_VFW) || \

View File

@ -1,5 +1,4 @@
#include "perf_precomp.hpp"
#include "opencv2/core/internal.hpp"
using namespace std;
using namespace cv;

View File

@ -43,15 +43,13 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#include <math.h>
#include <assert.h>
#include <string.h>

View File

@ -41,18 +41,14 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/legacy.hpp"
#include "opencv2/video.hpp"
#include "opencv2/legacy/blobtrack.hpp"
#include "opencv2/legacy/compat.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#define __BEGIN__ __CV_BEGIN__
#define __END__ __CV_END__

View File

@ -41,15 +41,13 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/core.hpp"
#include "opencv2/ml.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#include <assert.h>
#include <float.h>

View File

@ -43,15 +43,10 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/nonfree.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/opencv_modules.hpp"
@ -73,4 +68,6 @@
# include "opencv2/ocl/private/util.hpp"
#endif
#include "opencv2/core/private.hpp"
#endif

View File

@ -42,8 +42,7 @@
/* Haar features calculation */
#include "precomp.hpp"
#include <stdio.h>
#include "opencv2/core/internal.hpp"
#include "stdio.h"
#if CV_SSE2
# if 1 /*!CV_SSE4_1 && !CV_SSE4_2*/

View File

@ -43,23 +43,20 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_HIGHGUI
# include "opencv2/highgui.hpp"
#endif
#include "opencv2/core/private.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/objdetect/objdetect_tegra.hpp"
#endif

View File

@ -41,13 +41,8 @@
//M*/
#include "test_precomp.hpp"
#include <string>
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#ifdef HAVE_TBB
#include "tbb/task_scheduler_init.h"
#endif

View File

@ -61,19 +61,16 @@
#include <iterator>
#include <string>
#include <cstdarg>
#include "cvconfig.h"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video.hpp"
#include "opencv2/ts.hpp"
#include "opencv2/ocl.hpp"
//#include "opencv2/calib3d.hpp"
//#include "opencv2/nonfree.hpp"
#include "utility.hpp"
#include "interpolation.hpp"
//#include "add_test_info.h"
//#define PERF_TEST_OCL 1
#include "opencv2/core/private.hpp"
#endif

View File

@ -52,10 +52,6 @@
#pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 )
#endif
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include <map>
#include <iostream>
#include <limits>
@ -72,7 +68,8 @@
#include "opencv2/ocl.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
//#include "opencv2/highgui.hpp"
#define __ATI__

View File

@ -61,17 +61,16 @@
#include <iterator>
#include <string>
#include <cstdarg>
#include "cvconfig.h"
#include "opencv2/ts.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video.hpp"
#include "opencv2/ocl.hpp"
//#include "opencv2/calib3d.hpp"
#include "utility.hpp"
#include "interpolation.hpp"
//#include "add_test_info.h"
#include "opencv2/core/private.hpp"
#endif

View File

@ -43,9 +43,6 @@
#define __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_HPP__
#include "precomp.hpp"
#include <opencv2/core.hpp>
#include <opencv2/core/internal.hpp>
#include <opencv2/imgproc.hpp>
#include <limits>
#include "fast_nlmeans_denoising_invoker_commons.hpp"

View File

@ -42,10 +42,6 @@
#ifndef __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_COMMONS_HPP__
#define __OPENCV_FAST_NLMEANS_DENOISING_INVOKER_COMMONS_HPP__
#include <opencv2/core.hpp>
#include <opencv2/core/internal.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
template <typename T> static inline int calcDist(const T a, const T b);

View File

@ -43,9 +43,6 @@
#define __OPENCV_FAST_NLMEANS_MULTI_DENOISING_INVOKER_HPP__
#include "precomp.hpp"
#include <opencv2/core.hpp>
#include <opencv2/core/internal.hpp>
#include <opencv2/imgproc.hpp>
#include <limits>
#include "fast_nlmeans_denoising_invoker_commons.hpp"

View File

@ -43,11 +43,8 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/photo.hpp"
#include "opencv2/core/private.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/photo/photo_tegra.hpp"

View File

@ -43,17 +43,14 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/softcascade.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core_c.h"
#include "opencv2/core/internal.hpp"
#include "opencv2/ml.hpp"
#include "opencv2/core/private.hpp"
namespace cv { namespace softcascade { namespace internal
{

View File

@ -1,6 +1,5 @@
#include "perf_precomp.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/flann.hpp"
#include "opencv2/opencv_modules.hpp"

View File

@ -43,9 +43,6 @@
#ifndef __OPENCV_STITCHING_PRECOMP_H__
#define __OPENCV_STITCHING_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/opencv_modules.hpp"
#include <vector>
@ -56,7 +53,6 @@
#include <sstream>
#include <cmath>
#include "opencv2/core.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/stitching.hpp"
#include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
@ -79,6 +75,8 @@
#include "../../imgproc/src/gcgraph.hpp"
#include "opencv2/core/private.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
# include "opencv2/stitching/stitching_tegra.hpp"
#endif

View File

@ -51,10 +51,6 @@
#ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/core.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/ts/ts_perf.hpp"

View File

@ -46,16 +46,11 @@
#include <vector>
#include <limits>
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/core/opengl.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
@ -76,4 +71,6 @@
#include "ring_buffer.hpp"
#include "opencv2/core/private.hpp"
#endif /* __OPENCV_PRECOMP_H__ */

View File

@ -51,10 +51,6 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"

View File

@ -4,6 +4,7 @@
#ifdef HAVE_CVCONFIG_H
# include "cvconfig.h"
#endif
#ifndef GTEST_CREATE_SHARED_LIBRARY
#ifdef BUILD_SHARED_LIBS
#define GTEST_LINKED_AS_SHARED_LIBRARY 1

View File

@ -4,6 +4,7 @@
#ifdef HAVE_CVCONFIG_H
# include "cvconfig.h"
#endif
#ifndef GTEST_CREATE_SHARED_LIBRARY
# ifdef BUILD_SHARED_LIBS
# define GTEST_LINKED_AS_SHARED_LIBRARY 1

View File

@ -40,11 +40,10 @@
//
//M*/
#include "precomp.hpp"
#include "opencv2/ts/gpu_perf.hpp"
#include "opencv2/core/gpumat.hpp"
#include "cvconfig.h"
#ifdef HAVE_CUDA
#include <cuda_runtime.h>
#endif

View File

@ -3,6 +3,7 @@
#include "opencv2/core/core_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#ifdef GTEST_LINKED_AS_SHARED_LIBRARY
#error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined

View File

@ -43,15 +43,11 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/video.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/core/private.hpp"
#include <list>

View File

@ -43,10 +43,6 @@
#ifndef __OPENCV_PRECOMP_HPP__
#define __OPENCV_PRECOMP_HPP__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include <stdexcept>
#include <iostream>
#include <ctime>
@ -57,6 +53,8 @@
#include "opencv2/features2d.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/core/private.hpp"
// some aux. functions
inline float sqr(float x) { return x * x; }

View File

@ -43,10 +43,6 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_VIDEO
#include "opencv2/video.hpp"

View File

@ -382,6 +382,96 @@ struct EqKeypoints
const Set2i* pairs;
};
template<typename _Tp, class _EqPredicate> static
int partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
_EqPredicate predicate=_EqPredicate())
{
int i, j, N = (int)_vec.size();
const _Tp* vec = &_vec[0];
const int PARENT=0;
const int RANK=1;
std::vector<int> _nodes(N*2);
int (*nodes)[2] = (int(*)[2])&_nodes[0];
// The first O(N) pass: create N single-vertex trees
for(i = 0; i < N; i++)
{
nodes[i][PARENT]=-1;
nodes[i][RANK] = 0;
}
// The main O(N^2) pass: merge connected components
for( i = 0; i < N; i++ )
{
int root = i;
// find root
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
for( j = 0; j < N; j++ )
{
if( i == j || !predicate(vec[i], vec[j]))
continue;
int root2 = j;
while( nodes[root2][PARENT] >= 0 )
root2 = nodes[root2][PARENT];
if( root2 != root )
{
// unite both trees
int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
if( rank > rank2 )
nodes[root2][PARENT] = root;
else
{
nodes[root][PARENT] = root2;
nodes[root2][RANK] += rank == rank2;
root = root2;
}
CV_Assert( nodes[root][PARENT] < 0 );
int k = j, parent;
// compress the path from node2 to root
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
// compress the path from node to root
k = i;
while( (parent = nodes[k][PARENT]) >= 0 )
{
nodes[k][PARENT] = root;
k = parent;
}
}
}
}
// Final O(N) pass: enumerate classes
labels.resize(N);
int nclasses = 0;
for( i = 0; i < N; i++ )
{
int root = i;
while( nodes[root][PARENT] >= 0 )
root = nodes[root][PARENT];
// re-use the rank as the class label
if( nodes[root][RANK] >= 0 )
nodes[root][RANK] = ~nclasses++;
labels[i] = ~nodes[root][RANK];
}
return nclasses;
}
static void build3dmodel( const Ptr<FeatureDetector>& detector,
const Ptr<DescriptorExtractor>& descriptorExtractor,
const vector<Point3f>& /*modelBox*/,

View File

@ -11,6 +11,18 @@
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
# else
# undef HAVE_TBB
# endif
#endif
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
int main()
@ -30,7 +42,6 @@ int main()
#include <cuda.h>
#include <cuda_runtime.h>
#include "opencv2/core/internal.hpp" // For TBB wrappers
using namespace std;
using namespace cv;
@ -96,7 +107,7 @@ int main()
// Execute calculation in two threads using two GPUs
int devices[] = {0, 1};
parallel_do(devices, devices + 2, Worker());
tbb::parallel_do(devices, devices + 2, Worker());
destroyContexts();
return 0;

View File

@ -13,6 +13,18 @@
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
# else
# undef HAVE_TBB
# endif
#endif
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
int main()
@ -32,7 +44,6 @@ int main()
#include <cuda.h>
#include <cuda_runtime.h>
#include "opencv2/core/internal.hpp" // For TBB wrappers
using namespace std;
using namespace cv;
@ -159,7 +170,7 @@ int main(int argc, char** argv)
// Execute calculation in two threads using two GPUs
int devices[] = {0, 1};
parallel_do(devices, devices + 2, Worker());
tbb::parallel_do(devices, devices + 2, Worker());
// Release the first GPU resources
contextOn(0);

View File

@ -11,6 +11,18 @@
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
# else
# undef HAVE_TBB
# endif
#endif
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
int main()
@ -28,8 +40,6 @@ int main()
#else
#include "opencv2/core/internal.hpp" // For TBB wrappers
using namespace std;
using namespace cv;
using namespace cv::gpu;
@ -60,7 +70,7 @@ int main()
// Execute calculation in two threads using two GPUs
int devices[] = {0, 1};
parallel_do(devices, devices + 2, Worker());
tbb::parallel_do(devices, devices + 2, Worker());
return 0;
}

View File

@ -13,6 +13,18 @@
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
# else
# undef HAVE_TBB
# endif
#endif
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
int main()
@ -30,8 +42,6 @@ int main()
#else
#include "opencv2/core/internal.hpp" // For TBB wrappers
using namespace std;
using namespace cv;
using namespace cv::gpu;
@ -112,7 +122,7 @@ int main(int argc, char** argv)
// Execute calculation in two threads using two GPUs
int devices[] = {0, 1};
parallel_do(devices, devices + 2, Worker());
tbb::parallel_do(devices, devices + 2, Worker());
// Release the first GPU resources
setDevice(0);