renamed cv::flann to cv::cvflann to avoid name conflicts

pull/13383/head
Vadim Pisarevsky 15 years ago
parent 60019422e8
commit b94e09bfeb
  1. 2
      3rdparty/flann/algorithms/autotuned_index.h
  2. 2
      3rdparty/flann/algorithms/composite_index.h
  3. 2
      3rdparty/flann/algorithms/dist.cpp
  4. 2
      3rdparty/flann/algorithms/dist.h
  5. 2
      3rdparty/flann/algorithms/kdtree_index.h
  6. 2
      3rdparty/flann/algorithms/kmeans_index.h
  7. 2
      3rdparty/flann/algorithms/linear_index.h
  8. 2
      3rdparty/flann/algorithms/nn_index.h
  9. 4
      3rdparty/flann/flann.cpp
  10. 2
      3rdparty/flann/flann.hpp
  11. 2
      3rdparty/flann/nn/ground_truth.h
  12. 2
      3rdparty/flann/nn/index_testing.cpp
  13. 2
      3rdparty/flann/nn/index_testing.h
  14. 2
      3rdparty/flann/nn/simplex_downhill.h
  15. 2
      3rdparty/flann/util/allocator.h
  16. 2
      3rdparty/flann/util/common.h
  17. 2
      3rdparty/flann/util/heap.h
  18. 2
      3rdparty/flann/util/logger.cpp
  19. 2
      3rdparty/flann/util/logger.h
  20. 2
      3rdparty/flann/util/matrix.h
  21. 2
      3rdparty/flann/util/object_factory.h
  22. 2
      3rdparty/flann/util/random.cpp
  23. 2
      3rdparty/flann/util/random.h
  24. 2
      3rdparty/flann/util/result_set.h
  25. 2
      3rdparty/flann/util/saving.cpp
  26. 2
      3rdparty/flann/util/saving.h
  27. 2
      3rdparty/flann/util/timer.h
  28. 2
      3rdparty/include/flann/common.h
  29. 2
      3rdparty/include/flann/flann.hpp
  30. 2
      3rdparty/include/flann/matrix.h
  31. 2
      3rdparty/include/flann/random.h
  32. 18
      doc/cxcore_clustering_search.tex
  33. 79
      modules/core/include/opencv2/core/core.hpp
  34. 20
      modules/core/include/opencv2/core/flann.hpp
  35. 88
      modules/core/src/flann.cpp
  36. 2
      modules/features2d/include/opencv2/features2d/features2d.hpp
  37. 22
      modules/features2d/src/oneway.cpp
  38. 4
      samples/c/find_obj.cpp
  39. 2
      tests/cv/src/anearestneighbors.cpp

