Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
481f786f
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
481f786f
编写于
5月 28, 2015
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added simple HAL test; added RHO homography test
上级
8fb37606
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
222 addition
and
8 deletion
+222
-8
modules/calib3d/test/test_homography.cpp
modules/calib3d/test/test_homography.cpp
+27
-8
modules/core/test/test_hal_core.cpp
modules/core/test/test_hal_core.cpp
+195
-0
未找到文件。
modules/calib3d/test/test_homography.cpp
浏览文件 @
481f786f
...
...
@@ -662,7 +662,7 @@ TEST(Calib3d_Homography, fromImages)
std
::
vector
<
DMatch
>
good_matches
;
for
(
int
i
=
0
;
i
<
descriptors_1
.
rows
;
i
++
)
{
if
(
matches
[
i
].
distance
<=
42
)
if
(
matches
[
i
].
distance
<=
100
)
good_matches
.
push_back
(
matches
[
i
]);
}
...
...
@@ -676,13 +676,32 @@ TEST(Calib3d_Homography, fromImages)
pointframe2
.
push_back
(
keypoints_2
[
good_matches
[
i
].
trainIdx
].
pt
);
}
Mat
inliers
;
Mat
H
=
findHomography
(
pointframe1
,
pointframe2
,
RANSAC
,
3.0
,
inliers
);
int
ninliers
=
countNonZero
(
inliers
);
printf
(
"nfeatures1 = %d, nfeatures2=%d, good matches=%d, ninliers=%d
\n
"
,
Mat
H0
,
H1
,
inliers0
,
inliers1
;
double
min_t0
=
DBL_MAX
,
min_t1
=
DBL_MAX
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
double
t
=
(
double
)
getTickCount
();
H0
=
findHomography
(
pointframe1
,
pointframe2
,
RANSAC
,
3.0
,
inliers0
);
t
=
(
double
)
getTickCount
()
-
t
;
min_t0
=
std
::
min
(
min_t0
,
t
);
}
int
ninliers0
=
countNonZero
(
inliers0
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
double
t
=
(
double
)
getTickCount
();
H1
=
findHomography
(
pointframe1
,
pointframe2
,
RHO
,
3.0
,
inliers1
);
t
=
(
double
)
getTickCount
()
-
t
;
min_t1
=
std
::
min
(
min_t1
,
t
);
}
int
ninliers1
=
countNonZero
(
inliers1
);
double
freq
=
getTickFrequency
();
printf
(
"nfeatures1 = %d, nfeatures2=%d, matches=%d, ninliers(RANSAC)=%d, "
"time(RANSAC)=%.2fmsec, ninliers(RHO)=%d, time(RHO)=%.2fmsec
\n
"
,
(
int
)
keypoints_1
.
size
(),
(
int
)
keypoints_2
.
size
(),
(
int
)
good_matches
.
size
(),
ninliers
);
(
int
)
good_matches
.
size
(),
ninliers
0
,
min_t0
*
1000.
/
freq
,
ninliers1
,
min_t1
*
1000.
/
freq
);
ASSERT_TRUE
(
!
H
.
empty
());
ASSERT_GE
(
ninliers
,
80
);
ASSERT_TRUE
(
!
H0
.
empty
());
ASSERT_GE
(
ninliers0
,
80
);
ASSERT_TRUE
(
!
H1
.
empty
());
ASSERT_GE
(
ninliers1
,
80
);
}
modules/core/test/test_hal_core.cpp
0 → 100644
浏览文件 @
481f786f
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the OpenCV Foundation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include "opencv2/hal.hpp"
using
namespace
cv
;
enum
{
HAL_EXP
=
0
,
HAL_LOG
=
1
,
HAL_SQRT
=
2
};
TEST
(
Core_HAL
,
mathfuncs
)
{
for
(
int
hcase
=
0
;
hcase
<
6
;
hcase
++
)
{
int
depth
=
hcase
%
2
==
0
?
CV_32F
:
CV_64F
;
double
eps
=
depth
==
CV_32F
?
1e-5
:
1e-10
;
int
nfunc
=
hcase
/
2
;
int
n
=
100
;
Mat
src
(
1
,
n
,
depth
),
dst
(
1
,
n
,
depth
),
dst0
(
1
,
n
,
depth
);
randu
(
src
,
1
,
10
);
double
min_hal_t
=
DBL_MAX
,
min_ocv_t
=
DBL_MAX
;
for
(
int
iter
=
0
;
iter
<
10
;
iter
++
)
{
double
t
=
(
double
)
getTickCount
();
switch
(
nfunc
)
{
case
HAL_EXP
:
if
(
depth
==
CV_32F
)
hal
::
exp
(
src
.
ptr
<
float
>
(),
dst
.
ptr
<
float
>
(),
n
);
else
hal
::
exp
(
src
.
ptr
<
double
>
(),
dst
.
ptr
<
double
>
(),
n
);
break
;
case
HAL_LOG
:
if
(
depth
==
CV_32F
)
hal
::
log
(
src
.
ptr
<
float
>
(),
dst
.
ptr
<
float
>
(),
n
);
else
hal
::
log
(
src
.
ptr
<
double
>
(),
dst
.
ptr
<
double
>
(),
n
);
break
;
case
HAL_SQRT
:
if
(
depth
==
CV_32F
)
hal
::
sqrt
(
src
.
ptr
<
float
>
(),
dst
.
ptr
<
float
>
(),
n
);
else
hal
::
sqrt
(
src
.
ptr
<
double
>
(),
dst
.
ptr
<
double
>
(),
n
);
break
;
default:
CV_Error
(
Error
::
StsBadArg
,
"unknown function"
);
}
t
=
(
double
)
getTickCount
()
-
t
;
min_hal_t
=
std
::
min
(
min_hal_t
,
t
);
t
=
(
double
)
getTickCount
();
switch
(
nfunc
)
{
case
HAL_EXP
:
exp
(
src
,
dst0
);
break
;
case
HAL_LOG
:
log
(
src
,
dst0
);
break
;
case
HAL_SQRT
:
pow
(
src
,
0.5
,
dst0
);
break
;
default:
CV_Error
(
Error
::
StsBadArg
,
"unknown function"
);
}
t
=
(
double
)
getTickCount
()
-
t
;
min_ocv_t
=
std
::
min
(
min_ocv_t
,
t
);
}
EXPECT_LE
(
norm
(
dst
,
dst0
,
NORM_INF
|
NORM_RELATIVE
),
eps
);
double
freq
=
getTickFrequency
();
printf
(
"%s (N=%d, %s): hal time=%.2fusec, ocv time=%.2fusec
\n
"
,
(
nfunc
==
HAL_EXP
?
"exp"
:
nfunc
==
HAL_LOG
?
"log"
:
nfunc
==
HAL_SQRT
?
"sqrt"
:
"???"
),
n
,
(
depth
==
CV_32F
?
"f32"
:
"f64"
),
min_hal_t
*
1e6
/
freq
,
min_ocv_t
*
1e6
/
freq
);
}
}
enum
{
HAL_LU
=
0
,
HAL_CHOL
=
1
};
TEST
(
Core_HAL
,
mat_decomp
)
{
for
(
int
hcase
=
0
;
hcase
<
16
;
hcase
++
)
{
int
depth
=
hcase
%
2
==
0
?
CV_32F
:
CV_64F
;
int
size
=
(
hcase
/
2
)
%
4
;
size
=
size
==
0
?
3
:
size
==
1
?
4
:
size
==
2
?
6
:
15
;
int
nfunc
=
(
hcase
/
8
);
double
eps
=
depth
==
CV_32F
?
1e-5
:
1e-10
;
if
(
size
==
3
)
continue
;
Mat
a0
(
size
,
size
,
depth
),
a
(
size
,
size
,
depth
),
b
(
size
,
1
,
depth
),
x
(
size
,
1
,
depth
),
x0
(
size
,
1
,
depth
);
randu
(
a0
,
-
1
,
1
);
a0
=
a0
*
a0
.
t
();
randu
(
b
,
-
1
,
1
);
double
min_hal_t
=
DBL_MAX
,
min_ocv_t
=
DBL_MAX
;
size_t
asize
=
size
*
size
*
a
.
elemSize
();
size_t
bsize
=
size
*
b
.
elemSize
();
for
(
int
iter
=
0
;
iter
<
10
;
iter
++
)
{
memcpy
(
x
.
ptr
(),
b
.
ptr
(),
bsize
);
memcpy
(
a
.
ptr
(),
a0
.
ptr
(),
asize
);
double
t
=
(
double
)
getTickCount
();
switch
(
nfunc
)
{
case
HAL_LU
:
if
(
depth
==
CV_32F
)
hal
::
LU
(
a
.
ptr
<
float
>
(),
a
.
step
,
size
,
x
.
ptr
<
float
>
(),
x
.
step
,
1
);
else
hal
::
LU
(
a
.
ptr
<
double
>
(),
a
.
step
,
size
,
x
.
ptr
<
double
>
(),
x
.
step
,
1
);
break
;
case
HAL_CHOL
:
if
(
depth
==
CV_32F
)
hal
::
Cholesky
(
a
.
ptr
<
float
>
(),
a
.
step
,
size
,
x
.
ptr
<
float
>
(),
x
.
step
,
1
);
else
hal
::
Cholesky
(
a
.
ptr
<
double
>
(),
a
.
step
,
size
,
x
.
ptr
<
double
>
(),
x
.
step
,
1
);
break
;
default:
CV_Error
(
Error
::
StsBadArg
,
"unknown function"
);
}
t
=
(
double
)
getTickCount
()
-
t
;
min_hal_t
=
std
::
min
(
min_hal_t
,
t
);
t
=
(
double
)
getTickCount
();
solve
(
a0
,
b
,
x0
,
(
nfunc
==
HAL_LU
?
DECOMP_LU
:
DECOMP_CHOLESKY
));
t
=
(
double
)
getTickCount
()
-
t
;
min_ocv_t
=
std
::
min
(
min_ocv_t
,
t
);
}
//std::cout << "x: " << Mat(x.t()) << std::endl;
//std::cout << "x0: " << Mat(x0.t()) << std::endl;
EXPECT_LE
(
norm
(
x
,
x0
,
NORM_INF
|
NORM_RELATIVE
),
eps
);
double
freq
=
getTickFrequency
();
printf
(
"%s (%d x %d, %s): hal time=%.2fusec, ocv time=%.2fusec
\n
"
,
(
nfunc
==
HAL_LU
?
"LU"
:
nfunc
==
HAL_CHOL
?
"Cholesky"
:
"???"
),
size
,
size
,
(
depth
==
CV_32F
?
"f32"
:
"f64"
),
min_hal_t
*
1e6
/
freq
,
min_ocv_t
*
1e6
/
freq
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录