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
7cd42b8b
Commit
7cd42b8b
authored
Apr 11, 2012
by
Alexander Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified reduce test
parent
b7560332
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
test_mat.cpp
modules/core/test/test_mat.cpp
+26
-10
No files found.
modules/core/test/test_mat.cpp
View file @
7cd42b8b
...
...
@@ -10,7 +10,7 @@ public:
Core_ReduceTest
()
{};
protected
:
void
run
(
int
);
int
checkOp
(
const
Mat
&
src
,
int
dstType
,
int
opType
,
const
Mat
&
opRes
,
int
dim
,
double
eps
);
int
checkOp
(
const
Mat
&
src
,
int
dstType
,
int
opType
,
const
Mat
&
opRes
,
int
dim
);
int
checkCase
(
int
srcType
,
int
dstType
,
int
dim
,
Size
sz
);
int
checkDim
(
int
dim
,
Size
sz
);
int
checkSize
(
Size
sz
);
...
...
@@ -80,7 +80,7 @@ void getMatTypeStr( int type, string& str)
type
==
CV_64FC1
?
"CV_64FC1"
:
"unsupported matrix type"
;
}
int
Core_ReduceTest
::
checkOp
(
const
Mat
&
src
,
int
dstType
,
int
opType
,
const
Mat
&
opRes
,
int
dim
,
double
eps
)
int
Core_ReduceTest
::
checkOp
(
const
Mat
&
src
,
int
dstType
,
int
opType
,
const
Mat
&
opRes
,
int
dim
)
{
int
srcType
=
src
.
type
();
bool
support
=
false
;
...
...
@@ -117,12 +117,30 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
}
if
(
!
support
)
return
cvtest
::
TS
::
OK
;
double
eps
=
0.0
;
if
(
opType
==
CV_REDUCE_SUM
||
opType
==
CV_REDUCE_AVG
)
{
if
(
dstType
==
CV_32F
)
eps
=
1.e-5
;
else
if
(
dstType
==
CV_64F
)
eps
=
1.e-8
;
else
if
(
dstType
==
CV_32S
)
eps
=
0.6
;
}
assert
(
opRes
.
type
()
==
CV_64FC1
);
Mat
_dst
,
dst
;
Mat
_dst
,
dst
,
diff
;
reduce
(
src
,
_dst
,
dim
,
opType
,
dstType
);
_dst
.
convertTo
(
dst
,
CV_64FC1
);
if
(
norm
(
opRes
,
dst
,
NORM_INF
)
>
eps
)
absdiff
(
opRes
,
dst
,
diff
);
bool
check
=
false
;
if
(
dstType
==
CV_32F
||
dstType
==
CV_64F
)
check
=
countNonZero
(
diff
>
eps
*
dst
)
>
0
;
else
check
=
countNonZero
(
diff
>
eps
)
>
0
;
if
(
check
)
{
char
msg
[
100
];
const
char
*
opTypeStr
=
opType
==
CV_REDUCE_SUM
?
"CV_REDUCE_SUM"
:
...
...
@@ -168,21 +186,19 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
assert
(
0
);
// 1. sum
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_SUM
,
sum
,
dim
,
srcType
==
CV_32FC1
&&
dstType
==
CV_32FC1
?
0.05
:
FLT_EPSILON
);
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_SUM
,
sum
,
dim
);
code
=
tempCode
!=
cvtest
::
TS
::
OK
?
tempCode
:
code
;
// 2. avg
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_AVG
,
avg
,
dim
,
dstType
==
CV_32SC1
?
0.6
:
0.00007
);
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_AVG
,
avg
,
dim
);
code
=
tempCode
!=
cvtest
::
TS
::
OK
?
tempCode
:
code
;
// 3. max
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_MAX
,
max
,
dim
,
FLT_EPSILON
);
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_MAX
,
max
,
dim
);
code
=
tempCode
!=
cvtest
::
TS
::
OK
?
tempCode
:
code
;
// 4. min
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_MIN
,
min
,
dim
,
FLT_EPSILON
);
tempCode
=
checkOp
(
src
,
dstType
,
CV_REDUCE_MIN
,
min
,
dim
);
code
=
tempCode
!=
cvtest
::
TS
::
OK
?
tempCode
:
code
;
return
code
;
...
...
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