Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
0d880479
Commit
0d880479
authored
Dec 06, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated nv perf test script (added opticalFlowBM and HoughLinesP)
parent
aad76090
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
183 additions
and
32 deletions
+183
-32
main.cpp
modules/gpu/app/nv_perf_test/main.cpp
+183
-32
No files found.
modules/gpu/app/nv_perf_test/main.cpp
View file @
0d880479
...
...
@@ -4,6 +4,7 @@
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/video.hpp>
#include <opencv2/legacy/legacy.hpp>
#include <opencv2/ts/ts.hpp>
#include <opencv2/ts/ts_perf.hpp>
...
...
@@ -66,19 +67,75 @@ int main(int argc, char* argv[])
return
RUN_ALL_TESTS
();
}
//////////////////////////////////////////////////////////
// Tests
#define DEF_PARAM_TEST(name, ...) typedef ::perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > name
#define DEF_PARAM_TEST_1(name, param_type) typedef ::perf::TestBaseWithParam< param_type > name
DEF_PARAM_TEST_1
(
Depth
,
perf
::
MatDepth
);
//////////////////////////////////////////////////////////
// HoughLinesP
DEF_PARAM_TEST_1
(
Image
,
std
::
string
);
PERF_TEST_P
(
Image
,
HoughLinesP
,
testing
::
Values
(
std
::
string
(
"im1_1280x800.jpg"
)))
{
declare
.
time
(
30.0
);
std
::
string
fileName
=
GetParam
();
const
double
rho
=
1.0
;
const
double
theta
=
1.0
;
const
int
threshold
=
40
;
const
int
minLineLenght
=
20
;
const
int
maxLineGap
=
5
;
cv
::
Mat
image
=
cv
::
imread
(
fileName
,
cv
::
IMREAD_GRAYSCALE
);
if
(
PERF_RUN_GPU
())
{
cv
::
gpu
::
GpuMat
d_image
(
image
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
CannyBuf
d_buf
;
cv
::
gpu
::
HoughLinesP
(
d_image
,
d_lines
,
d_buf
,
minLineLenght
,
maxLineGap
);
TEST_CYCLE
()
{
cv
::
gpu
::
HoughLinesP
(
d_image
,
d_lines
,
d_buf
,
minLineLenght
,
maxLineGap
);
}
}
else
{
cv
::
Mat
mask
;
cv
::
Canny
(
image
,
mask
,
50
,
100
);
std
::
vector
<
cv
::
Vec4i
>
lines
;
cv
::
HoughLinesP
(
mask
,
lines
,
rho
,
theta
,
threshold
,
minLineLenght
,
maxLineGap
);
PERF_TEST_P
(
Depth
,
GoodFeaturesToTrack
,
testing
::
Values
(
CV_8U
,
CV_16U
))
TEST_CYCLE
()
{
cv
::
HoughLinesP
(
mask
,
lines
,
rho
,
theta
,
threshold
,
minLineLenght
,
maxLineGap
);
}
}
SANITY_CHECK
(
0
);
}
//////////////////////////////////////////////////////////
// GoodFeaturesToTrack
DEF_PARAM_TEST
(
Image_Depth
,
std
::
string
,
perf
::
MatDepth
);
PERF_TEST_P
(
Image_Depth
,
GoodFeaturesToTrack
,
testing
::
Combine
(
testing
::
Values
(
std
::
string
(
"im1_1280x800.jpg"
)),
testing
::
Values
(
CV_8U
,
CV_16U
)
))
{
declare
.
time
(
60
);
const
int
depth
=
GetParam
();
const
std
::
string
fileName
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
int
depth
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
int
maxCorners
=
5000
;
const
double
qualityLevel
=
0.05
;
const
int
minDistance
=
5
;
...
...
@@ -86,8 +143,6 @@ PERF_TEST_P(Depth, GoodFeaturesToTrack, testing::Values(CV_8U, CV_16U))
const
bool
useHarrisDetector
=
true
;
const
double
k
=
0.05
;
const
std
::
string
fileName
=
"im1_1280x800.jpg"
;
cv
::
Mat
src
=
cv
::
imread
(
fileName
,
cv
::
IMREAD_GRAYSCALE
);
if
(
src
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileName
<<
"]"
;
...
...
@@ -115,6 +170,9 @@ PERF_TEST_P(Depth, GoodFeaturesToTrack, testing::Values(CV_8U, CV_16U))
}
else
{
if
(
depth
!=
CV_8U
)
FAIL
()
<<
"Unsupported depth"
;
cv
::
Mat
pts
;
cv
::
goodFeaturesToTrack
(
src
,
pts
,
maxCorners
,
qualityLevel
,
minDistance
,
mask
,
blockSize
,
useHarrisDetector
,
k
);
...
...
@@ -128,14 +186,25 @@ PERF_TEST_P(Depth, GoodFeaturesToTrack, testing::Values(CV_8U, CV_16U))
SANITY_CHECK
(
0
);
}
DEF_PARAM_TEST
(
Depth_GraySource
,
perf
::
MatDepth
,
bool
);
//////////////////////////////////////////////////////////
// OpticalFlowPyrLKSparse
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
string_pair
;
PERF_TEST_P
(
Depth_GraySource
,
PyrLKOpticalFlowSparse
,
testing
::
Combine
(
testing
::
Values
(
CV_8U
,
CV_16U
),
testing
::
Bool
()))
DEF_PARAM_TEST
(
ImagePair_Depth_GraySource
,
string_pair
,
perf
::
MatDepth
,
bool
);
PERF_TEST_P
(
ImagePair_Depth_GraySource
,
OpticalFlowPyrLKSparse
,
testing
::
Combine
(
testing
::
Values
(
string_pair
(
"im1_1280x800.jpg"
,
"im2_1280x800.jpg"
)),
testing
::
Values
(
CV_8U
,
CV_16U
),
testing
::
Bool
()
))
{
declare
.
time
(
60
);
const
int
depth
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
bool
graySource
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
string_pair
fileNames
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
int
depth
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
bool
graySource
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
// PyrLK params
const
cv
::
Size
winSize
(
15
,
15
);
...
...
@@ -150,16 +219,13 @@ PERF_TEST_P(Depth_GraySource, PyrLKOpticalFlowSparse, testing::Combine(testing::
const
bool
useHarrisDetector
=
true
;
const
double
k
=
0.05
;
const
std
::
string
fileName1
=
"im1_1280x800.jpg"
;
const
std
::
string
fileName2
=
"im2_1280x800.jpg"
;
cv
::
Mat
src1
=
cv
::
imread
(
fileName1
,
graySource
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
src1
=
cv
::
imread
(
fileNames
.
first
,
graySource
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
if
(
src1
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileName
1
<<
"]"
;
FAIL
()
<<
"Unable to load source image ["
<<
fileName
s
.
first
<<
"]"
;
cv
::
Mat
src2
=
cv
::
imread
(
fileName
2
,
graySource
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
src2
=
cv
::
imread
(
fileName
s
.
second
,
graySource
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
if
(
src2
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileName
2
<<
"]"
;
FAIL
()
<<
"Unable to load source image ["
<<
fileName
s
.
second
<<
"]"
;
cv
::
Mat
gray_src
;
if
(
graySource
)
...
...
@@ -199,6 +265,9 @@ PERF_TEST_P(Depth_GraySource, PyrLKOpticalFlowSparse, testing::Combine(testing::
}
else
{
if
(
depth
!=
CV_8U
)
FAIL
()
<<
"Unsupported depth"
;
cv
::
Mat
nextPts
;
cv
::
Mat
status
;
...
...
@@ -213,13 +282,21 @@ PERF_TEST_P(Depth_GraySource, PyrLKOpticalFlowSparse, testing::Combine(testing::
SANITY_CHECK
(
0
);
}
DEF_PARAM_TEST_1
(
Depth
,
perf
::
MatDepth
);
//////////////////////////////////////////////////////////
// OpticalFlowFarneback
DEF_PARAM_TEST
(
ImagePair_Depth
,
string_pair
,
perf
::
MatDepth
);
PERF_TEST_P
(
Depth
,
FarnebackOpticalFlow
,
testing
::
Values
(
CV_8U
,
CV_16U
))
PERF_TEST_P
(
ImagePair_Depth
,
OpticalFlowFarneback
,
testing
::
Combine
(
testing
::
Values
(
string_pair
(
"im1_1280x800.jpg"
,
"im2_1280x800.jpg"
)),
testing
::
Values
(
CV_8U
,
CV_16U
)
))
{
declare
.
time
(
6
0
);
declare
.
time
(
50
0
);
const
int
depth
=
GetParam
();
const
string_pair
fileNames
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
int
depth
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
double
pyrScale
=
0.5
;
const
int
numLevels
=
6
;
...
...
@@ -229,16 +306,13 @@ PERF_TEST_P(Depth, FarnebackOpticalFlow, testing::Values(CV_8U, CV_16U))
const
double
polySigma
=
1.5
;
const
int
flags
=
cv
::
OPTFLOW_USE_INITIAL_FLOW
;
const
std
::
string
fileName1
=
"im1_1280x800.jpg"
;
const
std
::
string
fileName2
=
"im2_1280x800.jpg"
;
cv
::
Mat
src1
=
cv
::
imread
(
fileName1
,
cv
::
IMREAD_GRAYSCALE
);
cv
::
Mat
src1
=
cv
::
imread
(
fileNames
.
first
,
cv
::
IMREAD_GRAYSCALE
);
if
(
src1
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileName
1
<<
"]"
;
FAIL
()
<<
"Unable to load source image ["
<<
fileName
s
.
first
<<
"]"
;
cv
::
Mat
src2
=
cv
::
imread
(
fileName
2
,
cv
::
IMREAD_GRAYSCALE
);
cv
::
Mat
src2
=
cv
::
imread
(
fileName
s
.
second
,
cv
::
IMREAD_GRAYSCALE
);
if
(
src2
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileName
2
<<
"]"
;
FAIL
()
<<
"Unable to load source image ["
<<
fileName
s
.
second
<<
"]"
;
if
(
depth
!=
CV_8U
)
{
...
...
@@ -264,18 +338,21 @@ PERF_TEST_P(Depth, FarnebackOpticalFlow, testing::Values(CV_8U, CV_16U))
d_farneback
(
d_src1
,
d_src2
,
d_u
,
d_v
);
TEST_CYCLE
(
)
TEST_CYCLE
_N
(
10
)
{
d_farneback
(
d_src1
,
d_src2
,
d_u
,
d_v
);
}
}
else
{
if
(
depth
!=
CV_8U
)
FAIL
()
<<
"Unsupported depth"
;
cv
::
Mat
flow
(
src1
.
size
(),
CV_32FC2
,
cv
::
Scalar
::
all
(
0
));
cv
::
calcOpticalFlowFarneback
(
src1
,
src2
,
flow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
);
TEST_CYCLE
(
)
TEST_CYCLE
_N
(
10
)
{
cv
::
calcOpticalFlowFarneback
(
src1
,
src2
,
flow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
);
}
...
...
@@ -283,3 +360,77 @@ PERF_TEST_P(Depth, FarnebackOpticalFlow, testing::Values(CV_8U, CV_16U))
SANITY_CHECK
(
0
);
}
//////////////////////////////////////////////////////////
// OpticalFlowBM
void
calcOpticalFlowBM
(
const
cv
::
Mat
&
prev
,
const
cv
::
Mat
&
curr
,
cv
::
Size
bSize
,
cv
::
Size
shiftSize
,
cv
::
Size
maxRange
,
int
usePrevious
,
cv
::
Mat
&
velx
,
cv
::
Mat
&
vely
)
{
cv
::
Size
sz
((
curr
.
cols
-
bSize
.
width
+
shiftSize
.
width
)
/
shiftSize
.
width
,
(
curr
.
rows
-
bSize
.
height
+
shiftSize
.
height
)
/
shiftSize
.
height
);
velx
.
create
(
sz
,
CV_32FC1
);
vely
.
create
(
sz
,
CV_32FC1
);
CvMat
cvprev
=
prev
;
CvMat
cvcurr
=
curr
;
CvMat
cvvelx
=
velx
;
CvMat
cvvely
=
vely
;
cvCalcOpticalFlowBM
(
&
cvprev
,
&
cvcurr
,
bSize
,
shiftSize
,
maxRange
,
usePrevious
,
&
cvvelx
,
&
cvvely
);
}
DEF_PARAM_TEST
(
ImagePair_BlockSize_ShiftSize_MaxRange
,
string_pair
,
cv
::
Size
,
cv
::
Size
,
cv
::
Size
);
PERF_TEST_P
(
ImagePair_BlockSize_ShiftSize_MaxRange
,
OpticalFlowBM
,
testing
::
Combine
(
testing
::
Values
(
string_pair
(
"im1_1280x800.jpg"
,
"im2_1280x800.jpg"
)),
testing
::
Values
(
cv
::
Size
(
16
,
16
)),
testing
::
Values
(
cv
::
Size
(
2
,
2
)),
testing
::
Values
(
cv
::
Size
(
16
,
16
))
))
{
declare
.
time
(
1000
);
const
string_pair
fileNames
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
cv
::
Size
block_size
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
cv
::
Size
shift_size
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
const
cv
::
Size
max_range
=
std
::
tr1
::
get
<
3
>
(
GetParam
());
cv
::
Mat
src1
=
cv
::
imread
(
fileNames
.
first
,
cv
::
IMREAD_GRAYSCALE
);
if
(
src1
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileNames
.
first
<<
"]"
;
cv
::
Mat
src2
=
cv
::
imread
(
fileNames
.
second
,
cv
::
IMREAD_GRAYSCALE
);
if
(
src2
.
empty
())
FAIL
()
<<
"Unable to load source image ["
<<
fileNames
.
second
<<
"]"
;
if
(
PERF_RUN_GPU
())
{
cv
::
gpu
::
GpuMat
d_src1
(
src1
);
cv
::
gpu
::
GpuMat
d_src2
(
src2
);
cv
::
gpu
::
GpuMat
d_velx
,
d_vely
,
buf
;
cv
::
gpu
::
calcOpticalFlowBM
(
d_src1
,
d_src2
,
block_size
,
shift_size
,
max_range
,
false
,
d_velx
,
d_vely
,
buf
);
TEST_CYCLE_N
(
10
)
{
cv
::
gpu
::
calcOpticalFlowBM
(
d_src1
,
d_src2
,
block_size
,
shift_size
,
max_range
,
false
,
d_velx
,
d_vely
,
buf
);
}
}
else
{
cv
::
Mat
velx
,
vely
;
calcOpticalFlowBM
(
src1
,
src2
,
block_size
,
shift_size
,
max_range
,
false
,
velx
,
vely
);
TEST_CYCLE_N
(
10
)
{
calcOpticalFlowBM
(
src1
,
src2
,
block_size
,
shift_size
,
max_range
,
false
,
velx
,
vely
);
}
}
SANITY_CHECK
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment