Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PointCloud
Flann
提交
6fd82bc2
F
Flann
项目概览
PointCloud
/
Flann
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flann
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6fd82bc2
编写于
11月 26, 2010
作者:
M
Marius Muja
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Release 1.6
上级
ef572298
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
47 addition
and
189 deletion
+47
-189
CMakeLists.txt
CMakeLists.txt
+1
-1
doc/manual.tex
doc/manual.tex
+40
-130
src/cpp/flann/flann.cpp
src/cpp/flann/flann.cpp
+1
-2
src/cpp/flann/flann.hpp
src/cpp/flann/flann.hpp
+1
-1
src/cpp/flann/util/saving.cpp
src/cpp/flann/util/saving.cpp
+1
-1
src/python/pyflann/bindings/flann_ctypes.py
src/python/pyflann/bindings/flann_ctypes.py
+0
-52
src/python/setup.py
src/python/setup.py
+3
-2
未找到文件。
CMakeLists.txt
浏览文件 @
6fd82bc2
...
...
@@ -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
()
...
...
doc/manual.tex
浏览文件 @
6fd82bc2
...
...
@@ -16,7 +16,7 @@ Manual\\[1cm]}
\author
{
Marius Muja, mariusm@cs.ubc.ca
\\
David Lowe, lowe@cs.ubc.ca
}
\date
{
Sept
ember 26, 2009
}
\date
{
Nov
ember 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<fl
oat
> index(dataset, flann::KDTreeIndexParams(4));
flann::Index<fl
ann::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
}
...
...
src/cpp/flann/flann.cpp
浏览文件 @
6fd82bc2
...
...
@@ -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
);
}
}
src/cpp/flann/flann.hpp
浏览文件 @
6fd82bc2
...
...
@@ -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
();
...
...
src/cpp/flann/util/saving.cpp
浏览文件 @
6fd82bc2
...
...
@@ -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
)
...
...
src/python/pyflann/bindings/flann_ctypes.py
浏览文件 @
6fd82bc2
...
...
@@ -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
)
...
...
src/python/setup.py
浏览文件 @
6fd82bc2
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录