Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
e37b9469
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
e37b9469
编写于
8月 10, 2012
作者:
D
Daniil Osokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added perf tests
上级
c3ae08a1
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
1726 addition
and
1726 deletion
+1726
-1726
modules/imgproc/perf/perf_cvt_color.cpp
modules/imgproc/perf/perf_cvt_color.cpp
+269
-269
modules/imgproc/perf/perf_warp.cpp
modules/imgproc/perf/perf_warp.cpp
+168
-168
modules/stitching/perf/perf_stich.cpp
modules/stitching/perf/perf_stich.cpp
+134
-134
modules/ts/src/ts_perf.cpp
modules/ts/src/ts_perf.cpp
+1155
-1155
未找到文件。
modules/imgproc/perf/perf_cvt_color.cpp
浏览文件 @
e37b9469
此差异已折叠。
点击以展开。
modules/imgproc/perf/perf_warp.cpp
浏览文件 @
e37b9469
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
namespace
testing
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
enum
{
HALF_SIZE
=
0
,
UPSIDE_DOWN
,
REFLECTION_X
,
REFLECTION_BOTH
};
CV_ENUM
(
BorderMode
,
BORDER_CONSTANT
,
BORDER_REPLICATE
);
CV_ENUM
(
InterType
,
INTER_NEAREST
,
INTER_LINEAR
);
CV_ENUM
(
RemapMode
,
HALF_SIZE
,
UPSIDE_DOWN
,
REFLECTION_X
,
REFLECTION_BOTH
);
typedef
TestBaseWithParam
<
tr1
::
tuple
<
Size
,
InterType
,
BorderMode
>
>
TestWarpAffine
;
typedef
TestBaseWithParam
<
tr1
::
tuple
<
Size
,
InterType
,
BorderMode
>
>
TestWarpPerspective
;
typedef
TestBaseWithParam
<
tr1
::
tuple
<
MatType
,
Size
,
InterType
,
BorderMode
,
RemapMode
>
>
TestRemap
;
void
update_map
(
const
Mat
&
src
,
Mat
&
map_x
,
Mat
&
map_y
,
const
int
remapMode
);
PERF_TEST_P
(
TestWarpAffine
,
WarpAffine
,
Combine
(
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
)
)
)
{
Size
sz
;
int
borderMode
,
interType
;
sz
=
get
<
0
>
(
GetParam
());
borderMode
=
get
<
1
>
(
GetParam
());
interType
=
get
<
2
>
(
GetParam
());
Mat
src
,
img
=
imread
(
getDataPath
(
"cv/shared/fruits.jpg"
));
cvtColor
(
img
,
src
,
COLOR_BGR2RGBA
,
4
);
Mat
warpMat
=
getRotationMatrix2D
(
Point2f
(
src
.
cols
/
2.
f
,
src
.
rows
/
2.
f
),
30.
,
2.2
);
Mat
dst
(
sz
,
CV_8UC4
);
declare
.
in
(
src
).
out
(
dst
);
TEST_CYCLE
()
warpAffine
(
src
,
dst
,
warpMat
,
sz
,
interType
,
borderMode
,
Scalar
::
all
(
150
)
);
SANITY_CHECK
(
dst
);
}
PERF_TEST_P
(
TestWarpPerspective
,
WarpPerspective
,
Combine
(
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
)
)
)
{
Size
sz
;
int
borderMode
,
interType
;
sz
=
get
<
0
>
(
GetParam
());
borderMode
=
get
<
1
>
(
GetParam
());
interType
=
get
<
2
>
(
GetParam
());
Mat
src
,
img
=
imread
(
getDataPath
(
"cv/shared/fruits.jpg"
));
cvtColor
(
img
,
src
,
COLOR_BGR2RGBA
,
4
);
Mat
rotMat
=
getRotationMatrix2D
(
Point2f
(
src
.
cols
/
2.
f
,
src
.
rows
/
2.
f
),
30.
,
2.2
);
Mat
warpMat
(
3
,
3
,
CV_64FC1
);
for
(
int
r
=
0
;
r
<
2
;
r
++
)
for
(
int
c
=
0
;
c
<
3
;
c
++
)
warpMat
.
at
<
double
>
(
r
,
c
)
=
rotMat
.
at
<
double
>
(
r
,
c
);
warpMat
.
at
<
double
>
(
2
,
0
)
=
.3
/
sz
.
width
;
warpMat
.
at
<
double
>
(
2
,
1
)
=
.3
/
sz
.
height
;
warpMat
.
at
<
double
>
(
2
,
2
)
=
1
;
Mat
dst
(
sz
,
CV_8UC4
);
declare
.
in
(
src
).
out
(
dst
);
TEST_CYCLE
()
warpPerspective
(
src
,
dst
,
warpMat
,
sz
,
interType
,
borderMode
,
Scalar
::
all
(
150
)
);
SANITY_CHECK
(
dst
);
}
PERF_TEST_P
(
TestRemap
,
remap
,
Combine
(
Values
(
TYPICAL_MAT_TYPES
),
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
),
ValuesIn
(
RemapMode
::
all
()
)
)
)
{
int
type
=
get
<
0
>
(
GetParam
());
Size
size
=
get
<
1
>
(
GetParam
());
int
interpolationType
=
get
<
2
>
(
GetParam
());
int
borderMode
=
get
<
3
>
(
GetParam
());
int
remapMode
=
get
<
4
>
(
GetParam
());
unsigned
int
height
=
size
.
height
;
unsigned
int
width
=
size
.
width
;
Mat
source
(
height
,
width
,
type
);
Mat
destination
;
Mat
map_x
(
height
,
width
,
CV_32F
);
Mat
map_y
(
height
,
width
,
CV_32F
);
declare
.
in
(
source
,
WARMUP_RNG
);
update_map
(
source
,
map_x
,
map_y
,
remapMode
);
TEST_CYCLE
()
{
remap
(
source
,
destination
,
map_x
,
map_y
,
interpolationType
,
borderMode
);
}
SANITY_CHECK
(
destination
,
1
);
}
void
update_map
(
const
Mat
&
src
,
Mat
&
map_x
,
Mat
&
map_y
,
const
int
remapMode
)
{
for
(
int
j
=
0
;
j
<
src
.
rows
;
j
++
)
{
for
(
int
i
=
0
;
i
<
src
.
cols
;
i
++
)
{
switch
(
remapMode
)
{
case
HALF_SIZE
:
if
(
i
>
src
.
cols
*
0.25
&&
i
<
src
.
cols
*
0.75
&&
j
>
src
.
rows
*
0.25
&&
j
<
src
.
rows
*
0.75
)
{
map_x
.
at
<
float
>
(
j
,
i
)
=
2
*
(
i
-
src
.
cols
*
0.25
)
+
0.5
;
map_y
.
at
<
float
>
(
j
,
i
)
=
2
*
(
j
-
src
.
rows
*
0.25
)
+
0.5
;
}
else
{
map_x
.
at
<
float
>
(
j
,
i
)
=
0
;
map_y
.
at
<
float
>
(
j
,
i
)
=
0
;
}
break
;
case
UPSIDE_DOWN
:
map_x
.
at
<
float
>
(
j
,
i
)
=
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
src
.
rows
-
j
;
break
;
case
REFLECTION_X
:
map_x
.
at
<
float
>
(
j
,
i
)
=
src
.
cols
-
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
j
;
break
;
case
REFLECTION_BOTH
:
map_x
.
at
<
float
>
(
j
,
i
)
=
src
.
cols
-
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
src
.
rows
-
j
;
break
;
}
// end of switch
}
}
}
PERF_TEST
(
Transform
,
getPerspectiveTransform
)
{
unsigned
int
size
=
8
;
Mat
source
(
1
,
size
/
2
,
CV_32FC2
);
Mat
destination
(
1
,
size
/
2
,
CV_32FC2
);
Mat
transformCoefficient
;
declare
.
in
(
source
,
destination
,
WARMUP_RNG
);
TEST_CYCLE
()
{
transformCoefficient
=
getPerspectiveTransform
(
source
,
destination
);
}
}
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
namespace
testing
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
enum
{
HALF_SIZE
=
0
,
UPSIDE_DOWN
,
REFLECTION_X
,
REFLECTION_BOTH
};
CV_ENUM
(
BorderMode
,
BORDER_CONSTANT
,
BORDER_REPLICATE
);
CV_ENUM
(
InterType
,
INTER_NEAREST
,
INTER_LINEAR
);
CV_ENUM
(
RemapMode
,
HALF_SIZE
,
UPSIDE_DOWN
,
REFLECTION_X
,
REFLECTION_BOTH
);
typedef
TestBaseWithParam
<
tr1
::
tuple
<
Size
,
InterType
,
BorderMode
>
>
TestWarpAffine
;
typedef
TestBaseWithParam
<
tr1
::
tuple
<
Size
,
InterType
,
BorderMode
>
>
TestWarpPerspective
;
typedef
TestBaseWithParam
<
tr1
::
tuple
<
MatType
,
Size
,
InterType
,
BorderMode
,
RemapMode
>
>
TestRemap
;
void
update_map
(
const
Mat
&
src
,
Mat
&
map_x
,
Mat
&
map_y
,
const
int
remapMode
);
PERF_TEST_P
(
TestWarpAffine
,
WarpAffine
,
Combine
(
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
)
)
)
{
Size
sz
;
int
borderMode
,
interType
;
sz
=
get
<
0
>
(
GetParam
());
borderMode
=
get
<
1
>
(
GetParam
());
interType
=
get
<
2
>
(
GetParam
());
Mat
src
,
img
=
imread
(
getDataPath
(
"cv/shared/fruits.jpg"
));
cvtColor
(
img
,
src
,
COLOR_BGR2RGBA
,
4
);
Mat
warpMat
=
getRotationMatrix2D
(
Point2f
(
src
.
cols
/
2.
f
,
src
.
rows
/
2.
f
),
30.
,
2.2
);
Mat
dst
(
sz
,
CV_8UC4
);
declare
.
in
(
src
).
out
(
dst
);
TEST_CYCLE
()
warpAffine
(
src
,
dst
,
warpMat
,
sz
,
interType
,
borderMode
,
Scalar
::
all
(
150
)
);
SANITY_CHECK
(
dst
);
}
PERF_TEST_P
(
TestWarpPerspective
,
WarpPerspective
,
Combine
(
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
)
)
)
{
Size
sz
;
int
borderMode
,
interType
;
sz
=
get
<
0
>
(
GetParam
());
borderMode
=
get
<
1
>
(
GetParam
());
interType
=
get
<
2
>
(
GetParam
());
Mat
src
,
img
=
imread
(
getDataPath
(
"cv/shared/fruits.jpg"
));
cvtColor
(
img
,
src
,
COLOR_BGR2RGBA
,
4
);
Mat
rotMat
=
getRotationMatrix2D
(
Point2f
(
src
.
cols
/
2.
f
,
src
.
rows
/
2.
f
),
30.
,
2.2
);
Mat
warpMat
(
3
,
3
,
CV_64FC1
);
for
(
int
r
=
0
;
r
<
2
;
r
++
)
for
(
int
c
=
0
;
c
<
3
;
c
++
)
warpMat
.
at
<
double
>
(
r
,
c
)
=
rotMat
.
at
<
double
>
(
r
,
c
);
warpMat
.
at
<
double
>
(
2
,
0
)
=
.3
/
sz
.
width
;
warpMat
.
at
<
double
>
(
2
,
1
)
=
.3
/
sz
.
height
;
warpMat
.
at
<
double
>
(
2
,
2
)
=
1
;
Mat
dst
(
sz
,
CV_8UC4
);
declare
.
in
(
src
).
out
(
dst
);
TEST_CYCLE
()
warpPerspective
(
src
,
dst
,
warpMat
,
sz
,
interType
,
borderMode
,
Scalar
::
all
(
150
)
);
SANITY_CHECK
(
dst
);
}
PERF_TEST_P
(
TestRemap
,
remap
,
Combine
(
Values
(
TYPICAL_MAT_TYPES
),
Values
(
szVGA
,
sz720p
,
sz1080p
),
ValuesIn
(
InterType
::
all
()
),
ValuesIn
(
BorderMode
::
all
()
),
ValuesIn
(
RemapMode
::
all
()
)
)
)
{
int
type
=
get
<
0
>
(
GetParam
());
Size
size
=
get
<
1
>
(
GetParam
());
int
interpolationType
=
get
<
2
>
(
GetParam
());
int
borderMode
=
get
<
3
>
(
GetParam
());
int
remapMode
=
get
<
4
>
(
GetParam
());
unsigned
int
height
=
size
.
height
;
unsigned
int
width
=
size
.
width
;
Mat
source
(
height
,
width
,
type
);
Mat
destination
;
Mat
map_x
(
height
,
width
,
CV_32F
);
Mat
map_y
(
height
,
width
,
CV_32F
);
declare
.
in
(
source
,
WARMUP_RNG
);
update_map
(
source
,
map_x
,
map_y
,
remapMode
);
TEST_CYCLE
()
{
remap
(
source
,
destination
,
map_x
,
map_y
,
interpolationType
,
borderMode
);
}
SANITY_CHECK
(
destination
,
1
);
}
void
update_map
(
const
Mat
&
src
,
Mat
&
map_x
,
Mat
&
map_y
,
const
int
remapMode
)
{
for
(
int
j
=
0
;
j
<
src
.
rows
;
j
++
)
{
for
(
int
i
=
0
;
i
<
src
.
cols
;
i
++
)
{
switch
(
remapMode
)
{
case
HALF_SIZE
:
if
(
i
>
src
.
cols
*
0.25
&&
i
<
src
.
cols
*
0.75
&&
j
>
src
.
rows
*
0.25
&&
j
<
src
.
rows
*
0.75
)
{
map_x
.
at
<
float
>
(
j
,
i
)
=
2
*
(
i
-
src
.
cols
*
0.25
)
+
0.5
;
map_y
.
at
<
float
>
(
j
,
i
)
=
2
*
(
j
-
src
.
rows
*
0.25
)
+
0.5
;
}
else
{
map_x
.
at
<
float
>
(
j
,
i
)
=
0
;
map_y
.
at
<
float
>
(
j
,
i
)
=
0
;
}
break
;
case
UPSIDE_DOWN
:
map_x
.
at
<
float
>
(
j
,
i
)
=
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
src
.
rows
-
j
;
break
;
case
REFLECTION_X
:
map_x
.
at
<
float
>
(
j
,
i
)
=
src
.
cols
-
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
j
;
break
;
case
REFLECTION_BOTH
:
map_x
.
at
<
float
>
(
j
,
i
)
=
src
.
cols
-
i
;
map_y
.
at
<
float
>
(
j
,
i
)
=
src
.
rows
-
j
;
break
;
}
// end of switch
}
}
}
PERF_TEST
(
Transform
,
getPerspectiveTransform
)
{
unsigned
int
size
=
8
;
Mat
source
(
1
,
size
/
2
,
CV_32FC2
);
Mat
destination
(
1
,
size
/
2
,
CV_32FC2
);
Mat
transformCoefficient
;
declare
.
in
(
source
,
destination
,
WARMUP_RNG
);
TEST_CYCLE
()
{
transformCoefficient
=
getPerspectiveTransform
(
source
,
destination
);
}
}
modules/stitching/perf/perf_stich.cpp
浏览文件 @
e37b9469
#include "perf_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/opencv_modules.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
#define SURF_MATCH_CONFIDENCE 0.65f
#define ORB_MATCH_CONFIDENCE 0.3f
#define WORK_MEGAPIX 0.6
typedef
TestBaseWithParam
<
String
>
stitch
;
typedef
TestBaseWithParam
<
String
>
match
;
#ifdef HAVE_OPENCV_NONFREE
#define TEST_DETECTORS testing::Values("surf", "orb")
#else
#define TEST_DETECTORS testing::Values<String>("orb")
#endif
PERF_TEST_P
(
stitch
,
a123
,
TEST_DETECTORS
)
{
Mat
pano
;
vector
<
Mat
>
imgs
;
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a1.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a2.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a3.jpg"
)
)
);
Ptr
<
detail
::
FeaturesFinder
>
featuresFinder
=
GetParam
()
==
"orb"
?
(
detail
::
FeaturesFinder
*
)
new
detail
::
OrbFeaturesFinder
()
:
(
detail
::
FeaturesFinder
*
)
new
detail
::
SurfFeaturesFinder
();
Ptr
<
detail
::
FeaturesMatcher
>
featuresMatcher
=
GetParam
()
==
"orb"
?
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
)
:
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
declare
.
time
(
30
*
20
).
iterations
(
20
);
while
(
next
())
{
Stitcher
stitcher
=
Stitcher
::
createDefault
();
stitcher
.
setFeaturesFinder
(
featuresFinder
);
stitcher
.
setFeaturesMatcher
(
featuresMatcher
);
stitcher
.
setWarper
(
new
SphericalWarper
());
stitcher
.
setRegistrationResol
(
WORK_MEGAPIX
);
startTimer
();
stitcher
.
stitch
(
imgs
,
pano
);
stopTimer
();
}
}
PERF_TEST_P
(
stitch
,
b12
,
TEST_DETECTORS
)
{
Mat
pano
;
vector
<
Mat
>
imgs
;
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/b1.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/b2.jpg"
)
)
);
Ptr
<
detail
::
FeaturesFinder
>
featuresFinder
=
GetParam
()
==
"orb"
?
(
detail
::
FeaturesFinder
*
)
new
detail
::
OrbFeaturesFinder
()
:
(
detail
::
FeaturesFinder
*
)
new
detail
::
SurfFeaturesFinder
();
Ptr
<
detail
::
FeaturesMatcher
>
featuresMatcher
=
GetParam
()
==
"orb"
?
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
)
:
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
declare
.
time
(
30
*
20
).
iterations
(
20
);
while
(
next
())
{
Stitcher
stitcher
=
Stitcher
::
createDefault
();
stitcher
.
setFeaturesFinder
(
featuresFinder
);
stitcher
.
setFeaturesMatcher
(
featuresMatcher
);
stitcher
.
setWarper
(
new
SphericalWarper
());
stitcher
.
setRegistrationResol
(
WORK_MEGAPIX
);
startTimer
();
stitcher
.
stitch
(
imgs
,
pano
);
stopTimer
();
}
}
PERF_TEST_P
(
match
,
bestOf2Nearest
,
TEST_DETECTORS
)
{
Mat
img1
,
img1_full
=
imread
(
getDataPath
(
"stitching/b1.jpg"
)
);
Mat
img2
,
img2_full
=
imread
(
getDataPath
(
"stitching/b2.jpg"
)
);
float
scale1
=
(
float
)
std
::
min
(
1.0
,
sqrt
(
WORK_MEGAPIX
*
1e6
/
img1_full
.
total
()));
float
scale2
=
(
float
)
std
::
min
(
1.0
,
sqrt
(
WORK_MEGAPIX
*
1e6
/
img2_full
.
total
()));
resize
(
img1_full
,
img1
,
Size
(),
scale1
,
scale1
);
resize
(
img2_full
,
img2
,
Size
(),
scale2
,
scale2
);
Ptr
<
detail
::
FeaturesFinder
>
finder
;
Ptr
<
detail
::
FeaturesMatcher
>
matcher
;
if
(
GetParam
()
==
"surf"
)
{
finder
=
new
detail
::
SurfFeaturesFinder
();
matcher
=
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
}
else
if
(
GetParam
()
==
"orb"
)
{
finder
=
new
detail
::
OrbFeaturesFinder
();
matcher
=
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
);
}
else
{
FAIL
()
<<
"Unknown 2D features type: "
<<
GetParam
();
}
detail
::
ImageFeatures
features1
,
features2
;
(
*
finder
)(
img1
,
features1
);
(
*
finder
)(
img2
,
features2
);
detail
::
MatchesInfo
pairwise_matches
;
declare
.
in
(
features1
.
descriptors
,
features2
.
descriptors
)
.
iterations
(
100
);
while
(
next
())
{
cvflann
::
seed_random
(
42
);
//for predictive FlannBasedMatcher
startTimer
();
(
*
matcher
)(
features1
,
features2
,
pairwise_matches
);
stopTimer
();
matcher
->
collectGarbage
();
}
}
#include "perf_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/opencv_modules.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
#define SURF_MATCH_CONFIDENCE 0.65f
#define ORB_MATCH_CONFIDENCE 0.3f
#define WORK_MEGAPIX 0.6
typedef
TestBaseWithParam
<
String
>
stitch
;
typedef
TestBaseWithParam
<
String
>
match
;
#ifdef HAVE_OPENCV_NONFREE
#define TEST_DETECTORS testing::Values("surf", "orb")
#else
#define TEST_DETECTORS testing::Values<String>("orb")
#endif
PERF_TEST_P
(
stitch
,
a123
,
TEST_DETECTORS
)
{
Mat
pano
;
vector
<
Mat
>
imgs
;
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a1.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a2.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/a3.jpg"
)
)
);
Ptr
<
detail
::
FeaturesFinder
>
featuresFinder
=
GetParam
()
==
"orb"
?
(
detail
::
FeaturesFinder
*
)
new
detail
::
OrbFeaturesFinder
()
:
(
detail
::
FeaturesFinder
*
)
new
detail
::
SurfFeaturesFinder
();
Ptr
<
detail
::
FeaturesMatcher
>
featuresMatcher
=
GetParam
()
==
"orb"
?
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
)
:
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
declare
.
time
(
30
*
20
).
iterations
(
20
);
while
(
next
())
{
Stitcher
stitcher
=
Stitcher
::
createDefault
();
stitcher
.
setFeaturesFinder
(
featuresFinder
);
stitcher
.
setFeaturesMatcher
(
featuresMatcher
);
stitcher
.
setWarper
(
new
SphericalWarper
());
stitcher
.
setRegistrationResol
(
WORK_MEGAPIX
);
startTimer
();
stitcher
.
stitch
(
imgs
,
pano
);
stopTimer
();
}
}
PERF_TEST_P
(
stitch
,
b12
,
TEST_DETECTORS
)
{
Mat
pano
;
vector
<
Mat
>
imgs
;
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/b1.jpg"
)
)
);
imgs
.
push_back
(
imread
(
getDataPath
(
"stitching/b2.jpg"
)
)
);
Ptr
<
detail
::
FeaturesFinder
>
featuresFinder
=
GetParam
()
==
"orb"
?
(
detail
::
FeaturesFinder
*
)
new
detail
::
OrbFeaturesFinder
()
:
(
detail
::
FeaturesFinder
*
)
new
detail
::
SurfFeaturesFinder
();
Ptr
<
detail
::
FeaturesMatcher
>
featuresMatcher
=
GetParam
()
==
"orb"
?
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
)
:
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
declare
.
time
(
30
*
20
).
iterations
(
20
);
while
(
next
())
{
Stitcher
stitcher
=
Stitcher
::
createDefault
();
stitcher
.
setFeaturesFinder
(
featuresFinder
);
stitcher
.
setFeaturesMatcher
(
featuresMatcher
);
stitcher
.
setWarper
(
new
SphericalWarper
());
stitcher
.
setRegistrationResol
(
WORK_MEGAPIX
);
startTimer
();
stitcher
.
stitch
(
imgs
,
pano
);
stopTimer
();
}
}
PERF_TEST_P
(
match
,
bestOf2Nearest
,
TEST_DETECTORS
)
{
Mat
img1
,
img1_full
=
imread
(
getDataPath
(
"stitching/b1.jpg"
)
);
Mat
img2
,
img2_full
=
imread
(
getDataPath
(
"stitching/b2.jpg"
)
);
float
scale1
=
(
float
)
std
::
min
(
1.0
,
sqrt
(
WORK_MEGAPIX
*
1e6
/
img1_full
.
total
()));
float
scale2
=
(
float
)
std
::
min
(
1.0
,
sqrt
(
WORK_MEGAPIX
*
1e6
/
img2_full
.
total
()));
resize
(
img1_full
,
img1
,
Size
(),
scale1
,
scale1
);
resize
(
img2_full
,
img2
,
Size
(),
scale2
,
scale2
);
Ptr
<
detail
::
FeaturesFinder
>
finder
;
Ptr
<
detail
::
FeaturesMatcher
>
matcher
;
if
(
GetParam
()
==
"surf"
)
{
finder
=
new
detail
::
SurfFeaturesFinder
();
matcher
=
new
detail
::
BestOf2NearestMatcher
(
false
,
SURF_MATCH_CONFIDENCE
);
}
else
if
(
GetParam
()
==
"orb"
)
{
finder
=
new
detail
::
OrbFeaturesFinder
();
matcher
=
new
detail
::
BestOf2NearestMatcher
(
false
,
ORB_MATCH_CONFIDENCE
);
}
else
{
FAIL
()
<<
"Unknown 2D features type: "
<<
GetParam
();
}
detail
::
ImageFeatures
features1
,
features2
;
(
*
finder
)(
img1
,
features1
);
(
*
finder
)(
img2
,
features2
);
detail
::
MatchesInfo
pairwise_matches
;
declare
.
in
(
features1
.
descriptors
,
features2
.
descriptors
)
.
iterations
(
100
);
while
(
next
())
{
cvflann
::
seed_random
(
42
);
//for predictive FlannBasedMatcher
startTimer
();
(
*
matcher
)(
features1
,
features2
,
pairwise_matches
);
stopTimer
();
matcher
->
collectGarbage
();
}
}
modules/ts/src/ts_perf.cpp
浏览文件 @
e37b9469
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录