diff --git a/3rdparty/flann/algorithms/autotuned_index.h b/3rdparty/flann/algorithms/autotuned_index.h index 30d9b5a514..aea36ef0ff 100644 --- a/3rdparty/flann/algorithms/autotuned_index.h +++ b/3rdparty/flann/algorithms/autotuned_index.h @@ -36,7 +36,7 @@ #include "ground_truth.h" #include "index_testing.h" -namespace flann +namespace cvflann { class AutotunedIndex : public NNIndex diff --git a/3rdparty/flann/algorithms/composite_index.h b/3rdparty/flann/algorithms/composite_index.h index c608388bfa..312ef4a9ae 100644 --- a/3rdparty/flann/algorithms/composite_index.h +++ b/3rdparty/flann/algorithms/composite_index.h @@ -34,7 +34,7 @@ #include "constants.h" #include "nn_index.h" -namespace flann +namespace cvflann { class CompositeIndex : public NNIndex diff --git a/3rdparty/flann/algorithms/dist.cpp b/3rdparty/flann/algorithms/dist.cpp index d9d3f0ee1e..c72cf2040c 100644 --- a/3rdparty/flann/algorithms/dist.cpp +++ b/3rdparty/flann/algorithms/dist.cpp @@ -30,7 +30,7 @@ #include "dist.h" -namespace flann +namespace cvflann { /** Global variable indicating the distance metric diff --git a/3rdparty/flann/algorithms/dist.h b/3rdparty/flann/algorithms/dist.h index 094dc3392a..444508dac3 100644 --- a/3rdparty/flann/algorithms/dist.h +++ b/3rdparty/flann/algorithms/dist.h @@ -36,7 +36,7 @@ using namespace std; #include "constants.h" -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/algorithms/kdtree_index.h b/3rdparty/flann/algorithms/kdtree_index.h index 2c957be435..d8be4417b6 100644 --- a/3rdparty/flann/algorithms/kdtree_index.h +++ b/3rdparty/flann/algorithms/kdtree_index.h @@ -48,7 +48,7 @@ using namespace std; -namespace flann +namespace cvflann { diff --git a/3rdparty/flann/algorithms/kmeans_index.h b/3rdparty/flann/algorithms/kmeans_index.h index 19fe51d65e..f8d3c15d8f 100644 --- a/3rdparty/flann/algorithms/kmeans_index.h +++ b/3rdparty/flann/algorithms/kmeans_index.h @@ -50,7 +50,7 @@ using namespace std; -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/algorithms/linear_index.h b/3rdparty/flann/algorithms/linear_index.h index 10df901503..19a4fd4a50 100644 --- a/3rdparty/flann/algorithms/linear_index.h +++ b/3rdparty/flann/algorithms/linear_index.h @@ -34,7 +34,7 @@ #include "constants.h" #include "nn_index.h" -namespace flann +namespace cvflann { class LinearIndex : public NNIndex { diff --git a/3rdparty/flann/algorithms/nn_index.h b/3rdparty/flann/algorithms/nn_index.h index 5018ab2d99..eeca4e08de 100644 --- a/3rdparty/flann/algorithms/nn_index.h +++ b/3rdparty/flann/algorithms/nn_index.h @@ -41,7 +41,7 @@ using namespace std; -namespace flann +namespace cvflann { class ResultSet; diff --git a/3rdparty/flann/flann.cpp b/3rdparty/flann/flann.cpp index 457698edd0..7297eacadc 100644 --- a/3rdparty/flann/flann.cpp +++ b/3rdparty/flann/flann.cpp @@ -58,7 +58,7 @@ using namespace std; #endif -namespace flann +namespace cvflann { typedef ObjectFactory ParamsFactory; @@ -224,7 +224,7 @@ int hierarchicalClustering(const Matrix& features, Matrix& centers -using namespace flann; +using namespace cvflann; typedef NNIndex* NNIndexPtr; typedef Matrix* MatrixPtr; diff --git a/3rdparty/flann/flann.hpp b/3rdparty/flann/flann.hpp index 2de0215138..97df248bc7 100644 --- a/3rdparty/flann/flann.hpp +++ b/3rdparty/flann/flann.hpp @@ -40,7 +40,7 @@ #include "flann.h" -namespace flann +namespace cvflann { class NNIndex; diff --git a/3rdparty/flann/nn/ground_truth.h b/3rdparty/flann/nn/ground_truth.h index eb8c25a89e..790aa7083f 100644 --- a/3rdparty/flann/nn/ground_truth.h +++ b/3rdparty/flann/nn/ground_truth.h @@ -34,7 +34,7 @@ #include "matrix.h" #include "dist.h" -namespace flann +namespace cvflann { template diff --git a/3rdparty/flann/nn/index_testing.cpp b/3rdparty/flann/nn/index_testing.cpp index fd418d42cc..e05662b45e 100644 --- a/3rdparty/flann/nn/index_testing.cpp +++ b/3rdparty/flann/nn/index_testing.cpp @@ -40,7 +40,7 @@ #include #include -namespace flann +namespace cvflann { const float SEARCH_EPS = 0.001f; diff --git a/3rdparty/flann/nn/index_testing.h b/3rdparty/flann/nn/index_testing.h index c5436c759a..7a8278f4d6 100644 --- a/3rdparty/flann/nn/index_testing.h +++ b/3rdparty/flann/nn/index_testing.h @@ -38,7 +38,7 @@ using namespace std; -namespace flann +namespace cvflann { void search_for_neighbors(NNIndex& index, const Matrix& testset, Matrix& result, Matrix& dists, const SearchParams &searchParams, int skip = 0); diff --git a/3rdparty/flann/nn/simplex_downhill.h b/3rdparty/flann/nn/simplex_downhill.h index 00595d2e9e..b995398cc7 100644 --- a/3rdparty/flann/nn/simplex_downhill.h +++ b/3rdparty/flann/nn/simplex_downhill.h @@ -31,7 +31,7 @@ #ifndef SIMPLEX_DOWNHILL_H #define SIMPLEX_DOWNHILL_H -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/util/allocator.h b/3rdparty/flann/util/allocator.h index 293b532f11..b6bdf37a8c 100644 --- a/3rdparty/flann/util/allocator.h +++ b/3rdparty/flann/util/allocator.h @@ -35,7 +35,7 @@ #include -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/util/common.h b/3rdparty/flann/util/common.h index 6df4f9e4c8..e5f9ed01e4 100644 --- a/3rdparty/flann/util/common.h +++ b/3rdparty/flann/util/common.h @@ -36,7 +36,7 @@ #include -namespace flann +namespace cvflann { class FLANNException : public std::runtime_error { public: diff --git a/3rdparty/flann/util/heap.h b/3rdparty/flann/util/heap.h index e43558f256..9cc835c064 100644 --- a/3rdparty/flann/util/heap.h +++ b/3rdparty/flann/util/heap.h @@ -35,7 +35,7 @@ #include using namespace std; -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/util/logger.cpp b/3rdparty/flann/util/logger.cpp index b01e3d81a4..c7e43e1a8d 100644 --- a/3rdparty/flann/util/logger.cpp +++ b/3rdparty/flann/util/logger.cpp @@ -36,7 +36,7 @@ using namespace std; -namespace flann +namespace cvflann { Logger logger; diff --git a/3rdparty/flann/util/logger.h b/3rdparty/flann/util/logger.h index 121eff9fb0..b47887f2fd 100644 --- a/3rdparty/flann/util/logger.h +++ b/3rdparty/flann/util/logger.h @@ -39,7 +39,7 @@ using namespace std; -namespace flann +namespace cvflann { class Logger diff --git a/3rdparty/flann/util/matrix.h b/3rdparty/flann/util/matrix.h index 5ebd1fe504..94ffb4449f 100644 --- a/3rdparty/flann/util/matrix.h +++ b/3rdparty/flann/util/matrix.h @@ -35,7 +35,7 @@ #include -namespace flann +namespace cvflann { /** * Class implementing a generic rectangular dataset. diff --git a/3rdparty/flann/util/object_factory.h b/3rdparty/flann/util/object_factory.h index a777701368..372bbe6b5a 100644 --- a/3rdparty/flann/util/object_factory.h +++ b/3rdparty/flann/util/object_factory.h @@ -33,7 +33,7 @@ #include -namespace flann +namespace cvflann { template diff --git a/3rdparty/flann/util/random.cpp b/3rdparty/flann/util/random.cpp index bc2f1e95ff..33cbe47fb9 100644 --- a/3rdparty/flann/util/random.cpp +++ b/3rdparty/flann/util/random.cpp @@ -31,7 +31,7 @@ #include "random.h" -namespace flann +namespace cvflann { void seed_random(unsigned int seed) diff --git a/3rdparty/flann/util/random.h b/3rdparty/flann/util/random.h index f78dfee9ee..74d5a563fe 100644 --- a/3rdparty/flann/util/random.h +++ b/3rdparty/flann/util/random.h @@ -37,7 +37,7 @@ using namespace std; -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/util/result_set.h b/3rdparty/flann/util/result_set.h index 61634aa354..2985d6956d 100644 --- a/3rdparty/flann/util/result_set.h +++ b/3rdparty/flann/util/result_set.h @@ -40,7 +40,7 @@ using namespace std; -namespace flann +namespace cvflann { /* This record represents a branch point when finding neighbors in diff --git a/3rdparty/flann/util/saving.cpp b/3rdparty/flann/util/saving.cpp index ea853276e3..bd51803504 100644 --- a/3rdparty/flann/util/saving.cpp +++ b/3rdparty/flann/util/saving.cpp @@ -33,7 +33,7 @@ #include "nn_index.h" #include -namespace flann +namespace cvflann { const char FLANN_SIGNATURE[] = "FLANN_INDEX"; diff --git a/3rdparty/flann/util/saving.h b/3rdparty/flann/util/saving.h index 082b56241c..f10162b6bd 100644 --- a/3rdparty/flann/util/saving.h +++ b/3rdparty/flann/util/saving.h @@ -35,7 +35,7 @@ #include "nn_index.h" -namespace flann +namespace cvflann { /** diff --git a/3rdparty/flann/util/timer.h b/3rdparty/flann/util/timer.h index df4a66a032..c5d2aefa48 100644 --- a/3rdparty/flann/util/timer.h +++ b/3rdparty/flann/util/timer.h @@ -34,7 +34,7 @@ #include -namespace flann +namespace cvflann { /** diff --git a/3rdparty/include/flann/common.h b/3rdparty/include/flann/common.h index 6df4f9e4c8..e5f9ed01e4 100644 --- a/3rdparty/include/flann/common.h +++ b/3rdparty/include/flann/common.h @@ -36,7 +36,7 @@ #include -namespace flann +namespace cvflann { class FLANNException : public std::runtime_error { public: diff --git a/3rdparty/include/flann/flann.hpp b/3rdparty/include/flann/flann.hpp index a86647388b..83231df29f 100644 --- a/3rdparty/include/flann/flann.hpp +++ b/3rdparty/include/flann/flann.hpp @@ -40,7 +40,7 @@ #include "flann.h" -namespace flann +namespace cvflann { class NNIndex; diff --git a/3rdparty/include/flann/matrix.h b/3rdparty/include/flann/matrix.h index 2af0a14907..d2ad915429 100644 --- a/3rdparty/include/flann/matrix.h +++ b/3rdparty/include/flann/matrix.h @@ -35,7 +35,7 @@ #include "random.h" -namespace flann +namespace cvflann { /** * Class implementing a generic rectangular dataset. diff --git a/3rdparty/include/flann/random.h b/3rdparty/include/flann/random.h index f78dfee9ee..74d5a563fe 100644 --- a/3rdparty/include/flann/random.h +++ b/3rdparty/include/flann/random.h @@ -37,7 +37,7 @@ using namespace std; -namespace flann +namespace cvflann { /** diff --git a/doc/cxcore_clustering_search.tex b/doc/cxcore_clustering_search.tex index b56f295bd9..21e337c73a 100644 --- a/doc/cxcore_clustering_search.tex +++ b/doc/cxcore_clustering_search.tex @@ -293,11 +293,11 @@ This section documents OpenCV's interface to the FLANN\footnote{http://people.cs contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. More information about FLANN can be found in \cite{muja_flann_2009}. -\cvclass{flann::Index} +\cvclass{cvflann::Index} The FLANN nearest neighbor index class. \begin{lstlisting} -namespace flann +namespace cvflann { class Index { @@ -335,7 +335,7 @@ namespace flann } \end{lstlisting} -\cvCppFunc{flann::Index::Index} +\cvCppFunc{cvflann::Index::Index} Constructs a nearest neighbor search index for a given dataset. \cvdefCpp{Index::Index(const Mat\& features, const IndexParams\& params);} @@ -452,7 +452,7 @@ optimum parameters.} } \end{description} -\cvCppFunc{flann::Index::knnSearch} +\cvCppFunc{cvflann::Index::knnSearch} Performs a K-nearest neighbor search for a given query point using the index. \cvdefCpp{void Index::knnSearch(const vector\& query, \par vector\& indices, \par @@ -479,7 +479,7 @@ precision was also computed, in which case this parameter is ignored.} \end{description} \end{description} -\cvCppFunc{flann::Index::knnSearch} +\cvCppFunc{cvflann::Index::knnSearch} Performs a K-nearest neighbor search for multiple query points. \cvdefCpp{void Index::knnSearch(const Mat\& queries,\par @@ -495,7 +495,7 @@ Performs a K-nearest neighbor search for multiple query points. \end{description} -\cvCppFunc{flann::Index::radiusSearch} +\cvCppFunc{cvflann::Index::radiusSearch} Performs a radius nearest neighbor search for a given query point. \cvdefCpp{int Index::radiusSearch(const vector\& query, \par vector\& indices, \par @@ -511,7 +511,7 @@ Performs a radius nearest neighbor search for a given query point. \end{description} -\cvCppFunc{flann::Index::radiusSearch} +\cvCppFunc{cvflann::Index::radiusSearch} Performs a radius nearest neighbor search for multiple query points. \cvdefCpp{int Index::radiusSearch(const Mat\& query, \par Mat\& indices, \par @@ -527,7 +527,7 @@ Performs a radius nearest neighbor search for multiple query points. \end{description} -\cvCppFunc{flann::Index::save} +\cvCppFunc{cvflann::Index::save} Saves the index to a file. \cvdefCpp{void Index::save(std::string filename);} \begin{description} @@ -535,7 +535,7 @@ Saves the index to a file. \end{description} -\cvCppFunc{flann::hierarchicalClustering} +\cvCppFunc{cvflann::hierarchicalClustering} Clusters the given points by constructing a hierarchical k-means tree and choosing a cut in the tree that minimizes the cluster's variance. \cvdefCpp{int hierarchicalClustering(const Mat\& features, Mat\& centers,\par const KMeansIndexParams\& params);} diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 0a8f1877b9..e529758a43 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -131,10 +131,9 @@ public: }; -/*! - \fn void error(const Exception& exc); - \brief Signals an error and raises the exception. +//! Signals an error and raises the exception. +/*! By default the function prints information about the error to stderr, then it either stops if setBreakOnError() had been called before or raises the exception. It is possible to alternate error processing by using redirectError(). @@ -143,10 +142,9 @@ public: */ CV_EXPORTS void error( const Exception& exc ); +//! Sets/resets the break-on-error mode. + /*! - \fn bool setBreakOnError(bool flag); - \brief 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. @@ -158,11 +156,9 @@ typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata ); -/*! - \fn ErrorCallback redirectError( ErrorCallback errCallback, - void* userdata=0, void** prevUserdata=0); - \brief Sets the new error handler and the optional user data. +//! 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. @@ -194,10 +190,9 @@ CV_EXPORTS void setNumThreads(int); CV_EXPORTS int getNumThreads(); CV_EXPORTS int getThreadNum(); -/*! - \fn int64 getTickCount(); - \brief Returns the number of ticks. +//! 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 @@ -206,8 +201,7 @@ CV_EXPORTS int getThreadNum(); CV_EXPORTS int64 getTickCount(); /*! - \fn int64 getTickCount(); - \brief Returns the number of ticks per seconds. + 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: @@ -221,8 +215,7 @@ CV_EXPORTS int64 getTickCount(); CV_EXPORTS double getTickFrequency(); /*! - \fn int64 getCPUTickCount(); - \brief Returns the number of CPU ticks. + 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 @@ -232,8 +225,7 @@ CV_EXPORTS double getTickFrequency(); CV_EXPORTS int64 getCPUTickCount(); /*! - \fn bool checkHardwareSupport(int feature); - \brief Returns SSE etc. support status + Returns SSE etc. support status The function returns true if certain hardware features are available. Currently, the following features are recognized: @@ -253,8 +245,7 @@ CV_EXPORTS int64 getCPUTickCount(); CV_EXPORTS bool checkHardwareSupport(int feature); /*! - \fn void* fastMalloc(size_t bufSize); - \brief allocates memory buffer + Allocates memory buffer This is specialized OpenCV memory allocation function that returns properly aligned memory buffers. The usage is identical to malloc(). The allocated buffers must be freed with cv::fastFree(). @@ -266,8 +257,7 @@ CV_EXPORTS bool checkHardwareSupport(int feature); CV_EXPORTS void* fastMalloc(size_t bufSize); /*! - \fn void fastFree(void* ptr); - \brief frees the memory allocated with cv::fastMalloc + Frees the memory allocated with cv::fastMalloc This is the corresponding deallocation function for cv::fastMalloc(). When ptr==NULL, the function has no effect. @@ -285,8 +275,7 @@ template static inline void deallocate(_Tp* ptr, size_t) } /*! - \fn template inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)); - \brief aligns pointer by the certain number of bytes + 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. @@ -297,8 +286,7 @@ template static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_ } /*! - \fn inline size_t alignSize(size_t sz, int n); - \brief aligns buffer size by the certain number of bytes + 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. */ @@ -308,8 +296,7 @@ static inline size_t alignSize(size_t sz, int n) } /*! - \fn void setUseOptimized(bool flag); - \brief Turns on/off available optimization + 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. @@ -320,8 +307,7 @@ static inline size_t alignSize(size_t sz, int n) CV_EXPORTS void setUseOptimized(bool); /*! - \fn bool useOptimized(); - \brief Returns the current optimization status + Returns the current optimization status The function returns the current optimization status, which is controlled by cv::setUseOptimized(). */ @@ -1693,43 +1679,68 @@ CV_EXPORTS void max(const Mat& a, const Mat& b, Mat& c); //! computes per-element maximum of array and a scalar (c = max(a, alpha)) CV_EXPORTS void max(const Mat& a, double alpha, Mat& c); - +//! computes square root of each matrix element CV_EXPORTS void sqrt(const Mat& a, Mat& b); +//! raises the input matrix elements to the specified power CV_EXPORTS void pow(const Mat& a, double power, Mat& b); +//! computes exponent of each matrix element CV_EXPORTS void exp(const Mat& a, Mat& b); +//! computes natural logarithm of each matrix element CV_EXPORTS void log(const Mat& a, Mat& b); +//! computes cube root of the argument CV_EXPORTS float cubeRoot(float val); +//! computes the angle in degrees (0..360) of the vector (x,y) CV_EXPORTS float fastAtan2(float y, float x); +//! converts polar coordinates to Cartesian CV_EXPORTS void polarToCart(const Mat& magnitude, const Mat& angle, Mat& x, Mat& y, bool angleInDegrees=false); +//! converts Cartesian coordinates to polar CV_EXPORTS void cartToPolar(const Mat& x, const Mat& y, Mat& magnitude, Mat& angle, bool angleInDegrees=false); +//! computes angle (angle(i)) of each (x(i), y(i)) vector CV_EXPORTS void phase(const Mat& x, const Mat& y, Mat& angle, - bool angleInDegrees=false); + bool angleInDegrees=false); +//! computes magnitude (magnitude(i)) of each (x(i), y(i)) vector CV_EXPORTS void magnitude(const Mat& x, const Mat& y, Mat& magnitude); +//! checks that each matrix element is within the specified range. CV_EXPORTS bool checkRange(const Mat& a, bool quiet=true, Point* pt=0, double minVal=-DBL_MAX, double maxVal=DBL_MAX); - +//! implements generalized matrix product algorithm GEMM from BLAS CV_EXPORTS void gemm(const Mat& a, const Mat& b, double alpha, const Mat& c, double gamma, Mat& d, int flags=0); +//! multiplies matrix by its transposition from the left or from the right CV_EXPORTS void mulTransposed( const Mat& a, Mat& c, bool aTa, const Mat& delta=Mat(), double scale=1, int rtype=-1 ); +//! transposes the matrix CV_EXPORTS void transpose(const Mat& a, Mat& b); +//! performs affine transformation of each element of multi-channel input matrix CV_EXPORTS void transform(const Mat& src, Mat& dst, const Mat& m ); +//! performs perspective transformation of each element of multi-channel input matrix CV_EXPORTS void perspectiveTransform(const Mat& src, Mat& dst, const Mat& m ); +//! extends the symmetrical matrix from the lower half or from the upper half CV_EXPORTS void completeSymm(Mat& a, bool lowerToUpper=false); +//! initializes scaled identity matrix CV_EXPORTS void setIdentity(Mat& c, const Scalar& s=Scalar(1)); +//! computes determinant of a square matrix CV_EXPORTS double determinant(const Mat& m); +//! computes trace of a matrix CV_EXPORTS Scalar trace(const Mat& m); +//! computes inverse or pseudo-inverse matrix CV_EXPORTS double invert(const Mat& a, Mat& c, int flags=DECOMP_LU); +//! solves linear system or a least-square problem CV_EXPORTS bool solve(const Mat& a, const Mat& b, Mat& x, int flags=DECOMP_LU); +//! sorts independently each matrix row or each matrix column CV_EXPORTS void sort(const Mat& a, Mat& b, int flags); +//! sorts independently each matrix row or each matrix column CV_EXPORTS void sortIdx(const Mat& a, Mat& b, int flags); +//! finds real roots of a cubic polynomial CV_EXPORTS int solveCubic(const Mat& coeffs, Mat& roots); +//! finds real and complex roots of a polynomial CV_EXPORTS double solvePoly(const Mat& coeffs, Mat& roots, int maxIters=300); +//! CV_EXPORTS bool eigen(const Mat& a, Mat& eigenvalues, int lowindex=-1, int highindex=-1); CV_EXPORTS bool eigen(const Mat& a, Mat& eigenvalues, Mat& eigenvectors, diff --git a/modules/core/include/opencv2/core/flann.hpp b/modules/core/include/opencv2/core/flann.hpp index 40162f81fc..715cc6267e 100644 --- a/modules/core/include/opencv2/core/flann.hpp +++ b/modules/core/include/opencv2/core/flann.hpp @@ -45,14 +45,14 @@ #ifdef __cplusplus -namespace flann +namespace cvflann { class Index; } namespace cv { -namespace flann { +namespace cvflann { /* Nearest neighbor index algorithms */ enum flann_algorithm_t { @@ -89,7 +89,7 @@ class CV_EXPORTS IndexFactory { public: virtual ~IndexFactory() {} - virtual ::flann::Index* createIndex(const Mat& dataset) const = 0; + virtual ::cvflann::Index* createIndex(const Mat& dataset) const = 0; }; struct CV_EXPORTS IndexParams : public IndexFactory { @@ -101,7 +101,7 @@ protected: struct CV_EXPORTS LinearIndexParams : public IndexParams { LinearIndexParams() {}; - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; @@ -111,7 +111,7 @@ struct CV_EXPORTS KDTreeIndexParams : public IndexParams { int trees; // number of randomized trees to use (for kdtree) - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; struct CV_EXPORTS KMeansIndexParams : public IndexParams { @@ -127,7 +127,7 @@ struct CV_EXPORTS KMeansIndexParams : public IndexParams { flann_centers_init_t centers_init; // algorithm used for picking the initial cluster centers for kmeans tree float cb_index; // cluster boundary index. Used when searching the kmeans tree - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; @@ -146,7 +146,7 @@ struct CV_EXPORTS CompositeIndexParams : public IndexParams { flann_centers_init_t centers_init; // algorithm used for picking the initial cluster centers for kmeans tree float cb_index; // cluster boundary index. Used when searching the kmeans tree - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; @@ -163,7 +163,7 @@ struct CV_EXPORTS AutotunedIndexParams : public IndexParams { float memory_weight; // index memory weighting factor float sample_fraction; // what fraction of the dataset to use for autotuning - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; @@ -173,7 +173,7 @@ struct CV_EXPORTS SavedIndexParams : public IndexParams { std::string filename; // filename of the stored index - ::flann::Index* createIndex(const Mat& dataset) const; + ::cvflann::Index* createIndex(const Mat& dataset) const; }; @@ -187,7 +187,7 @@ struct CV_EXPORTS SearchParams { class CV_EXPORTS Index { - ::flann::Index* nnIndex; + ::cvflann::Index* nnIndex; public: Index(const Mat& features, const IndexParams& params); diff --git a/modules/core/src/flann.cpp b/modules/core/src/flann.cpp index 95278ee4d8..46f961022a 100644 --- a/modules/core/src/flann.cpp +++ b/modules/core/src/flann.cpp @@ -38,72 +38,72 @@ namespace cv { -namespace flann { +namespace cvflann { -::flann::Index* LinearIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* LinearIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::LinearIndexParams()); + return new ::cvflann::Index(mat, ::cvflann::LinearIndexParams()); } -::flann::Index* KDTreeIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* KDTreeIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::KDTreeIndexParams(trees)); + return new ::cvflann::Index(mat, ::cvflann::KDTreeIndexParams(trees)); } -::flann::Index* KMeansIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* KMeansIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::KMeansIndexParams(branching,iterations, (::flann_centers_init_t)centers_init, cb_index)); + return new ::cvflann::Index(mat, ::cvflann::KMeansIndexParams(branching,iterations, (::flann_centers_init_t)centers_init, cb_index)); } -::flann::Index* CompositeIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* CompositeIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::CompositeIndexParams(trees, branching, iterations, (::flann_centers_init_t)centers_init, cb_index)); + return new ::cvflann::Index(mat, ::cvflann::CompositeIndexParams(trees, branching, iterations, (::flann_centers_init_t)centers_init, cb_index)); } -::flann::Index* AutotunedIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* AutotunedIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::AutotunedIndexParams(target_precision, build_weight, memory_weight, sample_fraction)); + return new ::cvflann::Index(mat, ::cvflann::AutotunedIndexParams(target_precision, build_weight, memory_weight, sample_fraction)); } -::flann::Index* SavedIndexParams::createIndex(const Mat& dataset) const +::cvflann::Index* SavedIndexParams::createIndex(const Mat& dataset) const { CV_Assert(dataset.type() == CV_32F); CV_Assert(dataset.isContinuous()); - // TODO: fix ::flann::Matrix class so it can be constructed with a const float* - ::flann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); + // TODO: fix ::cvflann::Matrix class so it can be constructed with a const float* + ::cvflann::Matrix mat(dataset.rows, dataset.cols, (float*)dataset.ptr(0)); - return new ::flann::Index(mat, ::flann::SavedIndexParams(filename)); + return new ::cvflann::Index(mat, ::cvflann::SavedIndexParams(filename)); } @@ -121,11 +121,11 @@ Index::~Index() void Index::knnSearch(const vector& query, vector& indices, vector& dists, int knn, const SearchParams& searchParams) { - ::flann::Matrix m_query(1, query.size(), (float*)&query[0]); - ::flann::Matrix m_indices(1, indices.size(), &indices[0]); - ::flann::Matrix m_dists(1, dists.size(), &dists[0]); + ::cvflann::Matrix m_query(1, query.size(), (float*)&query[0]); + ::cvflann::Matrix m_indices(1, indices.size(), &indices[0]); + ::cvflann::Matrix m_dists(1, dists.size(), &dists[0]); - nnIndex->knnSearch(m_query,m_indices,m_dists,knn,::flann::SearchParams(searchParams.checks)); + nnIndex->knnSearch(m_query,m_indices,m_dists,knn,::cvflann::SearchParams(searchParams.checks)); } @@ -134,26 +134,26 @@ void Index::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, con CV_Assert(queries.type() == CV_32F); CV_Assert(queries.isContinuous()); - ::flann::Matrix m_queries(queries.rows, queries.cols, (float*)queries.ptr(0)); + ::cvflann::Matrix m_queries(queries.rows, queries.cols, (float*)queries.ptr(0)); CV_Assert(indices.type() == CV_32S); CV_Assert(indices.isContinuous()); - ::flann::Matrix m_indices(indices.rows, indices.cols, (int*)indices.ptr(0)); + ::cvflann::Matrix m_indices(indices.rows, indices.cols, (int*)indices.ptr(0)); CV_Assert(dists.type() == CV_32F); CV_Assert(dists.isContinuous()); - ::flann::Matrix m_dists(dists.rows, dists.cols, (float*)dists.ptr(0)); + ::cvflann::Matrix m_dists(dists.rows, dists.cols, (float*)dists.ptr(0)); - nnIndex->knnSearch(m_queries,m_indices,m_dists,knn,::flann::SearchParams(searchParams.checks)); + nnIndex->knnSearch(m_queries,m_indices,m_dists,knn,::cvflann::SearchParams(searchParams.checks)); } int Index::radiusSearch(const vector& query, vector& indices, vector& dists, float radius, const SearchParams& searchParams) { - ::flann::Matrix m_query(1, query.size(), (float*)&query[0]); - ::flann::Matrix m_indices(1, indices.size(), &indices[0]); - ::flann::Matrix m_dists(1, dists.size(), &dists[0]); + ::cvflann::Matrix m_query(1, query.size(), (float*)&query[0]); + ::cvflann::Matrix m_indices(1, indices.size(), &indices[0]); + ::cvflann::Matrix m_dists(1, dists.size(), &dists[0]); - return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,::flann::SearchParams(searchParams.checks)); + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,::cvflann::SearchParams(searchParams.checks)); } @@ -161,17 +161,17 @@ int Index::radiusSearch(const Mat& query, Mat& indices, Mat& dists, float radius { CV_Assert(query.type() == CV_32F); CV_Assert(query.isContinuous()); - ::flann::Matrix m_query(query.rows, query.cols, (float*)query.ptr(0)); + ::cvflann::Matrix m_query(query.rows, query.cols, (float*)query.ptr(0)); CV_Assert(indices.type() == CV_32S); CV_Assert(indices.isContinuous()); - ::flann::Matrix m_indices(indices.rows, indices.cols, (int*)indices.ptr(0)); + ::cvflann::Matrix m_indices(indices.rows, indices.cols, (int*)indices.ptr(0)); CV_Assert(dists.type() == CV_32F); CV_Assert(dists.isContinuous()); - ::flann::Matrix m_dists(dists.rows, dists.cols, (float*)dists.ptr(0)); + ::cvflann::Matrix m_dists(dists.rows, dists.cols, (float*)dists.ptr(0)); - return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,::flann::SearchParams(searchParams.checks)); + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,::cvflann::SearchParams(searchParams.checks)); } @@ -195,13 +195,13 @@ int hierarchicalClustering(const Mat& features, Mat& centers, const KMeansIndexP { CV_Assert(features.type() == CV_32F); CV_Assert(features.isContinuous()); - ::flann::Matrix m_features(features.rows, features.cols, (float*)features.ptr(0)); + ::cvflann::Matrix m_features(features.rows, features.cols, (float*)features.ptr(0)); CV_Assert(features.type() == CV_32F); CV_Assert(features.isContinuous()); - ::flann::Matrix m_centers(centers.rows, centers.cols, (float*)centers.ptr(0)); + ::cvflann::Matrix m_centers(centers.rows, centers.cols, (float*)centers.ptr(0)); - return ::flann::hierarchicalClustering(m_features, m_centers, ::flann::KMeansIndexParams(params.branching, params.iterations, + return ::cvflann::hierarchicalClustering(m_features, m_centers, ::cvflann::KMeansIndexParams(params.branching, params.iterations, (::flann_centers_init_t)params.centers_init, params.cb_index)); } diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 8178196d4f..ce5d07a7ac 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -1078,7 +1078,7 @@ protected: CvMat* m_pca_hr_eigenvectors; // PCA eigenvectors for large patches OneWayDescriptor* m_pca_descriptors; // an array of PCA descriptors - cv::flann::Index* m_pca_descriptors_tree; + cv::cvflann::Index* m_pca_descriptors_tree; CvMat* m_pca_descriptors_matrix; CvAffinePose* m_poses; // array of poses diff --git a/modules/features2d/src/oneway.cpp b/modules/features2d/src/oneway.cpp index e0b3d5c56e..1bf253ca16 100644 --- a/modules/features2d/src/oneway.cpp +++ b/modules/features2d/src/oneway.cpp @@ -149,7 +149,7 @@ namespace cv{ std::vector& desc_idxs, std::vector& pose_idxs, std::vector& distances, CvMat* avg = 0, CvMat* eigenvalues = 0); - void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, + void FindOneWayDescriptor(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, CvMat* avg = 0, CvMat* eigenvalues = 0); void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, @@ -163,7 +163,7 @@ namespace cv{ std::vector& distances, std::vector& scales, CvMat* avg, CvMat* eigenvectors); - void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, + void FindOneWayDescriptorEx(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, float scale_min, float scale_max, float scale_step, int& desc_idx, int& pose_idx, float& distance, float& scale, CvMat* avg, CvMat* eigenvectors); @@ -800,7 +800,7 @@ namespace cv{ #if defined(_KDTREE) - void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, + void FindOneWayDescriptor(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, CvMat* avg, CvMat* eigenvectors) { desc_idx = -1; @@ -848,8 +848,8 @@ namespace cv{ //-------- //float* target = new float[m_pca_dim_low]; - //::flann::KNNResultSet res(1,pca_coeffs->data.fl,m_pca_dim_low); - //::flann::SearchParams params; + //::cvflann::KNNResultSet res(1,pca_coeffs->data.fl,m_pca_dim_low); + //::cvflann::SearchParams params; //params.checks = -1; //int maxDepth = 1000000; @@ -875,7 +875,7 @@ namespace cv{ object_ptr[i] = pca_coeffs->data.fl[i]; } - m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::flann::SearchParams(-1) ); + m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::cvflann::SearchParams(-1) ); desc_idx = ((int*)(m_indices.ptr(0)))[0] / m_pose_count; pose_idx = ((int*)(m_indices.ptr(0)))[0] % m_pose_count; @@ -1109,7 +1109,7 @@ namespace cv{ } #if defined(_KDTREE) - void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, + void FindOneWayDescriptorEx(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, float scale_min, float scale_max, float scale_step, int& desc_idx, int& pose_idx, float& distance, float& scale, @@ -1633,13 +1633,13 @@ namespace cv{ int pca_dim_low = this->GetDescriptor(0)->GetPCADimLow(); //if (!m_pca_descriptors_matrix) - // m_pca_descriptors_matrix = new ::flann::Matrix(n*m_pose_count,pca_dim_low); + // m_pca_descriptors_matrix = new ::cvflann::Matrix(n*m_pose_count,pca_dim_low); //else //{ // if ((m_pca_descriptors_matrix->cols != pca_dim_low)&&(m_pca_descriptors_matrix->rows != n*m_pose_count)) // { // delete m_pca_descriptors_matrix; - // m_pca_descriptors_matrix = new ::flann::Matrix(n*m_pose_count,pca_dim_low); + // m_pca_descriptors_matrix = new ::cvflann::Matrix(n*m_pose_count,pca_dim_low); // } //} @@ -1657,10 +1657,10 @@ namespace cv{ } cv::Mat pca_descriptors_mat(m_pca_descriptors_matrix,false); - //::flann::KDTreeIndexParams params; + //::cvflann::KDTreeIndexParams params; //params.trees = 1; //m_pca_descriptors_tree = new KDTree(pca_descriptors_mat); - m_pca_descriptors_tree = new cv::flann::Index(pca_descriptors_mat,cv::flann::KDTreeIndexParams(1)); + m_pca_descriptors_tree = new cv::cvflann::Index(pca_descriptors_mat,cv::cvflann::KDTreeIndexParams(1)); //cvReleaseMat(&m_pca_descriptors_matrix); //m_pca_descriptors_tree->buildIndex(); } diff --git a/samples/c/find_obj.cpp b/samples/c/find_obj.cpp index 8faa31dd9e..74bcbc901b 100644 --- a/samples/c/find_obj.cpp +++ b/samples/c/find_obj.cpp @@ -138,8 +138,8 @@ flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors, // find nearest neighbors using FLANN cv::Mat m_indices(objectDescriptors->total, 2, CV_32S); cv::Mat m_dists(objectDescriptors->total, 2, CV_32F); - cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4)); // using 4 randomized kdtrees - flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64) ); // maximum number of leafs checked + cv::cvflann::Index flann_index(m_image, cv::cvflann::KDTreeIndexParams(4)); // using 4 randomized kdtrees + flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::cvflann::SearchParams(64) ); // maximum number of leafs checked int* indices_ptr = m_indices.ptr(0); float* dists_ptr = m_dists.ptr(0); diff --git a/tests/cv/src/anearestneighbors.cpp b/tests/cv/src/anearestneighbors.cpp index 5bc9904d2f..a346d220bf 100644 --- a/tests/cv/src/anearestneighbors.cpp +++ b/tests/cv/src/anearestneighbors.cpp @@ -47,7 +47,7 @@ #include using namespace cv; -using namespace cv::flann; +using namespace cv::cvflann; //-------------------------------------------------------------------------------- class NearestNeighborTest : public CvTest