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
1887dcb3
Commit
1887dcb3
authored
Jun 05, 2017
by
Dinar
Committed by
Dinar Ahmatnurov
Jun 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for videostab;
parent
ebd98eaf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
190 additions
and
0 deletions
+190
-0
test_main.cpp
modules/videostab/test/test_main.cpp
+3
-0
test_motion_estimation.cpp
modules/videostab/test/test_motion_estimation.cpp
+171
-0
test_precomp.hpp
modules/videostab/test/test_precomp.hpp
+16
-0
No files found.
modules/videostab/test/test_main.cpp
0 → 100644
View file @
1887dcb3
#include "test_precomp.hpp"
CV_TEST_MAIN
(
"cv"
)
modules/videostab/test/test_motion_estimation.cpp
0 → 100644
View file @
1887dcb3
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#include "test_precomp.hpp"
namespace
testUtil
{
cv
::
RNG
rng
(
/*std::time(0)*/
0
);
const
float
sigma
=
1.
f
;
const
float
pointsMaxX
=
500.
f
;
const
float
pointsMaxY
=
500.
f
;
const
int
testRun
=
5000
;
void
generatePoints
(
cv
::
Mat
points
);
void
addNoise
(
cv
::
Mat
points
);
cv
::
Mat
generateTransform
(
const
cv
::
videostab
::
MotionModel
model
);
double
performTest
(
const
cv
::
videostab
::
MotionModel
model
,
int
size
);
}
void
testUtil
::
generatePoints
(
cv
::
Mat
points
)
{
CV_Assert
(
!
points
.
empty
());
for
(
int
i
=
0
;
i
<
points
.
cols
;
++
i
)
{
points
.
at
<
float
>
(
0
,
i
)
=
rng
.
uniform
(
0.
f
,
pointsMaxX
);
points
.
at
<
float
>
(
1
,
i
)
=
rng
.
uniform
(
0.
f
,
pointsMaxY
);
points
.
at
<
float
>
(
2
,
i
)
=
1.
f
;
}
}
void
testUtil
::
addNoise
(
cv
::
Mat
points
)
{
CV_Assert
(
!
points
.
empty
());
for
(
int
i
=
0
;
i
<
points
.
cols
;
i
++
)
{
points
.
at
<
float
>
(
0
,
i
)
+=
static_cast
<
float
>
(
rng
.
gaussian
(
sigma
));
points
.
at
<
float
>
(
1
,
i
)
+=
static_cast
<
float
>
(
rng
.
gaussian
(
sigma
));
}
}
cv
::
Mat
testUtil
::
generateTransform
(
const
cv
::
videostab
::
MotionModel
model
)
{
/*----------Params----------*/
const
float
minAngle
=
0.
f
,
maxAngle
=
static_cast
<
float
>
(
CV_PI
);
const
float
minScale
=
0.5
f
,
maxScale
=
2.
f
;
const
float
maxTranslation
=
100.
f
;
const
float
affineCoeff
=
3.
f
;
/*----------Params----------*/
cv
::
Mat
transform
=
cv
::
Mat
::
eye
(
3
,
3
,
CV_32F
);
if
(
model
!=
cv
::
videostab
::
MM_ROTATION
)
{
transform
.
at
<
float
>
(
0
,
2
)
=
rng
.
uniform
(
-
maxTranslation
,
maxTranslation
);
transform
.
at
<
float
>
(
1
,
2
)
=
rng
.
uniform
(
-
maxTranslation
,
maxTranslation
);
}
if
(
model
!=
cv
::
videostab
::
MM_AFFINE
)
{
if
(
model
!=
cv
::
videostab
::
MM_TRANSLATION_AND_SCALE
&&
model
!=
cv
::
videostab
::
MM_TRANSLATION
)
{
const
float
angle
=
rng
.
uniform
(
minAngle
,
maxAngle
);
transform
.
at
<
float
>
(
1
,
1
)
=
transform
.
at
<
float
>
(
0
,
0
)
=
std
::
cos
(
angle
);
transform
.
at
<
float
>
(
0
,
1
)
=
std
::
sin
(
angle
);
transform
.
at
<
float
>
(
1
,
0
)
=
-
transform
.
at
<
float
>
(
0
,
1
);
}
if
(
model
==
cv
::
videostab
::
MM_TRANSLATION_AND_SCALE
||
model
==
cv
::
videostab
::
MM_SIMILARITY
)
{
const
float
scale
=
rng
.
uniform
(
minScale
,
maxScale
);
transform
.
at
<
float
>
(
0
,
0
)
*=
scale
;
transform
.
at
<
float
>
(
1
,
1
)
*=
scale
;
}
}
else
{
transform
.
at
<
float
>
(
0
,
0
)
=
rng
.
uniform
(
-
affineCoeff
,
affineCoeff
);
transform
.
at
<
float
>
(
0
,
1
)
=
rng
.
uniform
(
-
affineCoeff
,
affineCoeff
);
transform
.
at
<
float
>
(
1
,
0
)
=
rng
.
uniform
(
-
affineCoeff
,
affineCoeff
);
transform
.
at
<
float
>
(
1
,
1
)
=
rng
.
uniform
(
-
affineCoeff
,
affineCoeff
);
}
return
transform
;
}
double
testUtil
::
performTest
(
const
cv
::
videostab
::
MotionModel
model
,
int
size
)
{
cv
::
Ptr
<
cv
::
videostab
::
MotionEstimatorRansacL2
>
estimator
=
cv
::
makePtr
<
cv
::
videostab
::
MotionEstimatorRansacL2
>
(
model
);
estimator
->
setRansacParams
(
cv
::
videostab
::
RansacParams
(
size
,
3.
f
*
testUtil
::
sigma
/*3 sigma rule*/
,
0.5
f
,
0.5
f
));
double
disparity
=
0.
;
for
(
int
attempt
=
0
;
attempt
<
testUtil
::
testRun
;
attempt
++
)
{
const
cv
::
Mat
transform
=
testUtil
::
generateTransform
(
model
);
const
int
pointsNumber
=
testUtil
::
rng
.
uniform
(
10
,
100
);
cv
::
Mat
points
(
3
,
pointsNumber
,
CV_32F
);
testUtil
::
generatePoints
(
points
);
cv
::
Mat
transformedPoints
=
transform
*
points
;
testUtil
::
addNoise
(
transformedPoints
);
const
cv
::
Mat
src
=
points
.
rowRange
(
0
,
2
).
t
();
const
cv
::
Mat
dst
=
transformedPoints
.
rowRange
(
0
,
2
).
t
();
bool
isOK
=
false
;
const
cv
::
Mat
estTransform
=
estimator
->
estimate
(
src
.
reshape
(
2
),
dst
.
reshape
(
2
),
&
isOK
);
CV_Assert
(
isOK
);
const
cv
::
Mat
testPoints
=
estTransform
*
points
;
const
double
norm
=
cv
::
norm
(
testPoints
,
transformedPoints
,
cv
::
NORM_INF
);
disparity
=
std
::
max
(
disparity
,
norm
);
}
return
disparity
;
}
TEST
(
Regression
,
MM_TRANSLATION
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_TRANSLATION
,
2
),
7.
f
);
}
TEST
(
Regression
,
MM_TRANSLATION_AND_SCALE
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_TRANSLATION_AND_SCALE
,
3
),
7.
f
);
}
TEST
(
Regression
,
MM_ROTATION
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_ROTATION
,
2
),
7.
f
);
}
TEST
(
Regression
,
MM_RIGID
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_RIGID
,
3
),
7.
f
);
}
TEST
(
Regression
,
MM_SIMILARITY
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_SIMILARITY
,
4
),
7.
f
);
}
TEST
(
Regression
,
MM_AFFINE
)
{
EXPECT_LT
(
testUtil
::
performTest
(
cv
::
videostab
::
MM_AFFINE
,
6
),
9.
f
);
}
modules/videostab/test/test_precomp.hpp
0 → 100644
View file @
1887dcb3
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include <iostream>
#include "opencv2/ts.hpp"
#include "opencv2/videostab.hpp"
#endif
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