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
a24ebc99
Commit
a24ebc99
authored
Dec 13, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7840 from alalek:fix_test_rng
parents
7a3b5b30
ec859ceb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
10 deletions
+34
-10
test_chessboardgenerator.cpp
modules/calib3d/test/test_chessboardgenerator.cpp
+4
-2
test_hal_core.cpp
modules/core/test/test_hal_core.cpp
+19
-5
ts.hpp
modules/ts/include/opencv2/ts.hpp
+3
-1
ts_ext.hpp
modules/ts/include/opencv2/ts/ts_ext.hpp
+3
-1
ts.cpp
modules/ts/src/ts.cpp
+5
-0
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+0
-1
No files found.
modules/calib3d/test/test_chessboardgenerator.cpp
View file @
a24ebc99
...
@@ -51,7 +51,7 @@ using namespace cv;
...
@@ -51,7 +51,7 @@ using namespace cv;
using
namespace
std
;
using
namespace
std
;
ChessBoardGenerator
::
ChessBoardGenerator
(
const
Size
&
_patternSize
)
:
sensorWidth
(
32
),
sensorHeight
(
24
),
ChessBoardGenerator
::
ChessBoardGenerator
(
const
Size
&
_patternSize
)
:
sensorWidth
(
32
),
sensorHeight
(
24
),
squareEdgePointsNum
(
200
),
min_cos
(
std
::
sqrt
(
2
.
f
)
*
0.5
f
),
cov
(
0.5
),
squareEdgePointsNum
(
200
),
min_cos
(
std
::
sqrt
(
3
.
f
)
*
0.5
f
),
cov
(
0.5
),
patternSize
(
_patternSize
),
rendererResolutionMultiplier
(
4
),
tvec
(
Mat
::
zeros
(
1
,
3
,
CV_32F
))
patternSize
(
_patternSize
),
rendererResolutionMultiplier
(
4
),
tvec
(
Mat
::
zeros
(
1
,
3
,
CV_32F
))
{
{
Rodrigues
(
Mat
::
eye
(
3
,
3
,
CV_32F
),
rvec
);
Rodrigues
(
Mat
::
eye
(
3
,
3
,
CV_32F
),
rvec
);
...
@@ -85,8 +85,10 @@ void cv::ChessBoardGenerator::generateBasis(Point3f& pb1, Point3f& pb2) const
...
@@ -85,8 +85,10 @@ void cv::ChessBoardGenerator::generateBasis(Point3f& pb1, Point3f& pb2) const
{
{
n
[
0
]
=
rng
.
uniform
(
-
1.
f
,
1.
f
);
n
[
0
]
=
rng
.
uniform
(
-
1.
f
,
1.
f
);
n
[
1
]
=
rng
.
uniform
(
-
1.
f
,
1.
f
);
n
[
1
]
=
rng
.
uniform
(
-
1.
f
,
1.
f
);
n
[
2
]
=
rng
.
uniform
(
-
1.
f
,
1.
f
);
n
[
2
]
=
rng
.
uniform
(
0.0
f
,
1.
f
);
float
len
=
(
float
)
norm
(
n
);
float
len
=
(
float
)
norm
(
n
);
if
(
len
<
1e-3
)
continue
;
n
[
0
]
/=
len
;
n
[
0
]
/=
len
;
n
[
1
]
/=
len
;
n
[
1
]
/=
len
;
n
[
2
]
/=
len
;
n
[
2
]
/=
len
;
...
...
modules/core/test/test_hal_core.cpp
View file @
a24ebc99
...
@@ -120,15 +120,20 @@ TEST(Core_HAL, mathfuncs)
...
@@ -120,15 +120,20 @@ TEST(Core_HAL, mathfuncs)
}
}
}
}
namespace
{
enum
enum
{
{
HAL_LU
=
0
,
HAL_LU
=
0
,
HAL_CHOL
=
1
HAL_CHOL
=
1
};
};
TEST
(
Core_HAL
,
mat_decomp
)
typedef
testing
::
TestWithParam
<
int
>
HAL
;
TEST_P
(
HAL
,
mat_decomp
)
{
{
for
(
int
hcase
=
0
;
hcase
<
16
;
hcase
++
)
int
hcase
=
GetParam
();
SCOPED_TRACE
(
cv
::
format
(
"hcase=%d"
,
hcase
));
{
{
int
depth
=
hcase
%
2
==
0
?
CV_32F
:
CV_64F
;
int
depth
=
hcase
%
2
==
0
?
CV_32F
:
CV_64F
;
int
size
=
(
hcase
/
2
)
%
4
;
int
size
=
(
hcase
/
2
)
%
4
;
...
@@ -137,7 +142,7 @@ TEST(Core_HAL, mat_decomp)
...
@@ -137,7 +142,7 @@ TEST(Core_HAL, mat_decomp)
double
eps
=
depth
==
CV_32F
?
1e-5
:
1e-10
;
double
eps
=
depth
==
CV_32F
?
1e-5
:
1e-10
;
if
(
size
==
3
)
if
(
size
==
3
)
continue
;
return
;
// TODO ???
Mat
a0
(
size
,
size
,
depth
),
a
(
size
,
size
,
depth
),
b
(
size
,
1
,
depth
),
x
(
size
,
1
,
depth
),
x0
(
size
,
1
,
depth
);
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
);
randu
(
a0
,
-
1
,
1
);
...
@@ -175,14 +180,19 @@ TEST(Core_HAL, mat_decomp)
...
@@ -175,14 +180,19 @@ TEST(Core_HAL, mat_decomp)
min_hal_t
=
std
::
min
(
min_hal_t
,
t
);
min_hal_t
=
std
::
min
(
min_hal_t
,
t
);
t
=
(
double
)
getTickCount
();
t
=
(
double
)
getTickCount
();
solve
(
a0
,
b
,
x0
,
(
nfunc
==
HAL_LU
?
DECOMP_LU
:
DECOMP_CHOLESKY
));
bool
solveStatus
=
solve
(
a0
,
b
,
x0
,
(
nfunc
==
HAL_LU
?
DECOMP_LU
:
DECOMP_CHOLESKY
));
t
=
(
double
)
getTickCount
()
-
t
;
t
=
(
double
)
getTickCount
()
-
t
;
EXPECT_TRUE
(
solveStatus
);
min_ocv_t
=
std
::
min
(
min_ocv_t
,
t
);
min_ocv_t
=
std
::
min
(
min_ocv_t
,
t
);
}
}
//std::cout << "x: " << Mat(x.t()) << std::endl;
//std::cout << "x: " << Mat(x.t()) << std::endl;
//std::cout << "x0: " << Mat(x0.t()) << std::endl;
//std::cout << "x0: " << Mat(x0.t()) << std::endl;
EXPECT_LE
(
norm
(
x
,
x0
,
NORM_INF
|
NORM_RELATIVE
),
eps
);
EXPECT_LE
(
norm
(
x
,
x0
,
NORM_INF
|
NORM_RELATIVE
),
eps
)
<<
"x: "
<<
Mat
(
x
.
t
())
<<
"
\n
x0: "
<<
Mat
(
x0
.
t
())
<<
"
\n
a0: "
<<
a0
<<
"
\n
b: "
<<
b
;
double
freq
=
getTickFrequency
();
double
freq
=
getTickFrequency
();
printf
(
"%s (%d x %d, %s): hal time=%.2fusec, ocv time=%.2fusec
\n
"
,
printf
(
"%s (%d x %d, %s): hal time=%.2fusec, ocv time=%.2fusec
\n
"
,
...
@@ -192,3 +202,7 @@ TEST(Core_HAL, mat_decomp)
...
@@ -192,3 +202,7 @@ TEST(Core_HAL, mat_decomp)
min_hal_t
*
1e6
/
freq
,
min_ocv_t
*
1e6
/
freq
);
min_hal_t
*
1e6
/
freq
,
min_ocv_t
*
1e6
/
freq
);
}
}
}
}
INSTANTIATE_TEST_CASE_P
(
Core
,
HAL
,
testing
::
Range
(
0
,
16
));
}
// namespace
modules/ts/include/opencv2/ts.hpp
View file @
a24ebc99
...
@@ -539,11 +539,13 @@ protected:
...
@@ -539,11 +539,13 @@ protected:
}
}
};
};
extern
uint64
param_seed
;
struct
CV_EXPORTS
DefaultRngAuto
struct
CV_EXPORTS
DefaultRngAuto
{
{
const
uint64
old_state
;
const
uint64
old_state
;
DefaultRngAuto
()
:
old_state
(
cv
::
theRNG
().
state
)
{
cv
::
theRNG
().
state
=
(
uint64
)
-
1
;
}
DefaultRngAuto
()
:
old_state
(
cv
::
theRNG
().
state
)
{
cv
::
theRNG
().
state
=
cvtest
::
param_seed
;
}
~
DefaultRngAuto
()
{
cv
::
theRNG
().
state
=
old_state
;
}
~
DefaultRngAuto
()
{
cv
::
theRNG
().
state
=
old_state
;
}
DefaultRngAuto
&
operator
=
(
const
DefaultRngAuto
&
);
DefaultRngAuto
&
operator
=
(
const
DefaultRngAuto
&
);
...
...
modules/ts/include/opencv2/ts/ts_ext.hpp
View file @
a24ebc99
...
@@ -12,7 +12,9 @@ namespace cvtest {
...
@@ -12,7 +12,9 @@ namespace cvtest {
void
checkIppStatus
();
void
checkIppStatus
();
}
}
#define CV_TEST_INIT cv::ipp::setIppStatus(0);
#define CV_TEST_INIT \
cv::ipp::setIppStatus(0); \
cv::theRNG().state = cvtest::param_seed;
#define CV_TEST_CLEANUP ::cvtest::checkIppStatus();
#define CV_TEST_CLEANUP ::cvtest::checkIppStatus();
#define CV_TEST_BODY_IMPL \
#define CV_TEST_BODY_IMPL \
{ \
{ \
...
...
modules/ts/src/ts.cpp
View file @
a24ebc99
...
@@ -80,6 +80,8 @@
...
@@ -80,6 +80,8 @@
namespace
cvtest
namespace
cvtest
{
{
uint64
param_seed
=
0x12345678
;
// real value is passed via parseCustomOptions function
static
std
::
string
path_join
(
const
std
::
string
&
prefix
,
const
std
::
string
&
subpath
)
static
std
::
string
path_join
(
const
std
::
string
&
prefix
,
const
std
::
string
&
subpath
)
{
{
CV_Assert
(
subpath
.
empty
()
||
subpath
[
0
]
!=
'/'
);
CV_Assert
(
subpath
.
empty
()
||
subpath
[
0
]
!=
'/'
);
...
@@ -695,6 +697,7 @@ void parseCustomOptions(int argc, char **argv)
...
@@ -695,6 +697,7 @@ void parseCustomOptions(int argc, char **argv)
{
{
const
char
*
const
command_line_keys
=
const
char
*
const
command_line_keys
=
"{ ipp test_ipp_check |false |check whether IPP works without failures }"
"{ ipp test_ipp_check |false |check whether IPP works without failures }"
"{ test_seed |809564 |seed for random numbers generator }"
"{ h help |false |print help info }"
;
"{ h help |false |print help info }"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
command_line_keys
);
cv
::
CommandLineParser
parser
(
argc
,
argv
,
command_line_keys
);
...
@@ -711,6 +714,8 @@ void parseCustomOptions(int argc, char **argv)
...
@@ -711,6 +714,8 @@ void parseCustomOptions(int argc, char **argv)
#else
#else
test_ipp_check
=
false
;
test_ipp_check
=
false
;
#endif
#endif
param_seed
=
parser
.
get
<
unsigned
int
>
(
"test_seed"
);
}
}
...
...
modules/ts/src/ts_perf.cpp
View file @
a24ebc99
...
@@ -38,7 +38,6 @@ static double param_max_outliers;
...
@@ -38,7 +38,6 @@ static double param_max_outliers;
static
double
param_max_deviation
;
static
double
param_max_deviation
;
static
unsigned
int
param_min_samples
;
static
unsigned
int
param_min_samples
;
static
unsigned
int
param_force_samples
;
static
unsigned
int
param_force_samples
;
static
uint64
param_seed
;
static
double
param_time_limit
;
static
double
param_time_limit
;
static
int
param_threads
;
static
int
param_threads
;
static
bool
param_write_sanity
;
static
bool
param_write_sanity
;
...
...
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