提交 6fd82bc2 编写于 作者: M Marius Muja

Release 1.6

上级 ef572298
......@@ -8,7 +8,7 @@ project(flann)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
include(${PROJECT_SOURCE_DIR}/cmake/flann_utils.cmake)
set(FLANN_VERSION 1.5.0)
set(FLANN_VERSION 1.6.0)
DISSECT_VERSION()
GET_OS_INFO()
......
......@@ -16,7 +16,7 @@ Manual\\[1cm]}
\author{Marius Muja, mariusm@cs.ubc.ca\\David Lowe, lowe@cs.ubc.ca}
\date{September 26, 2009}
\date{November 26, 2009}
\begin{document}
......@@ -60,8 +60,7 @@ through the C, MATLAB and Python bindings provided with the library.
This section contains small examples of how to use the FLANN library from
different programming languages (C++, C, MATLAB and Python) and from the
command line.
different programming languages (C++, C, MATLAB and Python).
\begin{itemize}
......@@ -88,7 +87,7 @@ int main(int argc, char** argv)
flann::Matrix<float> dists(new float[query.rows*nn], query.rows, nn);
// construct an randomized kd-tree index using 4 kd-trees
flann::Index<float> index(dataset, flann::KDTreeIndexParams(4));
flann::Index<flann::L2<float> > index(dataset, flann::KDTreeIndexParams(4));
index.buildIndex();
// do a knn search, using 128 checks
......@@ -189,22 +188,6 @@ result,dists = flann.nn(dataset,testset,5,algorithm="kmeans",
branching=32, iterations=7, checks=16);
\end{Verbatim}
\item \textbf{Command line application}
\begin{Verbatim}[fontsize=\scriptsize,frame=single]
$ flann compute_nn --input-file=dataset.dat --test-file=testset.dat
--algorithm=kdtree --trees=8 --checks=64 --nn=5 --output-file=nn.dat
Reading input dataset from dataset.dat
Building index
Building index took: 0.76
Reading test dataset from testset.dat
Searching for nearest neighbors
Searching took 0.06 seconds
Writing matches to nn.dat
\end{Verbatim}
\end{itemize}
......@@ -270,25 +253,27 @@ types of nearest neighbor search indexes.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
namespace flann
{
template<typename T>
template<typename Distance>
class Index
{
typedef typename Distance::ElementType ElementType;
typedef typename Distance::ResultType DistanceType;
public:
Index(const Matrix<T>& features, const IndexParams& params);
Index(const Matrix<ElementType>& features, const IndexParams& params);
~Index();
void buildIndex();
void knnSearch(const Matrix<T>& queries,
void knnSearch(const Matrix<ElementType>& queries,
Matrix<int>& indices,
Matrix<float>& dists,
Matrix<DistanceType>& dists,
int knn,
const SearchParams& params);
int radiusSearch(const Matrix<T>& query,
int radiusSearch(const Matrix<ElementType>& query,
Matrix<int>& indices,
Matrix<float>& dists,
Matrix<DistanceType>& dists,
float radius,
const SearchParams& params);
......@@ -306,7 +291,7 @@ namespace flann
\textbf{flann::Index::Index}
Constructs a nearest neighbor search index for a given dataset.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
Index(const Matrix<T>& features, const IndexParams& params);
Index(const Matrix<ElementType>& features, const IndexParams& params);
\end{Verbatim}
\begin{description}
\item[features] Matrix containing the features(points) to index. The size of the matrix is $num\_features \times dimensionality$.
......@@ -437,9 +422,9 @@ exception of saved index type).
\subsubsection{flann::Index::knnSearch}
Performs a K-nearest neighbor search for a given query point using the index.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
void Index::knnSearch(const Matrix<T>& queries,
void Index::knnSearch(const Matrix<ElementType>& queries,
Matrix<int>& indices,
Matrix<float>& dists,
Matrix<DistanceType>& dists,
int knn,
const SearchParams& params);
\end{Verbatim}
......@@ -459,9 +444,9 @@ precision was also computed, in which case this parameter is ignored.}
\subsubsection{flann::Index::radiusSearch}
Performs a radius nearest neighbor search for a given query point.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
int Index::radiusSearch(const Matrix<T>& query,
int Index::radiusSearch(const Matrix<ElementType>& query,
Matrix<int>& indices,
Matrix<float>& dists,
Matrix<DistanceType>& dists,
float radius,
const SearchParams& params);
\end{Verbatim}
......@@ -485,39 +470,16 @@ Saves the index to a file.
\item[filename]{The file to save the index to}
\end{description}
\subsubsection{flann::set\_distance\_type}
\label{flann::setDistanceType}
This function chooses the distance function to use when computing distances between
data points.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
void set_distance_type(flann_distance_t distance_type, int order);
\end{Verbatim}
\begin{description}
\item[distance\_type] The distance type to use. Possible values are
\begin{Verbatim}[fontsize=\footnotesize]
enum flann_distance_t {
EUCLIDEAN = 1, // squared euclidean distance
MANHATTAN = 2,
MINKOWSKI = 3,
MAX_DIST = 4, // L_infinity - not valid for kd-tree index type
HIK = 5,
HELLINGER = 6,
CS = 7, // chi-square
KL = 8, // kullback-leibler divergence
};
\end{Verbatim}
\item[order] Used in for the \texttt{MINKOWSKI} distance type, to choose the order of the Minkowski distance.
\end{description}
\subsubsection{flann::hierarchicalClustering}
\label{flann::hierarchicalClustering}
Clusters the given points by constructing a hierarchical k-means tree and choosing a cut in the tree that minimizes the clusters' variance.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
template <typename ELEM_TYPE, typename DIST_TYPE>
int hierarchicalClustering(const Matrix<ELEM_TYPE>& features,
Matrix<DIST_TYPE>& centers, const KMeansIndexParams& params)
template <typename Distance>
int hierarchicalClustering(const Matrix<typename Distance::ElementType>& features,
Matrix<typename Distance::ResultType>& centers,
const KMeansIndexParams& params,
Distance d = Distance())
\end{Verbatim}
\begin{description}
\item[features]{The points to be clustered}
......@@ -751,11 +713,29 @@ This function deletes a previously constructed index and frees all the memory
used by it.
\subsubsection{flann\_set\_distance\_type}
\label{flann::setDistanceType}
This function chooses the distance function to use when computing distances between
data points (see \ref{flann::setDistanceType}).
data points.
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
void flann_set_distance_type(enum flann_distance_t distance_type, int order);
\end{Verbatim}
\begin{description}
\item[distance\_type] The distance type to use. Possible values are
\begin{Verbatim}[fontsize=\footnotesize]
enum flann_distance_t {
EUCLIDEAN = 1, // squared euclidean distance
MANHATTAN = 2,
MINKOWSKI = 3,
HIK = 5,
HELLINGER = 6,
CS = 7, // chi-square
KL = 8, // kullback-leibler divergence
};
\end{Verbatim}
\item[order] Used in for the \texttt{MINKOWSKI} distance type, to choose the order of the Minkowski distance.
\end{description}
\subsubsection{flann\_compute\_cluster\_centers()}
......@@ -1179,76 +1159,6 @@ See section \ref{sec:quickstart} for an example of how to use the Python
bindings.
\subsection{Using the \texttt{flann} command line application}
The FLANN distribution also contains a command line application that can be
used to perform nearest-neighbor searches using datasets stored in files. The
application can read datasets stored in CSV format, space-separated values or
raw binary format.
The command line application takes a command name as the first argument and
then the arguments for that command:
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
$ flann
Usage: flann.py [command commans_args]
Comamnds:
generate_random
compute_gt
compute_nn
autotune
sample_dataset
cluster
run_test
For command specific help type: flann.py <command> -h
\end{Verbatim}
To see the possible arguments for each command, use \texttt{flann help
<command>}. For example:
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
$ flann run_test -h
Usage: flann.py [command command_args]
Options:
-h, --help show this help message and exit
-i FILE, --input-file=FILE
Name of file with input dataset
-a ALGORITHM, --algorithm=ALGORITHM
The algorithm to use when constructing the index
(kdtree, kmeans...)
-r TREES, --trees=TREES
Number of parallel trees to use (where available, for
example kdtree)
-b BRANCHING, --branching=BRANCHING
Branching factor (where applicable, for example
kmeans) (default: 2)
-C CENTERS_INIT, --centers-init=CENTERS_INIT
How to choose the initial cluster centers for kmeans
(random, gonzales) (default: random)
-M MAX_ITERATIONS, --max-iterations=MAX_ITERATIONS
Max iterations to perform for kmeans (default: until
convergence)
-l LOG_LEVEL, --log-level=LOG_LEVEL
Log level (none < fatal < error < warning < info)
(Default: info)
-t FILE, --test-file=FILE
Name of file with test dataset
-m FILE, --match-file=FILE
File with ground truth matches
-n NN, --nn=NN Number of nearest neighbors to search for
-c CHECKS, --checks=CHECKS
Number of times to restart search (in best-bin-first
manner)
-P PRECISION, --precision=PRECISION
Run the test until reaching this precision
-K NUM, --skip-matches=NUM
Skip the first NUM matches at test phase
\end{Verbatim}
\bibliographystyle{alpha}
\bibliography{references}
......
......@@ -95,7 +95,7 @@ flann_index_t __flann_build_index(typename Distance::ElementType* dataset, int r
index_params->toParameters(*flann_params);
if (index->getIndex()->getType()==AUTOTUNED) {
AutotunedIndex<T>* autotuned_index = (AutotunedIndex<T>*)index->getIndex();
AutotunedIndex<Distance>* autotuned_index = (AutotunedIndex<Distance>*)index->getIndex();
flann_params->checks = autotuned_index->getSearchParameters()->checks;
*speedup = autotuned_index->getSpeedup();
}
......@@ -762,4 +762,3 @@ EXPORTED int flann_compute_cluster_centers_int(int* dataset, int rows, int cols,
return _flann_compute_cluster_centers(dataset, rows, cols, clusters, result, flann_params);
}
}
......@@ -259,7 +259,7 @@ int Index<Distance>::veclen() const
template <typename Distance>
int hierarchicalClustering(const Matrix<typename Distance::ElementType>& features, Matrix<typename Distance::ResultType>& centers,
const KMeansIndexParams& params, Distance d)
const KMeansIndexParams& params, Distance d = Distance())
{
KMeansIndex<Distance> kmeans(features, params, d);
kmeans.buildIndex();
......
......@@ -34,7 +34,7 @@ namespace flann
{
const char FLANN_SIGNATURE[] = "FLANN_INDEX";
const char FLANN_VERSION[] = "1.5.0";
const char FLANN_VERSION[] = "1.6.0";
IndexHeader load_header(FILE* stream)
......
......@@ -353,58 +353,6 @@ flannlib.flann_free_index_%(C)s.argtypes = [
flann.free_index[%(numpy)s] = flannlib.flann_free_index_%(C)s
""")
flannlib.compute_ground_truth_float.restype = None
flannlib.compute_ground_truth_float.argtypes = [
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # dataset
c_int, # dshape
c_int,
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # testset
c_int, # tshape
c_int,
ndpointer(int32, ndim = 2, flags='aligned, c_contiguous, writeable'), # matches
c_int, # mshape
c_int,
c_int # skip
]
flannlib.test_with_precision.restype = c_float
flannlib.test_with_precision.argtypes = [
FLANN_INDEX,
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # dataset
c_int, # dshape
c_int,
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # testset
c_int, # tshape
c_int,
ndpointer(int32, ndim = 2, flags='aligned, c_contiguous'), # matches
c_int, # mshape
c_int,
c_int, # nn
c_float, #precision
POINTER(c_int), # checks
c_int # skip
]
flannlib.test_with_checks.restype = c_float
flannlib.test_with_checks.argtypes = [
FLANN_INDEX,
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # dataset
c_int, # dshape
c_int,
ndpointer(float32, ndim = 2, flags='aligned, c_contiguous'), # testset
c_int, # tshape
c_int,
ndpointer(int32, ndim = 2, flags='aligned, c_contiguous'), # matches
c_int, # mshape
c_int,
c_int, # nn
c_int, # checks
POINTER(c_float), #precision
c_int # skip
]
def ensure_2d_array(array, flags, **kwargs):
array = require(array, requirements = flags, **kwargs)
......
......@@ -8,13 +8,14 @@ setup_path = os.path.dirname(os.path.abspath(sys.argv[0]))
lib_path = os.path.abspath(os.path.join(setup_path,'../../../lib'))
setup(name='flann',
version='1.5.0',
version='1.6.0',
description='Fast Library for Approximate Nearest Neighbors',
author='Marius Muja',
author_email='mariusm@cs.ubc.ca',
license='BSD',
url='http://www.cs.ubc.ca/~mariusm/flann/',
packages=['pyflann', 'pyflann.io', 'pyflann.bindings', 'pyflann.util', 'pyflann.lib'],
packages=['pyflann','pyflann.command', 'pyflann.io', 'pyflann.bindings', 'pyflann.util', 'pyflann.lib'],
scripts=['flann'],
package_dir={'pyflann.lib':lib_path},
package_data={'pyflann.lib': ['libflann.so','flann.dll', 'libflann.dylib']},
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册