@ -36,7 +36,7 @@
#include "ground_truth.h"
#include "index_testing.h"
namespace flann
namespace cvflann
{
class AutotunedIndex : public NNIndex

@ -34,7 +34,7 @@
#include "constants.h"
#include "nn_index.h"
namespace flann
namespace cvflann
{
class CompositeIndex : public NNIndex

@ -30,7 +30,7 @@
#include "dist.h"
namespace flann
namespace cvflann
{
/** Global variable indicating the distance metric

@ -36,7 +36,7 @@ using namespace std;
#include "constants.h"
namespace flann
namespace cvflann
{
/**

@ -48,7 +48,7 @@
using namespace std;
namespace flann
namespace cvflann
{

@ -50,7 +50,7 @@
using namespace std;
namespace flann
namespace cvflann
{
/**

@ -34,7 +34,7 @@
#include "constants.h"
#include "nn_index.h"
namespace flann
namespace cvflann
{
class LinearIndex : public NNIndex {

@ -41,7 +41,7 @@
using namespace std;
namespace flann
namespace cvflann
{
class ResultSet;

@ -58,7 +58,7 @@ using namespace std;
#endif
namespace flann
namespace cvflann
{
typedef ObjectFactory<IndexParams, flann_algorithm_t> ParamsFactory;
@ -224,7 +224,7 @@ int hierarchicalClustering(const Matrix<float>& features, Matrix<float>& centers
using namespace flann;
using namespace cvflann;
typedef NNIndex* NNIndexPtr;
typedef Matrix<float>* MatrixPtr;

@ -40,7 +40,7 @@
#include "flann.h"
namespace flann
namespace cvflann
{
class NNIndex;

@ -34,7 +34,7 @@
#include "matrix.h"
#include "dist.h"
namespace flann
namespace cvflann
{
template <typename T>

@ -40,7 +40,7 @@
#include <string.h>
#include <stdlib.h>
namespace flann
namespace cvflann
{
const float SEARCH_EPS = 0.001f;

@ -38,7 +38,7 @@
using namespace std;
namespace flann
namespace cvflann
{
void search_for_neighbors(NNIndex& index, const Matrix<float>& testset, Matrix<int>& result, Matrix<float>& dists, const SearchParams &searchParams, int skip = 0);

@ -31,7 +31,7 @@
#ifndef SIMPLEX_DOWNHILL_H
#define SIMPLEX_DOWNHILL_H
namespace flann
namespace cvflann
{
/**

@ -35,7 +35,7 @@
#include <stdio.h>
namespace flann
namespace cvflann
{
/**

@ -36,7 +36,7 @@
#include <stdexcept>
namespace flann
namespace cvflann
{
class FLANNException : public std::runtime_error {
public:

@ -35,7 +35,7 @@
#include <algorithm>
using namespace std;
namespace flann
namespace cvflann
{
/**

@ -36,7 +36,7 @@
using namespace std;
namespace flann
namespace cvflann
{
Logger logger;

@ -39,7 +39,7 @@
using namespace std;
namespace flann
namespace cvflann
{
class Logger

@ -35,7 +35,7 @@
#include <random.h>
namespace flann
namespace cvflann
{
/**
* Class implementing a generic rectangular dataset.

@ -33,7 +33,7 @@
#include <map>
namespace flann
namespace cvflann
{
template<typename BaseClass, typename DerivedClass>

@ -31,7 +31,7 @@
#include "random.h"
namespace flann
namespace cvflann
{
void seed_random(unsigned int seed)

@ -37,7 +37,7 @@
using namespace std;
namespace flann
namespace cvflann
{
/**

@ -40,7 +40,7 @@
using namespace std;
namespace flann
namespace cvflann
{
/* This record represents a branch point when finding neighbors in

@ -33,7 +33,7 @@
#include "nn_index.h"
#include <cstdio>
namespace flann
namespace cvflann
{
const char FLANN_SIGNATURE[] = "FLANN_INDEX";

@ -35,7 +35,7 @@
#include "nn_index.h"
namespace flann
namespace cvflann
{
/**

@ -34,7 +34,7 @@
#include <time.h>
namespace flann
namespace cvflann
{
/**

@ -36,7 +36,7 @@
#include <stdexcept>
namespace flann
namespace cvflann
{
class FLANNException : public std::runtime_error {
public:

@ -40,7 +40,7 @@
#include "flann.h"
namespace flann
namespace cvflann
{
class NNIndex;

@ -35,7 +35,7 @@
#include "random.h"
namespace flann
namespace cvflann
{
/**
* Class implementing a generic rectangular dataset.

@ -37,7 +37,7 @@
using namespace std;
namespace flann
namespace cvflann
{
/**

@ -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<float>\& query, \par
vector<int>\& 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<float>\& query, \par
vector<int>\& 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);}

@ -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<typename _Tp> static inline void deallocate(_Tp* ptr, size_t)
}
/*!
\fn template<typename _Tp> 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<typename _Tp> 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,

@ -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);

@ -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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(0));
// TODO: fix ::cvflann::Matrix class so it can be constructed with a const float*
::cvflann::Matrix<float> mat(dataset.rows, dataset.cols, (float*)dataset.ptr<float>(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<float>& query, vector<int>& indices, vector<float>& dists, int knn, const SearchParams& searchParams)
{
::flann::Matrix<float> m_query(1, query.size(), (float*)&query[0]);
::flann::Matrix<int> m_indices(1, indices.size(), &indices[0]);
::flann::Matrix<float> m_dists(1, dists.size(), &dists[0]);
::cvflann::Matrix<float> m_query(1, query.size(), (float*)&query[0]);
::cvflann::Matrix<int> m_indices(1, indices.size(), &indices[0]);
::cvflann::Matrix<float> 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<float> m_queries(queries.rows, queries.cols, (float*)queries.ptr<float>(0));
::cvflann::Matrix<float> m_queries(queries.rows, queries.cols, (float*)queries.ptr<float>(0));
CV_Assert(indices.type() == CV_32S);
CV_Assert(indices.isContinuous());
::flann::Matrix<int> m_indices(indices.rows, indices.cols, (int*)indices.ptr<int>(0));
::cvflann::Matrix<int> m_indices(indices.rows, indices.cols, (int*)indices.ptr<int>(0));
CV_Assert(dists.type() == CV_32F);
CV_Assert(dists.isContinuous());
::flann::Matrix<float> m_dists(dists.rows, dists.cols, (float*)dists.ptr<float>(0));
::cvflann::Matrix<float> m_dists(dists.rows, dists.cols, (float*)dists.ptr<float>(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<float>& query, vector<int>& indices, vector<float>& dists, float radius, const SearchParams& searchParams)
{
::flann::Matrix<float> m_query(1, query.size(), (float*)&query[0]);
::flann::Matrix<int> m_indices(1, indices.size(), &indices[0]);
::flann::Matrix<float> m_dists(1, dists.size(), &dists[0]);
::cvflann::Matrix<float> m_query(1, query.size(), (float*)&query[0]);
::cvflann::Matrix<int> m_indices(1, indices.size(), &indices[0]);
::cvflann::Matrix<float> 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<float> m_query(query.rows, query.cols, (float*)query.ptr<float>(0));
::cvflann::Matrix<float> m_query(query.rows, query.cols, (float*)query.ptr<float>(0));
CV_Assert(indices.type() == CV_32S);
CV_Assert(indices.isContinuous());
::flann::Matrix<int> m_indices(indices.rows, indices.cols, (int*)indices.ptr<int>(0));
::cvflann::Matrix<int> m_indices(indices.rows, indices.cols, (int*)indices.ptr<int>(0));
CV_Assert(dists.type() == CV_32F);
CV_Assert(dists.isContinuous());
::flann::Matrix<float> m_dists(dists.rows, dists.cols, (float*)dists.ptr<float>(0));
::cvflann::Matrix<float> m_dists(dists.rows, dists.cols, (float*)dists.ptr<float>(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<float> m_features(features.rows, features.cols, (float*)features.ptr<float>(0));
::cvflann::Matrix<float> m_features(features.rows, features.cols, (float*)features.ptr<float>(0));
CV_Assert(features.type() == CV_32F);
CV_Assert(features.isContinuous());
::flann::Matrix<float> m_centers(centers.rows, centers.cols, (float*)centers.ptr<float>(0));
::cvflann::Matrix<float> m_centers(centers.rows, centers.cols, (float*)centers.ptr<float>(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));
}

@ -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

@ -149,7 +149,7 @@ namespace cv{
std::vector<int>& desc_idxs, std::vector<int>& pose_idxs, std::vector<float>& 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<float>& distances, std::vector<float>& 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<int>(0)))[0] / m_pose_count;
pose_idx = ((int*)(m_indices.ptr<int>(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<float>(n*m_pose_count,pca_dim_low);
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(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<float>(n*m_pose_count,pca_dim_low);
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(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();
}

@ -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<int>(0);
float* dists_ptr = m_dists.ptr<float>(0);

@ -47,7 +47,7 @@
#include <iostream>
using namespace cv;
using namespace cv::flann;
using namespace cv::cvflann;
//--------------------------------------------------------------------------------
class NearestNeighborTest : public CvTest

Loading…
Cancel
Save