Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
za0612
pcl
提交
a0f2e5ad
P
pcl
项目概览
za0612
/
pcl
与 Fork 源项目一致
从无法访问的项目Fork
通知
13
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pcl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a0f2e5ad
编写于
2月 09, 2020
作者:
M
Markus Vieth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test for SAC model normal plane SIMD implementations
上级
d73e3c98
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
0 deletion
+79
-0
test/sample_consensus/test_sample_consensus_plane_models.cpp
test/sample_consensus/test_sample_consensus_plane_models.cpp
+79
-0
未找到文件。
test/sample_consensus/test_sample_consensus_plane_models.cpp
浏览文件 @
a0f2e5ad
...
...
@@ -366,6 +366,85 @@ TEST (SampleConsensusModelPlane, SIMD_countWithinDistance) // Test if all countW
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
template
<
typename
PointT
,
typename
PointNT
>
class
SampleConsensusModelNormalPlaneTest
:
private
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>
{
public:
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
SampleConsensusModelNormalPlane
;
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
setNormalDistanceWeight
;
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
setInputNormals
;
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
countWithinDistanceStandard
;
#if defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
countWithinDistanceSSE
;
#endif
#if defined (__AVX__) && defined (__AVX2__)
using
SampleConsensusModelNormalPlane
<
PointT
,
PointNT
>::
countWithinDistanceAVX
;
#endif
};
TEST
(
SampleConsensusModelNormalPlane
,
SIMD_countWithinDistance
)
// Test if all countWithinDistance implementations return the same value
{
const
auto
seed
=
static_cast
<
unsigned
>
(
std
::
time
(
nullptr
));
srand
(
seed
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
// Run as often as you like
{
// Generate a cloud with 10000 random points
PointCloud
<
PointXYZ
>
cloud
;
PointCloud
<
Normal
>
normal_cloud
;
std
::
vector
<
int
>
indices
;
cloud
.
points
.
resize
(
10000
);
normal_cloud
.
resize
(
10000
);
for
(
std
::
size_t
idx
=
0
;
idx
<
cloud
.
size
();
++
idx
)
{
cloud
.
points
[
idx
].
x
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
cloud
.
points
[
idx
].
y
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
cloud
.
points
[
idx
].
z
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
const
double
a
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
const
double
b
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
const
double
c
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
const
double
factor
=
1.0
/
sqrt
(
a
*
a
+
b
*
b
+
c
*
c
);
normal_cloud
.
points
[
idx
].
normal
[
0
]
=
a
*
factor
;
normal_cloud
.
points
[
idx
].
normal
[
1
]
=
b
*
factor
;
normal_cloud
.
points
[
idx
].
normal
[
2
]
=
c
*
factor
;
if
(
rand
()
%
4
!=
0
)
{
indices
.
push_back
(
static_cast
<
int
>
(
idx
));
}
}
SampleConsensusModelNormalPlaneTest
<
PointXYZ
,
Normal
>
model
(
cloud
.
makeShared
(),
indices
,
true
);
const
double
normal_distance_weight
=
0.3
*
static_cast
<
double
>
(
rand
())
/
RAND_MAX
;
// in [0; 0.3]
model
.
setNormalDistanceWeight
(
normal_distance_weight
);
model
.
setInputNormals
(
normal_cloud
.
makeShared
());
// Generate random model parameters
Eigen
::
VectorXf
model_coefficients
(
4
);
model_coefficients
<<
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
,
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
,
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
,
0.0
;
model_coefficients
.
normalize
();
model_coefficients
(
3
)
=
2.0
*
static_cast
<
float
>
(
rand
())
/
RAND_MAX
-
1.0
;
// Last parameter
const
double
threshold
=
0.1
*
static_cast
<
double
>
(
rand
())
/
RAND_MAX
;
// threshold in [0; 0.1]
// The number of inliers is usually somewhere between 0 and 100
const
auto
res_standard
=
model
.
countWithinDistanceStandard
(
model_coefficients
,
threshold
);
// Standard
#if defined (__SSE__) && defined (__SSE2__) && defined (__SSE4_1__)
const
auto
res_sse
=
model
.
countWithinDistanceSSE
(
model_coefficients
,
threshold
);
// SSE
EXPECT_LE
((
res_standard
>
res_sse
?
res_standard
-
res_sse
:
res_sse
-
res_standard
),
2u
)
<<
"seed="
<<
seed
<<
", i="
<<
i
<<
", model=("
<<
model_coefficients
(
0
)
<<
", "
<<
model_coefficients
(
1
)
<<
", "
<<
model_coefficients
(
2
)
<<
", "
<<
model_coefficients
(
3
)
<<
"), threshold="
<<
threshold
<<
", normal_distance_weight="
<<
normal_distance_weight
<<
", res_standard="
<<
res_standard
<<
std
::
endl
;
#endif
#if defined (__AVX__) && defined (__AVX2__)
const
auto
res_avx
=
model
.
countWithinDistanceAVX
(
model_coefficients
,
threshold
);
// AVX
EXPECT_LE
((
res_standard
>
res_avx
?
res_standard
-
res_avx
:
res_avx
-
res_standard
),
2u
)
<<
"seed="
<<
seed
<<
", i="
<<
i
<<
", model=("
<<
model_coefficients
(
0
)
<<
", "
<<
model_coefficients
(
1
)
<<
", "
<<
model_coefficients
(
2
)
<<
", "
<<
model_coefficients
(
3
)
<<
"), threshold="
<<
threshold
<<
", normal_distance_weight="
<<
normal_distance_weight
<<
", res_standard="
<<
res_standard
<<
std
::
endl
;
#endif
}
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录