Permalink
Browse files

Make core/internal.hpp a private header

  • Loading branch information...
1 parent d62bc8c commit 517062039e2078e86babdd87c7dfd2992e029c78 Andrey Kamaev committed Apr 1, 2013
Showing with 364 additions and 264 deletions.
  1. +48 −0 apps/traincascade/boost.cpp
  2. +1 −1 cmake/OpenCVModule.cmake
  3. +3 −1 include/opencv/cxmisc.h
  4. +4 −1 modules/calib3d/perf/perf_pnp.cpp
  5. +1 −7 modules/calib3d/src/precomp.hpp
  6. +4 −1 modules/calib3d/test/test_solvepnp_ransac.cpp
  7. +2 −6 modules/contrib/src/precomp.hpp
  8. +0 −1 modules/contrib/src/rgbdodometry.cpp
  9. +0 −101 modules/core/include/opencv2/core/operations.hpp
  10. +110 −0 modules/core/include/opencv2/core/{internal.hpp → private.hpp}
  11. +1 −4 modules/core/src/gl_core_3_1.cpp
  12. +2 −5 modules/core/src/precomp.hpp
  13. +0 −1 modules/features2d/src/matchers.cpp
  14. +1 −5 modules/features2d/src/precomp.hpp
  15. +1 −1 modules/flann/include/opencv2/flann/lsh_table.h
  16. +2 −4 modules/flann/src/precomp.hpp
  17. +2 −2 modules/gpu/perf/perf_precomp.hpp
  18. +2 −5 modules/gpu/src/precomp.hpp
  19. +2 −2 modules/gpu/test/test_precomp.hpp
  20. +1 −3 modules/highgui/src/precomp.hpp
  21. +2 −4 modules/highgui/test/test_precomp.hpp
  22. +0 −1 modules/imgproc/perf/perf_blur.cpp
  23. +2 −4 modules/imgproc/src/precomp.hpp
  24. +2 −6 modules/legacy/src/precomp.hpp
  25. +2 −4 modules/ml/src/precomp.hpp
  26. +2 −5 modules/nonfree/src/precomp.hpp
  27. +1 −2 modules/objdetect/src/haar.cpp
  28. +2 −5 modules/objdetect/src/precomp.hpp
  29. +0 −5 modules/objdetect/test/test_latentsvmdetector.cpp
  30. +2 −5 modules/ocl/perf/precomp.hpp
  31. +2 −5 modules/ocl/src/precomp.hpp
  32. +2 −3 modules/ocl/test/precomp.hpp
  33. +0 −3 modules/photo/src/fast_nlmeans_denoising_invoker.hpp
  34. +0 −4 modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
  35. +0 −3 modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp
  36. +1 −4 modules/photo/src/precomp.hpp
  37. +2 −5 modules/softcascade/src/precomp.hpp
  38. +0 −1 modules/stitching/perf/perf_stich.cpp
  39. +2 −4 modules/stitching/src/precomp.hpp
  40. +0 −4 modules/superres/perf/perf_precomp.hpp
  41. +2 −5 modules/superres/src/precomp.hpp
  42. +0 −4 modules/superres/test/test_precomp.hpp
  43. +2 −1 modules/ts/include/opencv2/ts.hpp
  44. +1 −0 modules/ts/include/opencv2/ts/ts_perf.hpp
  45. +1 −2 modules/ts/src/gpu_perf.cpp
  46. +1 −0 modules/ts/src/precomp.hpp
  47. +2 −6 modules/video/src/precomp.hpp
  48. +2 −4 modules/videostab/src/precomp.hpp
  49. +0 −4 modules/world/src/precomp.hpp
  50. +90 −0 samples/cpp/build3dmodel.cpp
  51. +13 −2 samples/gpu/driver_api_multi.cpp
  52. +13 −2 samples/gpu/driver_api_stereo_multi.cpp
  53. +13 −3 samples/gpu/multi.cpp
  54. +13 −3 samples/gpu/stereo_multi.cpp
@@ -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 @@ class LessThanIdx
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
@@ -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
@@ -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
@@ -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;
@@ -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"
@@ -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;
@@ -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
{
@@ -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)); }
@@ -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
@@ -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__
Oops, something went wrong.

1 comment on commit 5170620

smoguk commented on 5170620 Nov 12, 2013

Why did you put the public documented clustering algorithm "partition" in the private header? So it is unuseable in a common way...

Please sign in to comment.