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
d2c2c07a
Commit
d2c2c07a
authored
Jan 11, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the new arithmetic tests
parent
57f917d6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
26 deletions
+71
-26
test_arithm.cpp
modules/core/test/test_arithm.cpp
+52
-16
gtestcv.hpp
modules/gtest/include/opencv2/gtest/gtestcv.hpp
+19
-10
gtestcv.cpp
modules/gtest/src/gtestcv.cpp
+0
-0
No files found.
modules/core/test/test_arithm.cpp
View file @
d2c2c07a
#include "precomp.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
const
int
ARITHM_NTESTS
=
1000
;
const
int
ARITHM_RNG_SEED
=
-
1
;
const
int
ARITHM_MAX_NDIMS
=
4
;
const
int
ARITHM_MAX_SIZE_LOG
=
10
;
const
int
ARITHM_MAX_CHANNELS
=
4
;
static
void
getArithmValueRange
(
int
depth
,
double
&
minval
,
double
&
maxval
)
{
minval
=
depth
<
CV_32S
?
cvtest
::
getMinVal
(
depth
)
:
depth
==
CV_32S
?
-
1000000
:
-
1000.
;
maxval
=
depth
<
CV_32S
?
cvtest
::
getMinVal
(
depth
)
:
depth
==
CV_32S
?
1000000
:
1000.
;
}
static
double
getArithmMaxErr
(
int
depth
)
{
return
depth
<
CV_32F
?
0
:
4
;
}
TEST
(
ArithmTest
,
add
)
{
typedef
uchar
_Tp
;
Mat
A
(
30
,
30
,
DataType
<
_Tp
>::
type
),
B
(
A
.
size
(),
A
.
type
()),
C0
,
C
;
RNG
rng
(
-
1
);
rng
.
fill
(
A
,
RNG
::
UNIFORM
,
Scalar
::
all
(
0
),
Scalar
::
all
(
256
));
rng
.
fill
(
B
,
RNG
::
UNIFORM
,
Scalar
::
all
(
0
),
Scalar
::
all
(
256
));
C0
.
create
(
A
.
size
(),
A
.
type
());
int
i
,
j
,
cols
=
A
.
cols
*
A
.
channels
();
for
(
i
=
0
;
i
<
A
.
rows
;
i
++
)
int
testIdx
=
0
;
RNG
rng
(
ARITHM_RNG_SEED
);
for
(
testIdx
=
0
;
testIdx
<
ARITHM_NTESTS
;
testIdx
++
)
{
const
_Tp
*
aptr
=
A
.
ptr
<
_Tp
>
(
i
);
const
_Tp
*
bptr
=
B
.
ptr
<
_Tp
>
(
i
);
_Tp
*
cptr
=
C0
.
ptr
<
_Tp
>
(
i
);
for
(
j
=
0
;
j
<
cols
;
j
++
)
cptr
[
j
]
=
saturate_cast
<
_Tp
>
(
aptr
[
j
]
+
bptr
[
j
]);
double
minval
,
maxval
;
vector
<
int
>
size
;
cvtest
::
randomSize
(
rng
,
2
,
ARITHM_MAX_NDIMS
,
ARITHM_MAX_SIZE_LOG
,
size
);
int
type
=
cvtest
::
randomType
(
rng
,
cvtest
::
TYPE_MASK_ALL
,
1
,
ARITHM_MAX_CHANNELS
);
int
depth
=
CV_MAT_DEPTH
(
type
);
bool
haveMask
=
rng
.
uniform
(
0
,
4
)
==
0
;
getArithmValueRange
(
depth
,
minval
,
maxval
);
Mat
src1
=
cvtest
::
randomMat
(
rng
,
size
,
type
,
minval
,
maxval
,
true
);
Mat
src2
=
cvtest
::
randomMat
(
rng
,
size
,
type
,
minval
,
maxval
,
true
);
Mat
dst0
=
cvtest
::
randomMat
(
rng
,
size
,
type
,
minval
,
maxval
,
false
);
Mat
dst
=
cvtest
::
randomMat
(
rng
,
size
,
type
,
minval
,
maxval
,
true
);
Mat
mask
;
if
(
haveMask
)
{
mask
=
cvtest
::
randomMat
(
rng
,
size
,
CV_8U
,
0
,
2
,
true
);
cvtest
::
copy
(
dst0
,
dst
);
cvtest
::
add
(
src1
,
1
,
src2
,
1
,
Scalar
::
all
(
0
),
dst0
,
dst
.
type
());
cvtest
::
copy
(
dst
,
dst0
,
mask
,
true
);
add
(
src1
,
src2
,
dst
,
mask
);
}
else
{
cvtest
::
add
(
src1
,
1
,
src2
,
1
,
Scalar
::
all
(
0
),
dst0
,
dst
.
type
());
add
(
src1
,
src2
,
dst
);
}
double
maxErr
=
getArithmMaxErr
(
depth
);
vector
<
int
>
pos
;
ASSERT_TRUE
(
cvtest
::
cmpEps
(
dst0
,
dst
,
maxErr
,
&
pos
))
<<
"position: "
<<
Mat
(
pos
);
}
add
(
A
,
B
,
C
);
EXPECT_EQ
(
norm
(
C
,
C0
,
NORM_INF
),
0
);
}
modules/gtest/include/opencv2/gtest/gtestcv.hpp
View file @
d2c2c07a
...
...
@@ -27,29 +27,38 @@ enum
TYPE_MASK_ALL
=
(
TYPE_MASK_64F
<<
1
)
-
1
,
TYPE_MASK_ALL_BUT_8S
=
TYPE_MASK_ALL
&
~
TYPE_MASK_8S
};
CV_EXPORTS
double
getMinVal
(
int
depth
);
CV_EXPORTS
double
getMaxVal
(
int
depth
);
CV_EXPORTS
Size
randomSize
(
RNG
&
rng
,
double
maxSizeLog
);
CV_EXPORTS
void
randomSize
(
RNG
&
rng
,
int
minDims
,
int
maxDims
,
double
maxSizeLog
,
vector
<
int
>&
sz
);
CV_EXPORTS
int
randomType
(
RNG
&
rng
,
int
typeMask
,
int
minChannels
,
int
maxChannels
);
CV_EXPORTS
Mat
randomMat
(
RNG
&
rng
,
Size
size
,
int
type
,
bool
useRoi
);
CV_EXPORTS
Mat
randomMat
(
RNG
&
rng
,
const
vector
<
int
>&
size
,
int
type
,
bool
useRoi
);
CV_EXPORTS
Mat
randomMat
(
RNG
&
rng
,
Size
size
,
int
type
,
double
minVal
,
double
maxVal
,
bool
useRoi
);
CV_EXPORTS
Mat
randomMat
(
RNG
&
rng
,
const
vector
<
int
>&
size
,
int
type
,
double
minVal
,
double
maxVal
,
bool
useRoi
);
CV_EXPORTS
void
add
(
const
Mat
&
a
,
double
alpha
,
const
Mat
&
b
,
double
beta
,
Scalar
gamma
,
Mat
&
c
,
int
ctype
,
bool
calcAbs
);
CV_EXPORTS
void
convert
(
const
Mat
&
src
,
Mat
&
dst
,
int
dtype
,
double
alpha
,
double
beta
);
CV_EXPORTS
void
copy
(
const
Mat
&
src
,
Mat
&
dst
,
const
Mat
&
mask
=
Mat
());
Scalar
gamma
,
Mat
&
c
,
int
ctype
,
bool
calcAbs
=
false
);
CV_EXPORTS
void
convert
(
const
Mat
&
src
,
Mat
&
dst
,
int
dtype
,
double
alpha
=
1
,
double
beta
=
0
);
CV_EXPORTS
void
copy
(
const
Mat
&
src
,
Mat
&
dst
,
const
Mat
&
mask
=
Mat
()
,
bool
invertMask
=
false
);
CV_EXPORTS
void
set
(
Mat
&
dst
,
const
Scalar
&
gamma
,
const
Mat
&
mask
=
Mat
());
CV_EXPORTS
void
minMaxFilter
(
const
Mat
&
a
,
Mat
&
maxresult
,
const
Mat
&
minresult
,
const
Mat
&
kernel
,
Point
anchor
);
CV_EXPORTS
void
filter2D
(
const
Mat
&
src
,
Mat
&
dst
,
int
ddepth
,
const
Mat
&
kernel
,
Point
anchor
,
double
delta
,
int
borderType
);
CV_EXPORTS
void
copyMakeBorder
(
const
Mat
&
src
,
Mat
&
dst
,
int
top
,
int
bottom
,
int
left
,
int
right
,
int
borderType
,
Scalar
borderValue
);
CV_EXPORTS
void
erode
(
const
Mat
&
src
,
Mat
&
dst
,
const
Mat
&
_kernel
,
Point
anchor
=
Point
(
-
1
,
-
1
),
int
borderType
=
IPL_BORDER_CONSTANT
,
const
Scalar
&
borderValue
=
Scalar
());
CV_EXPORTS
void
dilate
(
const
Mat
&
src
,
Mat
&
dst
,
const
Mat
&
_kernel
,
Point
anchor
=
Point
(
-
1
,
-
1
),
int
borderType
=
IPL_BORDER_CONSTANT
,
const
Scalar
&
borderValue
=
Scalar
());
CV_EXPORTS
void
filter2D
(
const
Mat
&
src
,
Mat
&
dst
,
int
ddepth
,
const
Mat
&
kernel
,
Point
anchor
,
double
delta
,
int
borderType
,
const
Scalar
&
borderValue
=
Scalar
());
CV_EXPORTS
void
copyMakeBorder
(
const
Mat
&
src
,
Mat
&
dst
,
int
top
,
int
bottom
,
int
left
,
int
right
,
int
borderType
,
const
Scalar
&
borderValue
=
Scalar
());
CV_EXPORTS
void
minMaxLoc
(
const
Mat
&
src
,
double
*
maxval
,
double
*
minval
,
vector
<
int
>*
maxloc
,
vector
<
int
>*
minloc
,
const
Mat
&
mask
=
Mat
());
CV_EXPORTS
double
norm
(
const
Mat
&
src
,
int
normType
,
const
Mat
&
mask
=
Mat
());
CV_EXPORTS
double
norm
(
const
Mat
&
src1
,
const
Mat
&
src2
,
int
normType
,
const
Mat
&
mask
=
Mat
());
CV_EXPORTS
bool
cmpEps
(
const
Mat
&
src1
,
const
Mat
&
src2
,
double
maxDiff
,
vector
<
int
>*
loc
);
CV_EXPORTS
bool
cmpEps
(
const
Mat
&
src1
,
const
Mat
&
src2
,
int
maxDiff
,
vector
<
int
>*
loc
);
CV_EXPORTS
void
logicOp
(
const
Mat
&
src1
,
const
Mat
&
src2
,
Mat
&
dst
,
char
c
);
CV_EXPORTS
void
logicOp
(
const
Mat
&
src
,
const
Scalar
&
s
,
Mat
&
dst
,
char
c
);
CV_EXPORTS
void
compare
(
const
Mat
&
src1
,
const
Mat
&
src2
,
Mat
&
dst
,
int
cmpop
);
CV_EXPORTS
void
compare
(
const
Mat
&
src
,
const
Scalar
&
s
,
Mat
&
dst
,
int
cmpop
);
CV_EXPORTS
void
compare
(
const
Mat
&
src
,
double
s
,
Mat
&
dst
,
int
cmpop
);
CV_EXPORTS
void
gemm
(
const
Mat
&
src1
,
const
Mat
&
src2
,
double
alpha
,
const
Mat
&
src3
,
double
beta
,
Mat
&
dst
,
int
flags
);
CV_EXPORTS
void
crosscorr
(
const
Mat
&
src1
,
const
Mat
&
src2
,
Mat
&
dst
,
int
dtype
);
...
...
modules/gtest/src/gtestcv.cpp
View file @
d2c2c07a
This diff is collapsed.
Click to expand it.
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