Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PointCloud
Flann
提交
026ab986
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,发现更多精彩内容 >>
提交
026ab986
编写于
10月 05, 2011
作者:
M
Marius Muja
浏览文件
操作
浏览文件
下载
差异文件
Merge ec2-107-20-88-134.compute-1.amazonaws.com:flann
上级
bfe995c1
fd7cfc82
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
42 deletion
+48
-42
examples/flann_example_mpi.cpp
examples/flann_example_mpi.cpp
+37
-31
src/cpp/flann/flann_mpi.hpp
src/cpp/flann/flann_mpi.hpp
+4
-7
src/cpp/flann/io/hdf5.h
src/cpp/flann/io/hdf5.h
+2
-4
src/python/pyflann/bindings/flann_ctypes.py
src/python/pyflann/bindings/flann_ctypes.py
+5
-0
未找到文件。
examples/flann_example_mpi.cpp
浏览文件 @
026ab986
#include <flann/flann_mpi.hpp>
#include <flann/flann.hpp>
#include <flann/io/hdf5.h>
#include <stdio.h>
...
...
@@ -48,43 +49,48 @@ int main(int argc, char** argv)
boost
::
mpi
::
environment
env
(
argc
,
argv
);
boost
::
mpi
::
communicator
world
;
int
nn
=
1
;
int
nn
=
1
;
// flann::Matrix<float> dataset;
flann
::
Matrix
<
float
>
query
;
flann
::
Matrix
<
int
>
match
;
//flann::Matrix<float> dataset;
flann
::
Matrix
<
float
>
query
;
flann
::
Matrix
<
int
>
match
;
flann
::
Matrix
<
float
>
gt_dists
;
IF_RANK0
start_timer
(
"Loading data...
\n
"
);
flann
::
load_from_file
(
query
,
"sift100K.h5"
,
"query"
);
flann
::
load_from_file
(
match
,
"sift100K.h5"
,
"match"
);
flann
::
Matrix
<
int
>
indices
(
new
int
[
query
.
rows
*
nn
],
query
.
rows
,
nn
);
flann
::
Matrix
<
float
>
dists
(
new
float
[
query
.
rows
*
nn
],
query
.
rows
,
nn
);
IF_RANK0
start_timer
(
"Loading data...
\n
"
);
//flann::load_from_file(dataset, "sift100K.h5","dataset");
flann
::
load_from_file
(
query
,
"sift100K.h5"
,
"query"
);
flann
::
load_from_file
(
match
,
"sift100K.h5"
,
"match"
);
flann
::
load_from_file
(
gt_dists
,
"sift100K.h5"
,
"dists"
);
flann
::
Matrix
<
int
>
indices
(
new
int
[
query
.
rows
*
nn
],
query
.
rows
,
nn
);
flann
::
Matrix
<
float
>
dists
(
new
float
[
query
.
rows
*
nn
],
query
.
rows
,
nn
);
// construct an randomized kd-tree index using 4 kd-trees
flann
::
mpi
::
Index
<
flann
::
L2
<
float
>
>
index
(
"sift100K.h5"
,
"dataset"
,
flann
::
KDTreeIndexParams
(
4
));
IF_RANK0
printf
(
"Loading data done (%g seconds)
\n
"
,
stop_timer
());
// construct an randomized kd-tree index using 4 kd-trees
flann
::
mpi
::
Index
<
flann
::
L2
<
float
>
>
index
(
"sift100K.h5"
,
"dataset"
,
flann
::
KDTreeIndexParams
(
4
));
//flann::Index<flann::L2<float> > index( dataset, flann::KDTreeIndexParams(4));
IF_RANK0
printf
(
"Loading data done (%g seconds)
\n
"
,
stop_timer
());
IF_RANK0
printf
(
"Index size: (%d,%d)
\n
"
,
index
.
size
(),
index
.
veclen
());
IF_RANK0
printf
(
"Index size: (%d,%d)
\n
"
,
index
.
size
(),
index
.
veclen
());
start_timer
(
"Building index...
\n
"
);
index
.
buildIndex
();
start_timer
(
"Building index...
\n
"
);
index
.
buildIndex
();
printf
(
"Building index done (%g seconds)
\n
"
,
stop_timer
());
world
.
barrier
();
// do a knn search, using 128 checks
// do a knn search, using 128 checks
IF_RANK0
start_timer
(
"Performing search...
\n
"
);
index
.
knnSearch
(
query
,
indices
,
dists
,
nn
,
flann
::
SearchParams
(
128
));
IF_RANK0
printf
(
"Search done (%g seconds)
\n
"
,
stop_timer
());
IF_RANK0
{
printf
(
"Indices size: (%d,%d)
\n
"
,
indices
.
rows
,
indices
.
cols
);
printf
(
"Checking results
\n
"
);
float
precision
=
compute_precision
(
match
,
indices
);
printf
(
"Precision is: %g
\n
"
,
precision
);
}
delete
[]
query
.
data
;
delete
[]
indices
.
data
;
delete
[]
dists
.
data
;
delete
[]
match
.
data
;
return
0
;
index
.
knnSearch
(
query
,
indices
,
dists
,
nn
,
flann
::
SearchParams
(
128
));
IF_RANK0
printf
(
"Search done (%g seconds)
\n
"
,
stop_timer
());
IF_RANK0
{
printf
(
"Indices size: (%d,%d)
\n
"
,
(
int
)
indices
.
rows
,
(
int
)
indices
.
cols
);
printf
(
"Checking results
\n
"
);
float
precision
=
compute_precision
(
match
,
indices
);
printf
(
"Precision is: %g
\n
"
,
precision
);
}
delete
[]
query
.
data
;
delete
[]
indices
.
data
;
delete
[]
dists
.
data
;
delete
[]
match
.
data
;
return
0
;
}
src/cpp/flann/flann_mpi.hpp
浏览文件 @
026ab986
...
...
@@ -52,6 +52,7 @@ struct SearchResults
ar
&
indices
.
rows
;
ar
&
indices
.
cols
;
if
(
Archive
::
is_loading
::
value
)
{
indices
.
stride
=
indices
.
cols
;
indices
.
data
=
new
int
[
indices
.
rows
*
indices
.
cols
];
}
ar
&
boost
::
serialization
::
make_array
(
indices
.
data
,
indices
.
rows
*
indices
.
cols
);
...
...
@@ -61,6 +62,7 @@ struct SearchResults
ar
&
dists
.
rows
;
ar
&
dists
.
cols
;
if
(
Archive
::
is_loading
::
value
)
{
dists
.
stride
=
dists
.
cols
;
dists
.
data
=
new
DistanceType
[
dists
.
rows
*
dists
.
cols
];
}
ar
&
boost
::
serialization
::
make_array
(
dists
.
data
,
dists
.
rows
*
dists
.
cols
);
...
...
@@ -76,12 +78,8 @@ struct ResultsMerger
SearchResults
<
DistanceType
>
operator
()(
SearchResults
<
DistanceType
>
a
,
SearchResults
<
DistanceType
>
b
)
{
SearchResults
<
DistanceType
>
results
;
results
.
indices
.
rows
=
a
.
indices
.
rows
;
results
.
indices
.
cols
=
a
.
indices
.
cols
;
results
.
indices
.
data
=
new
int
[
results
.
indices
.
rows
*
results
.
indices
.
cols
];
results
.
dists
.
rows
=
a
.
dists
.
rows
;
results
.
dists
.
cols
=
a
.
dists
.
cols
;
results
.
dists
.
data
=
new
DistanceType
[
results
.
dists
.
rows
*
results
.
dists
.
cols
];
results
.
indices
=
flann
::
Matrix
<
int
>
(
new
int
[
a
.
indices
.
rows
*
a
.
indices
.
cols
],
a
.
indices
.
rows
,
a
.
indices
.
cols
);
results
.
dists
=
flann
::
Matrix
<
DistanceType
>
(
new
DistanceType
[
a
.
dists
.
rows
*
a
.
dists
.
cols
],
a
.
dists
.
rows
,
a
.
dists
.
cols
);
for
(
size_t
i
=
0
;
i
<
results
.
dists
.
rows
;
++
i
)
{
...
...
@@ -103,7 +101,6 @@ struct ResultsMerger
}
}
}
delete
[]
a
.
indices
.
data
;
delete
[]
a
.
dists
.
data
;
delete
[]
b
.
indices
.
data
;
...
...
src/cpp/flann/io/hdf5.h
浏览文件 @
026ab986
...
...
@@ -211,13 +211,11 @@ void load_from_file(flann::Matrix<T>& dataset, const std::string& filename, cons
H5Sselect_hyperslab
(
space_id
,
H5S_SELECT_SET
,
offset
,
NULL
,
count
,
NULL
);
dataset
.
rows
=
count
[
0
];
dataset
.
cols
=
count
[
1
];
dataset
.
data
=
new
T
[
dataset
.
rows
*
dataset
.
cols
];
dataset
=
flann
::
Matrix
<
T
>
(
new
T
[
count
[
0
]
*
count
[
1
]],
count
[
0
],
count
[
1
]);
plist_id
=
H5Pcreate
(
H5P_DATASET_XFER
);
H5Pset_dxpl_mpio
(
plist_id
,
H5FD_MPIO_COLLECTIVE
);
status
=
H5Dread
(
dataset_id
,
get_hdf5_type
<
T
>
(),
memspace_id
,
space_id
,
plist_id
,
dataset
.
data
);
status
=
H5Dread
(
dataset_id
,
get_hdf5_type
<
T
>
(),
memspace_id
,
space_id
,
plist_id
,
dataset
[
0
]
);
CHECK_ERROR
(
status
,
"Error reading dataset"
);
H5Pclose
(
plist_id
);
...
...
src/python/pyflann/bindings/flann_ctypes.py
浏览文件 @
026ab986
...
...
@@ -146,6 +146,11 @@ def load_flann_library():
return
flannlib
except
Exception
,
e
:
pass
try
:
flannlib
=
cdll
[
os
.
path
.
join
(
root_dir
,
"build"
,
libdir
,
libname
)]
return
flannlib
except
Exception
,
e
:
pass
tmp
=
os
.
path
.
dirname
(
root_dir
)
if
tmp
==
root_dir
:
root_dir
=
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录