namespace cvflann
Overview
namespace cvflann { // namespaces namespace cvflann::anyimpl; namespace cvflann::lsh; // typedefs typedef std::map<cv::String, any> IndexParams; // enums enum { FLANN_CHECKS_UNLIMITED = -1, FLANN_CHECKS_AUTOTUNED = -2, }; enum flann_algorithm_t; enum flann_centers_init_t; enum flann_datatype_t; enum flann_distance_t; enum flann_log_level_t; // structs template <typename T> struct Accumulator; template <> struct Accumulator<unsigned char>; template <> struct Accumulator<short>; template <> struct Accumulator<char>; template <> struct Accumulator<unsigned short>; struct AutotunedIndexParams; template < typename T, typename DistanceType > struct BranchStruct; template <class T> struct ChiSquareDistance; struct CompositeIndexParams; template <> struct Datatype<unsigned char>; template <> struct Datatype<short>; template <> struct Datatype<unsigned short>; template <> struct Datatype<float>; template <typename T> struct Datatype; template <> struct Datatype<char>; template <> struct Datatype<double>; template <class T> struct Hamming; template <typename T> struct Hamming2; struct HammingLUT; template <class T> struct HellingerDistance; struct HierarchicalClusteringIndexParams; template <class T> struct HistIntersectionDistance; struct IndexHeader; struct KDTreeIndexParams; struct KDTreeSingleIndexParams; template <class T> struct KL_Divergence; struct KMeansIndexParams; template <class T> struct L1; template <class T> struct L2; template <class T> struct L2_Simple; struct LinearIndexParams; struct LshIndexParams; template <class T> struct MaxDistance; template <class T> struct MinkowskiDistance; struct SavedIndexParams; struct SearchParams; template <typename T> struct ZeroIterator; struct any; template <typename Distance> struct index_creator<False, False, Distance>; template < typename KDTreeCapability, typename VectorSpace, typename Distance > struct index_creator; template < typename VectorSpace, typename Distance > struct index_creator<False, VectorSpace, Distance>; template <typename ElementType> struct simpleDistance<MinkowskiDistance<ElementType>, ElementType>; template < typename Distance, typename ElementType > struct simpleDistance; template <typename ElementType> struct simpleDistance<L2<ElementType>, ElementType>; template <typename ElementType> struct simpleDistance<L2_Simple<ElementType>, ElementType>; template <typename ElementType> struct simpleDistance<HellingerDistance<ElementType>, ElementType>; template <typename ElementType> struct simpleDistance<ChiSquareDistance<ElementType>, ElementType>; template <typename ElementType> struct squareDistance<L2_Simple<ElementType>, ElementType>; template <typename ElementType> struct squareDistance<L2<ElementType>, ElementType>; template <typename ElementType> struct squareDistance<HellingerDistance<ElementType>, ElementType>; template <typename ElementType> struct squareDistance<ChiSquareDistance<ElementType>, ElementType>; template <typename ElementType> struct squareDistance<MinkowskiDistance<ElementType>, ElementType>; template < typename Distance, typename ElementType > struct squareDistance; // classes template <typename Distance> class AutotunedIndex; template <typename Distance> class CompositeIndex; class CreatorNotFound; class DynamicBitset; class FLANNException; class False; template <typename T> class Heap; template <typename Distance> class HierarchicalClusteringIndex; template <typename Distance> class Index; template <typename Distance> class KDTreeIndex; template <typename Distance> class KDTreeSingleIndex; template <typename Distance> class KMeansIndex; template <typename DistanceType> class KNNRadiusUniqueResultSet; template <typename DistanceType> class KNNResultSet; template <typename DistanceType> class KNNSimpleResultSet; template <typename DistanceType> class KNNUniqueResultSet; template <typename Distance> class LinearIndex; class Logger; template <typename Distance> class LshIndex; template <typename T> class Matrix; template <typename Distance> class NNIndex; template < typename BaseClass, typename UniqueIdType, typename ObjectCreator = BaseClass* (*)() > class ObjectFactory; class PooledAllocator; template <typename DistanceType> class RadiusResultSet; template <typename DistanceType> class RadiusUniqueResultSet; template <typename DistanceType> class ResultSet; class StartStopTimer; class True; class UniqueRandom; template <typename DistanceType> class UniqueResultSet; class UntypedMatrix; // global variables const size_t BLOCKSIZE; const size_t WORDSIZE; // global functions template <typename T> T abs(T x); double abs< double >(double x); float abs< float >(float x); template <typename T> void addValue( int pos, float val, float* vals, T* point, T* points, int n ); template <typename T> T* allocate(size_t count = 1); template <typename Distance> void compute_ground_truth( const Matrix<typename Distance::ElementType>& dataset, const Matrix<typename Distance::ElementType>& testset, Matrix<int>& matches, int skip = 0, Distance d = Distance() ); template <typename Distance> Distance::ResultType computeDistanceRaport( const Matrix<typename Distance::ElementType>& inputData, typename Distance::ElementType* target, int* neighbors, int* groundTruth, int veclen, int n, const Distance& distance ); int countCorrectMatches( int* neighbors, int* groundTruth, int n ); template <typename Distance> NNIndex<Distance>* create_index_by_type( const Matrix<typename Distance::ElementType>& dataset, const IndexParams& params, const Distance& distance ); void dummyfunc(); template <typename Distance> Distance::ResultType ensureSimpleDistance(typename Distance::ResultType dist); template <typename Distance> Distance::ResultType ensureSquareDistance(typename Distance::ResultType dist); template <typename Distance> void find_nearest( const Matrix<typename Distance::ElementType>& dataset, typename Distance::ElementType* query, int* matches, int nn, int skip = 0, Distance distance = Distance() ); flann_distance_t flann_distance_type(); template <typename T> T get_param( const IndexParams& params, cv::String name, const T& default_value ); template <typename T> T get_param( const IndexParams& params, cv::String name ); template <typename Distance> int hierarchicalClustering( const Matrix<typename Distance::ElementType>& points, Matrix<typename Distance::ResultType>& centers, const KMeansIndexParams& params, Distance d = Distance() ); template <typename T> void load_from_file( cvflann::Matrix<T>& dataset, const String& filename, const String& name ); IndexHeader load_header(FILE* stream); template <typename Distance> NNIndex<Distance>* load_saved_index( const Matrix<typename Distance::ElementType>& dataset, const cv::String& filename, Distance distance ); template <typename T> void load_value( FILE* stream, T& value, size_t count = 1 ); template <typename T> void load_value( FILE* stream, cvflann::Matrix<T>& value ); template <typename T> void load_value( FILE* stream, std::vector<T>& value ); void log_verbosity(int level); std::ostream& operator<<( std::ostream& out, const any& any_val ); template < typename T, typename F > float optimizeSimplexDownhill( T* points, int n, F func, float* vals = NULL ); void print_params( const IndexParams& params, std::ostream& stream ); void print_params(const IndexParams& params); int rand(); double rand_double( double high = 1.0, double low = 0 ); int rand_int( int high = RAND_MAX, int low = 0 ); template <typename T> Matrix<T> random_sample( Matrix<T>& srcMatrix, long size, bool remove = false ); template <typename T> Matrix<T> random_sample( const Matrix<T>& srcMatrix, size_t size ); template <typename Distance> void save_header( FILE* stream, const NNIndex<Distance>& index ); template <typename T> void save_to_file( const cvflann::Matrix<T>& dataset, const String& filename, const String& name ); template <typename T> void save_value( FILE* stream, const T& value, size_t count = 1 ); template <typename T> void save_value( FILE* stream, const cvflann::Matrix<T>& value ); template <typename T> void save_value( FILE* stream, const std::vector<T>& value ); template <typename Distance> float search_with_ground_truth( NNIndex<Distance>& index, const Matrix<typename Distance::ElementType>& inputData, const Matrix<typename Distance::ElementType>& testData, const Matrix<int>& matches, int nn, int checks, float& time, typename Distance::ResultType& dist, const Distance& distance, int skipMatches ); void seed_random(unsigned int seed); void set_distance_type( flann_distance_t distance_type, int order ); template <typename Distance> float test_index_checks( NNIndex<Distance>& index, const Matrix<typename Distance::ElementType>& inputData, const Matrix<typename Distance::ElementType>& testData, const Matrix<int>& matches, int checks, float& precision, const Distance& distance, int nn = 1, int skipMatches = 0 ); template <typename Distance> float test_index_precision( NNIndex<Distance>& index, const Matrix<typename Distance::ElementType>& inputData, const Matrix<typename Distance::ElementType>& testData, const Matrix<int>& matches, float precision, int& checks, const Distance& distance, int nn = 1, int skipMatches = 0 ); template <typename Distance> void test_index_precisions( NNIndex<Distance>& index, const Matrix<typename Distance::ElementType>& inputData, const Matrix<typename Distance::ElementType>& testData, const Matrix<int>& matches, float* precisions, int precisions_length, const Distance& distance, int nn = 1, int skipMatches = 0, float maxTime = 0 ); } // namespace cvflann
Detailed Documentation
Global Variables
const size_t WORDSIZE
Pooled storage allocator
The following routines allow for the efficient allocation of storage in small chunks from a specified pool. Rather than allowing each structure to be freed individually, an entire pool of storage is freed at once. This method has two advantages over just using malloc() and free(). First, it is far more efficient for allocating small objects, as there is no overhead for remembering all the information needed to free each object or consolidating fragmented memory. Second, the decision about how long to keep an object is made at the time of allocation, and there is no need to track down all the objects to free them.
Global Functions
template <typename T> void addValue( int pos, float val, float* vals, T* point, T* points, int n )
Adds val to array vals (and point to array points) and keeping the arrays sorted by vals.
template <typename T> T* allocate(size_t count = 1)
Allocates (using C’s malloc) a generic type T.
Params: count = number of instances to allocate. Returns: pointer (of type T*) to memory buffer
template <typename Distance> int hierarchicalClustering( const Matrix<typename Distance::ElementType>& points, Matrix<typename Distance::ResultType>& centers, const KMeansIndexParams& params, Distance d = Distance() )
Performs a hierarchical clustering of the points passed as argument and then takes a cut in the the clustering tree to return a flat clustering.
Parameters:
points | Points to be clustered |
centers | The computed cluster centres. Matrix should be preallocated and centers.rows is the number of clusters requested. |
params | Clustering parameters (The same as for cvflann::KMeansIndex) |
d | Distance to be used for clustering (eg: cvflann::L2) |
Returns:
number of clusters computed (can be different than clusters.rows and is the highest number of the form (branching-1)*K+1 smaller than clusters.rows).
IndexHeader load_header(FILE* stream)
Parameters:
stream |
|
Returns:
Index header
void log_verbosity(int level)
Sets the log level used for all flann functions
Parameters:
level | Verbosity level |
template < typename T, typename F > float optimizeSimplexDownhill( T* points, int n, F func, float* vals = NULL )
Simplex downhill optimization function. Preconditions: points is a 2D mattrix of size (n+1) x n func is the cost function taking n an array of n params and returning float vals is the cost function in the n+1 simplex points, if NULL it will be computed
Postcondition: returns optimum value and points[0..n] are the optimum parameters
double rand_double( double high = 1.0, double low = 0 )
Generates a random double value.
Parameters:
high | Upper limit |
low | Lower limit |
Returns:
Random double value
int rand_int( int high = RAND_MAX, int low = 0 )
Generates a random integer value.
Parameters:
high | Upper limit |
low | Lower limit |
Returns:
Random integer value
template <typename Distance> void save_header( FILE* stream, const NNIndex<Distance>& index )
Saves index header to stream
Parameters:
stream |
|
index |
|
void seed_random(unsigned int seed)
Seeds the random number generator
Parameters:
seed | Random seed |