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
8aa3eb81
Commit
8aa3eb81
authored
Sep 24, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored arithm.cpp. Extended param list for all the tests
parent
b4ad1282
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
662 additions
and
605 deletions
+662
-605
arithm.cpp
modules/ocl/src/arithm.cpp
+30
-16
test_arithm.cpp
modules/ocl/test/test_arithm.cpp
+632
-589
No files found.
modules/ocl/src/arithm.cpp
View file @
8aa3eb81
...
@@ -97,9 +97,6 @@ namespace cv
...
@@ -97,9 +97,6 @@ namespace cv
extern
const
char
*
arithm_setidentity
;
extern
const
char
*
arithm_setidentity
;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
/////////////////////// add subtract multiply divide /////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/////////////////////// add subtract multiply divide /////////////////////////
/////////////////////// add subtract multiply divide /////////////////////////
...
@@ -251,7 +248,7 @@ void cv::ocl::divide(double scalar, const oclMat &src, oclMat &dst)
...
@@ -251,7 +248,7 @@ void cv::ocl::divide(double scalar, const oclMat &src, oclMat &dst)
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
Absdiff
///////////////////////////////////
/////////////////////////////////
Absdiff /
///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
cv
::
ocl
::
absdiff
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
)
void
cv
::
ocl
::
absdiff
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
)
...
@@ -430,9 +427,11 @@ Scalar cv::ocl::sqrSum(const oclMat &src)
...
@@ -430,9 +427,11 @@ Scalar cv::ocl::sqrSum(const oclMat &src)
func
=
functab
[(
int
)
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)];
func
=
functab
[(
int
)
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)];
return
func
(
src
,
2
);
return
func
(
src
,
2
);
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// meanStdDev //////////////////////////////////
//////////////////////////////// meanStdDev //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
cv
::
ocl
::
meanStdDev
(
const
oclMat
&
src
,
Scalar
&
mean
,
Scalar
&
stddev
)
void
cv
::
ocl
::
meanStdDev
(
const
oclMat
&
src
,
Scalar
&
mean
,
Scalar
&
stddev
)
{
{
CV_Assert
(
src
.
depth
()
<=
CV_32S
);
CV_Assert
(
src
.
depth
()
<=
CV_32S
);
...
@@ -441,8 +440,10 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
...
@@ -441,8 +440,10 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
Mat
m1
(
sz
,
CV_MAKETYPE
(
CV_32S
,
channels
),
cv
::
Scalar
::
all
(
0
)),
Mat
m1
(
sz
,
CV_MAKETYPE
(
CV_32S
,
channels
),
cv
::
Scalar
::
all
(
0
)),
m2
(
sz
,
CV_MAKETYPE
(
CV_32S
,
channels
),
cv
::
Scalar
::
all
(
0
));
m2
(
sz
,
CV_MAKETYPE
(
CV_32S
,
channels
),
cv
::
Scalar
::
all
(
0
));
oclMat
dst1
(
m1
),
dst2
(
m2
);
oclMat
dst1
(
m1
),
dst2
(
m2
);
//arithmetic_sum_run(src, dst1,"arithm_op_sum");
//arithmetic_sum_run(src, dst1,"arithm_op_sum");
//arithmetic_sum_run(src, dst2,"arithm_op_squares_sum");
//arithmetic_sum_run(src, dst2,"arithm_op_squares_sum");
m1
=
(
Mat
)
dst1
;
m1
=
(
Mat
)
dst1
;
m2
=
(
Mat
)
dst2
;
m2
=
(
Mat
)
dst2
;
int
i
=
0
,
*
p
=
(
int
*
)
m1
.
data
,
*
q
=
(
int
*
)
m2
.
data
;
int
i
=
0
,
*
p
=
(
int
*
)
m1
.
data
,
*
q
=
(
int
*
)
m2
.
data
;
...
@@ -456,6 +457,7 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
...
@@ -456,6 +457,7 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// minMax /////////////////////////////////
//////////////////////////////////// minMax /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_minMax_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
static
void
arithmetic_minMax_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
{
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
@@ -572,6 +574,7 @@ void cv::ocl::minMax(const oclMat &src, double *minVal, double *maxVal, const oc
...
@@ -572,6 +574,7 @@ void cv::ocl::minMax(const oclMat &src, double *minVal, double *maxVal, const oc
oclMat
buf
;
oclMat
buf
;
minMax_buf
(
src
,
minVal
,
maxVal
,
mask
,
buf
);
minMax_buf
(
src
,
minVal
,
maxVal
,
mask
,
buf
);
}
}
void
cv
::
ocl
::
minMax_buf
(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
const
oclMat
&
mask
,
oclMat
&
buf
)
void
cv
::
ocl
::
minMax_buf
(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
const
oclMat
&
mask
,
oclMat
&
buf
)
{
{
CV_Assert
(
src
.
oclchannels
()
==
1
);
CV_Assert
(
src
.
oclchannels
()
==
1
);
...
@@ -598,6 +601,7 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons
...
@@ -598,6 +601,7 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// norm /////////////////////////////////////
/////////////////////////////////// norm /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
double
cv
::
ocl
::
norm
(
const
oclMat
&
src1
,
int
normType
)
double
cv
::
ocl
::
norm
(
const
oclMat
&
src1
,
int
normType
)
{
{
return
norm
(
src1
,
oclMat
(
src1
.
size
(),
src1
.
type
(),
Scalar
::
all
(
0
)),
normType
);
return
norm
(
src1
,
oclMat
(
src1
.
size
(),
src1
.
type
(),
Scalar
::
all
(
0
)),
normType
);
...
@@ -657,6 +661,7 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
...
@@ -657,6 +661,7 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// flip //////////////////////////////////////
////////////////////////////////// flip //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_flip_rows_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
static
void
arithmetic_flip_rows_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
{
{
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
type
()
==
CV_64F
)
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
type
()
==
CV_64F
)
...
@@ -703,6 +708,7 @@ static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kern
...
@@ -703,6 +708,7 @@ static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kern
openCLExecuteKernel
(
clCxt
,
&
arithm_flip
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
clCxt
,
&
arithm_flip
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
}
static
void
arithmetic_flip_cols_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
bool
isVertical
)
static
void
arithmetic_flip_cols_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
bool
isVertical
)
{
{
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
type
()
==
CV_64F
)
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
type
()
==
CV_64F
)
...
@@ -755,6 +761,7 @@ static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kern
...
@@ -755,6 +761,7 @@ static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kern
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
depth
);
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
depth
);
}
}
void
cv
::
ocl
::
flip
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
flipCode
)
void
cv
::
ocl
::
flip
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
flipCode
)
{
{
dst
.
create
(
src
.
size
(),
src
.
type
());
dst
.
create
(
src
.
size
(),
src
.
type
());
...
@@ -868,6 +875,7 @@ void cv::ocl::log(const oclMat &src, oclMat &dst)
...
@@ -868,6 +875,7 @@ void cv::ocl::log(const oclMat &src, oclMat &dst)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// magnitude phase ///////////////////////////////
////////////////////////////// magnitude phase ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_magnitude_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
static
void
arithmetic_magnitude_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
{
{
if
(
!
src1
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src1
.
type
()
==
CV_64F
)
if
(
!
src1
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src1
.
type
()
==
CV_64F
)
...
@@ -951,6 +959,7 @@ static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat
...
@@ -951,6 +959,7 @@ static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
}
void
cv
::
ocl
::
phase
(
const
oclMat
&
x
,
const
oclMat
&
y
,
oclMat
&
Angle
,
bool
angleInDegrees
)
void
cv
::
ocl
::
phase
(
const
oclMat
&
x
,
const
oclMat
&
y
,
oclMat
&
Angle
,
bool
angleInDegrees
)
{
{
CV_Assert
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
(
x
.
depth
()
==
CV_32F
||
x
.
depth
()
==
CV_64F
));
CV_Assert
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
(
x
.
depth
()
==
CV_32F
||
x
.
depth
()
==
CV_64F
));
...
@@ -965,6 +974,7 @@ void cv::ocl::phase(const oclMat &x, const oclMat &y, oclMat &Angle , bool angle
...
@@ -965,6 +974,7 @@ void cv::ocl::phase(const oclMat &x, const oclMat &y, oclMat &Angle , bool angle
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// cartToPolar ///////////////////////////////
////////////////////////////////// cartToPolar ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_cartToPolar_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst_mag
,
oclMat
&
dst_cart
,
static
void
arithmetic_cartToPolar_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst_mag
,
oclMat
&
dst_cart
,
string
kernelName
,
bool
angleInDegrees
)
string
kernelName
,
bool
angleInDegrees
)
{
{
...
@@ -1003,6 +1013,7 @@ static void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, o
...
@@ -1003,6 +1013,7 @@ static void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, o
openCLExecuteKernel
(
clCxt
,
&
arithm_cartToPolar
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
clCxt
,
&
arithm_cartToPolar
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
}
void
cv
::
ocl
::
cartToPolar
(
const
oclMat
&
x
,
const
oclMat
&
y
,
oclMat
&
mag
,
oclMat
&
angle
,
bool
angleInDegrees
)
void
cv
::
ocl
::
cartToPolar
(
const
oclMat
&
x
,
const
oclMat
&
y
,
oclMat
&
mag
,
oclMat
&
angle
,
bool
angleInDegrees
)
{
{
CV_Assert
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
(
x
.
depth
()
==
CV_32F
||
x
.
depth
()
==
CV_64F
));
CV_Assert
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
(
x
.
depth
()
==
CV_32F
||
x
.
depth
()
==
CV_64F
));
...
@@ -1016,6 +1027,7 @@ void cv::ocl::cartToPolar(const oclMat &x, const oclMat &y, oclMat &mag, oclMat
...
@@ -1016,6 +1027,7 @@ void cv::ocl::cartToPolar(const oclMat &x, const oclMat &y, oclMat &mag, oclMat
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// polarToCart ///////////////////////////////
////////////////////////////////// polarToCart ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_ptc_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst1
,
oclMat
&
dst2
,
bool
angleInDegrees
,
static
void
arithmetic_ptc_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst1
,
oclMat
&
dst2
,
bool
angleInDegrees
,
string
kernelName
)
string
kernelName
)
{
{
...
@@ -1078,6 +1090,7 @@ void cv::ocl::polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &
...
@@ -1078,6 +1090,7 @@ void cv::ocl::polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// minMaxLoc ////////////////////////////////
/////////////////////////////////// minMaxLoc ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_minMaxLoc_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
static
void
arithmetic_minMaxLoc_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
{
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
@@ -1127,8 +1140,7 @@ static void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask,
...
@@ -1127,8 +1140,7 @@ static void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask,
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
moffset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
moffset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
mask
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
mask
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
));
// printf("elemnum:%d,cols:%d,invalid_cols:%d,offset:%d,minvalid_cols:%d,moffset:%d,repeat_e:%d\r\n",
// elemnum,cols,invalid_cols,offset,minvalid_cols,moffset,repeat_me);
openCLExecuteKernel
(
src
.
clCxt
,
&
arithm_minMaxLoc_mask
,
"arithm_op_minMaxLoc_mask"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
);
openCLExecuteKernel
(
src
.
clCxt
,
&
arithm_minMaxLoc_mask
,
"arithm_op_minMaxLoc_mask"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
);
}
}
}
}
...
@@ -1144,14 +1156,12 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
...
@@ -1144,14 +1156,12 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
Context
*
clCxt
=
src
.
clCxt
;
Context
*
clCxt
=
src
.
clCxt
;
cl_mem
dstBuffer
=
openCLCreateBuffer
(
clCxt
,
CL_MEM_WRITE_ONLY
,
dbsize
);
cl_mem
dstBuffer
=
openCLCreateBuffer
(
clCxt
,
CL_MEM_WRITE_ONLY
,
dbsize
);
*
minVal
=
std
::
numeric_limits
<
double
>::
max
()
,
*
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
*
minVal
=
std
::
numeric_limits
<
double
>::
max
()
,
*
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
if
(
mask
.
empty
())
if
(
mask
.
empty
())
{
arithmetic_minMaxLoc_run
(
src
,
dstBuffer
,
vlen
,
groupnum
);
arithmetic_minMaxLoc_run
(
src
,
dstBuffer
,
vlen
,
groupnum
);
}
else
else
{
arithmetic_minMaxLoc_mask_run
(
src
,
mask
,
dstBuffer
,
vlen
,
groupnum
);
arithmetic_minMaxLoc_mask_run
(
src
,
mask
,
dstBuffer
,
vlen
,
groupnum
);
}
T
*
p
=
new
T
[
groupnum
*
vlen
*
4
];
T
*
p
=
new
T
[
groupnum
*
vlen
*
4
];
memset
(
p
,
0
,
dbsize
);
memset
(
p
,
0
,
dbsize
);
openCLReadBuffer
(
clCxt
,
dstBuffer
,
(
void
*
)
p
,
dbsize
);
openCLReadBuffer
(
clCxt
,
dstBuffer
,
(
void
*
)
p
,
dbsize
);
...
@@ -1190,18 +1200,22 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
...
@@ -1190,18 +1200,22 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
maxLoc
->
x
=
maxLoc
->
y
=
-
1
;
maxLoc
->
x
=
maxLoc
->
y
=
-
1
;
}
}
delete
[]
p
;
delete
[]
p
;
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
}
}
typedef
void
(
*
minMaxLocFunc
)(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
typedef
void
(
*
minMaxLocFunc
)(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
const
oclMat
&
mask
);
Point
*
minLoc
,
Point
*
maxLoc
,
const
oclMat
&
mask
);
void
cv
::
ocl
::
minMaxLoc
(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
void
cv
::
ocl
::
minMaxLoc
(
const
oclMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
const
oclMat
&
mask
)
Point
*
minLoc
,
Point
*
maxLoc
,
const
oclMat
&
mask
)
{
{
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
{
{
CV_Error
(
CV_GpuNotSupported
,
"select device don't support double"
);
CV_Error
(
CV_GpuNotSupported
,
"select device don't support double"
);
return
;
}
}
static
minMaxLocFunc
functab
[
2
]
=
static
minMaxLocFunc
functab
[
2
]
=
{
{
arithmetic_minMaxLoc
<
float
>
,
arithmetic_minMaxLoc
<
float
>
,
...
@@ -1216,6 +1230,7 @@ void cv::ocl::minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
...
@@ -1216,6 +1230,7 @@ void cv::ocl::minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
///////////////////////////// countNonZero ///////////////////////////////////
///////////////////////////// countNonZero ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_countNonZero_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
static
void
arithmetic_countNonZero_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
{
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
@@ -1262,9 +1277,8 @@ int cv::ocl::countNonZero(const oclMat &src)
...
@@ -1262,9 +1277,8 @@ int cv::ocl::countNonZero(const oclMat &src)
memset
(
p
,
0
,
dbsize
*
sizeof
(
int
));
memset
(
p
,
0
,
dbsize
*
sizeof
(
int
));
openCLReadBuffer
(
clCxt
,
dstBuffer
,
(
void
*
)
p
,
dbsize
*
sizeof
(
int
));
openCLReadBuffer
(
clCxt
,
dstBuffer
,
(
void
*
)
p
,
dbsize
*
sizeof
(
int
));
for
(
int
i
=
0
;
i
<
dbsize
;
i
++
)
for
(
int
i
=
0
;
i
<
dbsize
;
i
++
)
{
nonzero
+=
p
[
i
];
nonzero
+=
p
[
i
];
}
delete
[]
p
;
delete
[]
p
;
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
return
nonzero
;
return
nonzero
;
...
@@ -1663,11 +1677,10 @@ static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string
...
@@ -1663,11 +1677,10 @@ static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_step1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_step1
));
float
pf
=
p
;
float
pf
=
static_cast
<
float
>
(
p
);
if
(
!
src1
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
src1
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
))
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_float
),
(
void
*
)
&
pf
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_float
),
(
void
*
)
&
pf
));
}
else
else
args
.
push_back
(
make_pair
(
sizeof
(
cl_double
),
(
void
*
)
&
p
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_double
),
(
void
*
)
&
p
));
...
@@ -1733,7 +1746,8 @@ void cv::ocl::setIdentity(oclMat& src, double scalar)
...
@@ -1733,7 +1746,8 @@ void cv::ocl::setIdentity(oclMat& src, double scalar)
{
{
scalar_i
=
(
int
)
scalar
;
scalar_i
=
(
int
)
scalar
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
scalar_i
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
scalar_i
));
}
else
}
else
args
.
push_back
(
make_pair
(
sizeof
(
cl_double
),
(
void
*
)
&
scalar
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_double
),
(
void
*
)
&
scalar
));
}
}
else
else
...
...
modules/ocl/test/test_arithm.cpp
View file @
8aa3eb81
...
@@ -50,10 +50,6 @@
...
@@ -50,10 +50,6 @@
//
//
//M*/
//M*/
//#define PRINT_CPU_TIME 1000
//#define PRINT_TIME
#include "test_precomp.hpp"
#include "test_precomp.hpp"
#include <iomanip>
#include <iomanip>
...
@@ -65,392 +61,506 @@ using namespace cvtest;
...
@@ -65,392 +61,506 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
testing
;
using
namespace
std
;
using
namespace
std
;
PARAM_TEST_CASE
(
ArithmTestBase
,
MatType
,
bool
)
//////////////////////////////// LUT /////////////////////////////////////////////////
PARAM_TEST_CASE
(
Lut
,
int
,
int
,
bool
,
bool
)
{
{
int
type
;
int
lut_depth
;
cv
::
Scalar
val
;
int
cn
;
bool
use_roi
,
same_cn
;
//src mat
// src mat
cv
::
Mat
mat1
;
cv
::
Mat
src
;
cv
::
Mat
mat2
;
cv
::
Mat
lut
;
cv
::
Mat
mask
;
cv
::
Mat
dst
;
cv
::
Mat
dst
;
cv
::
Mat
dst1
;
//bak, for two outputs
// set up roi
// src mat with roi
int
roicols
;
cv
::
Mat
src_roi
;
int
roirows
;
cv
::
Mat
lut_roi
;
int
src1x
;
int
src1y
;
int
src2x
;
int
src2y
;
int
dstx
;
int
dsty
;
int
maskx
;
int
masky
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
mat2_roi
;
cv
::
Mat
mask_roi
;
cv
::
Mat
dst_roi
;
cv
::
Mat
dst_roi
;
cv
::
Mat
dst1_roi
;
//bak
//ocl dst mat for testing
//
ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
cv
::
ocl
::
oclMat
gdst_whole
;
cv
::
ocl
::
oclMat
gdst1_whole
;
//bak
//ocl mat with roi
//
ocl mat with roi
cv
::
ocl
::
oclMat
g
mat1
;
cv
::
ocl
::
oclMat
g
src
;
cv
::
ocl
::
oclMat
g
mat2
;
cv
::
ocl
::
oclMat
g
lut
;
cv
::
ocl
::
oclMat
gdst
;
cv
::
ocl
::
oclMat
gdst
;
cv
::
ocl
::
oclMat
gdst1
;
//bak
cv
::
ocl
::
oclMat
gmask
;
virtual
void
SetUp
()
virtual
void
SetUp
()
{
{
type
=
GET_PARAM
(
0
);
lut_depth
=
GET_PARAM
(
0
);
cn
=
GET_PARAM
(
1
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
same_cn
=
GET_PARAM
(
2
);
use_roi
=
GET_PARAM
(
3
);
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
const
int
src_type
=
CV_MAKE_TYPE
(
CV_8U
,
cn
);
const
int
lut_type
=
CV_MAKE_TYPE
(
lut_depth
,
same_cn
?
cn
:
1
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
const
int
dst_type
=
CV_MAKE_TYPE
(
lut_depth
,
cn
);
//mat2 = randomMat(rng, size, type, 5, 16, false);
mat2
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
mask
=
randomMat
(
rng
,
size
,
CV_8UC1
,
0
,
2
,
false
);
cv
::
threshold
(
mask
,
mask
,
0.5
,
255.
,
CV_8UC1
);
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
)
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
(
);
src
=
randomMat
(
rng
,
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
src_type
,
0
,
256
,
false
);
lut
=
randomMat
(
rng
,
use_roi
?
randomSize
(
260
,
300
)
:
Size
(
256
,
1
),
lut_type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
use_roi
?
randomSize
(
MIN_VALUE
,
MAX_VALUE
)
:
src
.
size
(),
dst_type
,
5
,
16
,
false
);
}
}
void
random_roi
()
void
random_roi
()
{
{
#ifdef RANDOMROI
// set up roi
//randomize ROI
int
roicols
,
roirows
;
int
srcx
,
srcy
;
int
lutx
,
luty
;
int
dstx
,
dsty
;
if
(
use_roi
)
{
// randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
1
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
1
,
mat1
.
rows
);
roicols
=
rng
.
uniform
(
1
,
MIN_VALUE
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
roirows
=
rng
.
uniform
(
1
,
MIN_VALUE
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
srcx
=
rng
.
uniform
(
0
,
src
.
cols
-
roicols
);
srcy
=
rng
.
uniform
(
0
,
src
.
rows
-
roirows
);
lutx
=
rng
.
uniform
(
0
,
lut
.
cols
-
256
);
luty
=
rng
.
uniform
(
0
,
lut
.
rows
-
1
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
maskx
=
rng
.
uniform
(
0
,
mask
.
cols
-
roicols
);
}
masky
=
rng
.
uniform
(
0
,
mask
.
rows
-
roirows
);
else
src2x
=
rng
.
uniform
(
0
,
mat2
.
cols
-
roicols
);
{
src2y
=
rng
.
uniform
(
0
,
mat2
.
rows
-
roirows
);
roicols
=
src
.
cols
;
#else
roirows
=
src
.
rows
;
roicols
=
mat1
.
cols
;
srcx
=
srcy
=
0
;
roirows
=
mat1
.
rows
;
lutx
=
luty
=
0
;
src1x
=
0
;
dstx
=
dsty
=
0
;
src1y
=
0
;
}
dstx
=
0
;
dsty
=
0
;
src_roi
=
src
(
Rect
(
srcx
,
srcy
,
roicols
,
roirows
));
maskx
=
0
;
lut_roi
=
lut
(
Rect
(
lutx
,
luty
,
256
,
1
));
masky
=
0
;
src2x
=
0
;
src2y
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
mat2_roi
=
mat2
(
Rect
(
src2x
,
src2y
,
roicols
,
roirows
));
mask_roi
=
mask
(
Rect
(
maskx
,
masky
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
dst1_roi
=
dst1
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst1_whole
=
dst1
;
gsrc
=
src_roi
;
gdst1
=
gdst1_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
glut
=
lut_roi
;
gmat1
=
mat1_roi
;
gmat2
=
mat2_roi
;
gmask
=
mask_roi
;
//end
}
}
void
Near
(
double
threshold
=
0.
)
void
Near
(
double
threshold
=
0.
)
{
{
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
threshold
);
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
threshold
);
EXPECT_MAT_NEAR
(
dst_roi
,
Mat
(
gdst
),
threshold
);
}
}
};
void
Near1
(
double
threshold
=
0.
)
TEST_P
(
Lut
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
EXPECT_MAT_NEAR
(
dst1
,
Mat
(
gdst1_whole
),
threshold
);
random_roi
();
}
};
cv
::
LUT
(
src_roi
,
lut_roi
,
dst_roi
);
////////////////////////////////lut/////////////////////////////////////////////////
cv
::
ocl
::
LUT
(
gsrc
,
glut
,
gdst
);
struct
Lut
:
ArithmTestBase
{};
#define VARNAME(A) string(#A);
Near
();
}
}
///////////////////////// ArithmTestBase ///////////////////////////
TEST_P
(
Lut
,
Mat
)
PARAM_TEST_CASE
(
ArithmTestBase
,
int
,
int
,
bool
)
{
{
int
depth
;
int
cn
;
bool
use_roi
;
cv
::
Scalar
val
;
// src mat
cv
::
Mat
src1
;
cv
::
Mat
src2
;
cv
::
Mat
mask
;
cv
::
Mat
dst1
;
cv
::
Mat
dst2
;
// for two outputs
// set up roi
int
roicols
,
roirows
;
int
src1x
,
src1y
;
int
src2x
,
src2y
;
int
dst1x
,
dst1y
;
int
dst2x
,
dst2y
;
int
maskx
,
masky
;
// src mat with roi
cv
::
Mat
src1_roi
;
cv
::
Mat
src2_roi
;
cv
::
Mat
mask_roi
;
cv
::
Mat
dst1_roi
;
cv
::
Mat
dst2_roi
;
// for two outputs
// ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst1_whole
;
cv
::
ocl
::
oclMat
gdst2_whole
;
// for two outputs
// ocl mat with roi
cv
::
ocl
::
oclMat
gsrc1
;
cv
::
ocl
::
oclMat
gsrc2
;
cv
::
ocl
::
oclMat
gdst1
;
cv
::
ocl
::
oclMat
gdst2
;
// for two outputs
cv
::
ocl
::
oclMat
gmask
;
virtual
void
SetUp
()
{
depth
=
GET_PARAM
(
0
);
cn
=
GET_PARAM
(
1
);
use_roi
=
GET_PARAM
(
2
);
const
int
type
=
CV_MAKE_TYPE
(
depth
,
cn
);
cv
::
Mat
mat2
(
3
,
512
,
CV_8UC1
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
rng
.
fill
(
mat2
,
cv
::
RNG
::
UNIFORM
,
cv
::
Scalar
::
all
(
0
),
cv
::
Scalar
::
all
(
256
));
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
src1
=
randomMat
(
rng
,
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
type
,
5
,
16
,
false
);
src2
=
randomMat
(
rng
,
!
use_roi
?
src1
.
size
()
:
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
type
,
-
15440
,
14450
,
false
);
dst1
=
randomMat
(
rng
,
!
use_roi
?
src1
.
size
()
:
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
type
,
5
,
16
,
false
);
dst2
=
randomMat
(
rng
,
!
use_roi
?
src1
.
size
()
:
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
type
,
5
,
16
,
false
);
mask
=
randomMat
(
rng
,
!
use_roi
?
src1
.
size
()
:
randomSize
(
MIN_VALUE
,
MAX_VALUE
),
CV_8UC1
,
0
,
2
,
false
);
cv
::
threshold
(
mask
,
mask
,
0.5
,
255.
,
CV_8UC1
);
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
));
}
void
random_roi
()
{
{
random_roi
();
if
(
use_roi
)
{
// randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
src2x
=
rng
.
uniform
(
0
,
mat2
.
cols
-
256
);
roicols
=
rng
.
uniform
(
1
,
MIN_VALUE
);
src2y
=
rng
.
uniform
(
0
,
mat2
.
rows
-
1
);
roirows
=
rng
.
uniform
(
1
,
MIN_VALUE
);
cv
::
Mat
mat2_roi
=
mat2
(
Rect
(
src2x
,
src2y
,
256
,
1
));
src1x
=
rng
.
uniform
(
0
,
src1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
src1
.
rows
-
roirows
);
src2x
=
rng
.
uniform
(
0
,
src2
.
cols
-
roicols
);
src2y
=
rng
.
uniform
(
0
,
src2
.
rows
-
roirows
);
cv
::
ocl
::
oclMat
gmat2
(
mat2_roi
);
dst1x
=
rng
.
uniform
(
0
,
dst1
.
cols
-
roicols
);
dst1y
=
rng
.
uniform
(
0
,
dst1
.
rows
-
roirows
);
dst2x
=
rng
.
uniform
(
0
,
dst2
.
cols
-
roicols
);
dst2y
=
rng
.
uniform
(
0
,
dst2
.
rows
-
roirows
);
cv
::
LUT
(
mat1_roi
,
mat2_roi
,
dst_roi
);
maskx
=
rng
.
uniform
(
0
,
mask
.
cols
-
roicols
);
cv
::
ocl
::
LUT
(
gmat1
,
gmat2
,
gdst
);
masky
=
rng
.
uniform
(
0
,
mask
.
rows
-
roirows
);
Near
(
0
);
}
}
}
else
{
roicols
=
src1
.
cols
;
roirows
=
src1
.
rows
;
src1x
=
src1y
=
0
;
src2x
=
src2y
=
0
;
dst1x
=
dst1y
=
0
;
dst2x
=
dst2y
=
0
;
maskx
=
masky
=
0
;
}
src1_roi
=
src1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
src2_roi
=
src2
(
Rect
(
src2x
,
src2y
,
roicols
,
roirows
));
mask_roi
=
mask
(
Rect
(
maskx
,
masky
,
roicols
,
roirows
));
dst1_roi
=
dst1
(
Rect
(
dst1x
,
dst1y
,
roicols
,
roirows
));
dst2_roi
=
dst2
(
Rect
(
dst2x
,
dst2y
,
roicols
,
roirows
));
gdst1_whole
=
dst1
;
gdst1
=
gdst1_whole
(
Rect
(
dst1x
,
dst1y
,
roicols
,
roirows
));
gdst2_whole
=
dst2
;
gdst2
=
gdst2_whole
(
Rect
(
dst2x
,
dst2y
,
roicols
,
roirows
));
////////////////////////////////exp/////////////////////////////////////////////////
gsrc1
=
src1_roi
;
struct
Exp
:
ArithmTestBase
{};
gsrc2
=
src2_roi
;
gmask
=
mask_roi
;
}
void
Near
(
double
threshold
=
0.
)
{
EXPECT_MAT_NEAR
(
dst1
,
Mat
(
gdst1_whole
),
threshold
);
EXPECT_MAT_NEAR
(
dst1_roi
,
Mat
(
gdst1
),
threshold
);
}
void
Near1
(
double
threshold
=
0.
)
{
EXPECT_MAT_NEAR
(
dst2
,
Mat
(
gdst2_whole
),
threshold
);
EXPECT_MAT_NEAR
(
dst2_roi
,
Mat
(
gdst2
),
threshold
);
}
};
//////////////////////////////// Exp /////////////////////////////////////////////////
typedef
ArithmTestBase
Exp
;
TEST_P
(
Exp
,
Mat
)
TEST_P
(
Exp
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
exp
(
mat1_roi
,
dst_roi
);
cv
::
exp
(
src1_roi
,
dst1_roi
);
cv
::
ocl
::
exp
(
gmat1
,
gdst
);
cv
::
ocl
::
exp
(
gsrc1
,
gdst1
);
Near
(
2
);
Near
(
2
);
}
}
}
}
//////////////////////////////// Log /////////////////////////////////////////////////
////////////////////////////////log/////////////////////////////////////////////////
typedef
ArithmTestBase
Log
;
struct
Log
:
ArithmTestBase
{};
TEST_P
(
Log
,
Mat
)
TEST_P
(
Log
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
log
(
mat1_roi
,
dst
_roi
);
cv
::
log
(
src1_roi
,
dst1
_roi
);
cv
::
ocl
::
log
(
g
mat1
,
gdst
);
cv
::
ocl
::
log
(
g
src1
,
gdst1
);
Near
(
1
);
Near
(
1
);
}
}
}
}
//////////////////////////////// Add /////////////////////////////////////////////////
////////////////////////////////add/////////////////////////////////////////////////
typedef
ArithmTestBase
Add
;
struct
Add
:
ArithmTestBase
{};
TEST_P
(
Add
,
Mat
)
TEST_P
(
Add
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
add
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
add
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
add
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
add
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Add
,
Mat_Mask
)
TEST_P
(
Add
,
Mat_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
add
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
mask_roi
);
cv
::
add
(
src1_roi
,
src2_roi
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
add
(
g
mat1
,
gmat2
,
gdst
,
gmask
);
cv
::
ocl
::
add
(
g
src1
,
gsrc2
,
gdst1
,
gmask
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Add
,
Scalar
)
TEST_P
(
Add
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
add
(
mat1_roi
,
val
,
dst
_roi
);
cv
::
add
(
src1_roi
,
val
,
dst1
_roi
);
cv
::
ocl
::
add
(
g
mat1
,
val
,
gdst
);
cv
::
ocl
::
add
(
g
src1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Add
,
Scalar_Mask
)
TEST_P
(
Add
,
Scalar_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
add
(
mat1_roi
,
val
,
dst
_roi
,
mask_roi
);
cv
::
add
(
src1_roi
,
val
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
add
(
g
mat1
,
val
,
gdst
,
gmask
);
cv
::
ocl
::
add
(
g
src1
,
val
,
gdst1
,
gmask
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// Sub /////////////////////////////////////////////////
typedef
ArithmTestBase
Sub
;
////////////////////////////////sub/////////////////////////////////////////////////
struct
Sub
:
ArithmTestBase
{};
TEST_P
(
Sub
,
Mat
)
TEST_P
(
Sub
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
subtract
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
subtract
(
src1_roi
,
src2_roi
,
dst1_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
gmat2
,
gdst
);
cv
::
ocl
::
subtract
(
gsrc1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Sub
,
Mat_Mask
)
TEST_P
(
Sub
,
Mat_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
subtract
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
mask_roi
);
cv
::
subtract
(
src1_roi
,
src2_roi
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
subtract
(
g
mat1
,
gmat2
,
gdst
,
gmask
);
cv
::
ocl
::
subtract
(
g
src1
,
gsrc2
,
gdst1
,
gmask
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Sub
,
Scalar
)
TEST_P
(
Sub
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
subtract
(
mat1_roi
,
val
,
dst_roi
);
cv
::
subtract
(
src1_roi
,
val
,
dst1_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
val
,
gdst
);
cv
::
ocl
::
subtract
(
gsrc1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Sub
,
Scalar_Mask
)
TEST_P
(
Sub
,
Scalar_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
subtract
(
mat1_roi
,
val
,
dst
_roi
,
mask_roi
);
cv
::
subtract
(
src1_roi
,
val
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
subtract
(
g
mat1
,
val
,
gdst
,
gmask
);
cv
::
ocl
::
subtract
(
g
src1
,
val
,
gdst1
,
gmask
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// Mul /////////////////////////////////////////////////
typedef
ArithmTestBase
Mul
;
////////////////////////////////Mul/////////////////////////////////////////////////
struct
Mul
:
ArithmTestBase
{};
TEST_P
(
Mul
,
Mat
)
TEST_P
(
Mul
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
multiply
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
multiply
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
multiply
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
multiply
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Mul
,
Mat_
Scalar
)
TEST_P
(
Mul
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
(
);
cv
::
multiply
(
val
[
0
],
src1_roi
,
dst1_roi
);
double
s
=
rng
.
uniform
(
-
10.0
,
10.0
);
cv
::
ocl
::
multiply
(
val
[
0
],
gsrc1
,
gdst1
);
cv
::
multiply
(
mat1_roi
,
mat2_roi
,
dst_roi
,
s
);
Near
(
gdst1
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
cv
::
ocl
::
multiply
(
gmat1
,
gmat2
,
gdst
,
s
);
Near
(
.001
);
}
}
}
}
TEST_P
(
Mul
,
Mat_Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
multiply
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]);
cv
::
ocl
::
multiply
(
gsrc1
,
gsrc2
,
gdst1
,
val
[
0
]);
Near
(
gdst1
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
}
}
//////////////////////////////// Div /////////////////////////////////////////////////
struct
Div
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
Div
;
TEST_P
(
Div
,
Mat
)
TEST_P
(
Div
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
divide
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
divide
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
divide
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
1
);
Near
(
1
);
}
}
}
}
TEST_P
(
Div
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
divide
(
val
[
0
],
src1_roi
,
dst1_roi
);
cv
::
ocl
::
divide
(
val
[
0
],
gsrc1
,
gdst1
);
Near
(
gdst1
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
}
}
TEST_P
(
Div
,
Mat_Scalar
)
TEST_P
(
Div
,
Mat_Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
(
);
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]
);
double
s
=
rng
.
uniform
(
-
10.0
,
10.0
);
cv
::
ocl
::
divide
(
gsrc1
,
gsrc2
,
gdst1
,
val
[
0
]
);
cv
::
divide
(
mat1_roi
,
mat2_roi
,
dst_roi
,
s
);
Near
(
gdst1
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
cv
::
ocl
::
divide
(
gmat1
,
gmat2
,
gdst
,
s
);
Near
(
.001
);
}
}
}
}
//////////////////////////////// Absdiff /////////////////////////////////////////////////
struct
Absdiff
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
Absdiff
;
TEST_P
(
Absdiff
,
Mat
)
TEST_P
(
Absdiff
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
absdiff
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
absdiff
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
absdiff
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
absdiff
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Absdiff
,
Mat_Scalar
)
TEST_P
(
Absdiff
,
Mat_Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
absdiff
(
mat1_roi
,
val
,
dst
_roi
);
cv
::
absdiff
(
src1_roi
,
val
,
dst1
_roi
);
cv
::
ocl
::
absdiff
(
g
mat1
,
val
,
gdst
);
cv
::
ocl
::
absdiff
(
g
src1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// CartToPolar /////////////////////////////////////////////////
typedef
ArithmTestBase
CartToPolar
;
struct
CartToPolar
:
ArithmTestBase
{};
TEST_P
(
CartToPolar
,
angleInDegree
)
TEST_P
(
CartToPolar
,
angleInDegree
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
cartToPolar
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
1
);
cv
::
cartToPolar
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
,
true
);
cv
::
ocl
::
cartToPolar
(
g
mat1
,
gmat2
,
gdst
,
gdst1
,
1
);
cv
::
ocl
::
cartToPolar
(
g
src1
,
gsrc2
,
gdst1
,
gdst2
,
true
);
Near
(
.5
);
Near
(
.5
);
Near1
(
.5
);
Near1
(
.5
);
}
}
...
@@ -458,28 +568,30 @@ TEST_P(CartToPolar, angleInDegree)
...
@@ -458,28 +568,30 @@ TEST_P(CartToPolar, angleInDegree)
TEST_P
(
CartToPolar
,
angleInRadians
)
TEST_P
(
CartToPolar
,
angleInRadians
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
cartToPolar
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
0
);
cv
::
cartToPolar
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
);
cv
::
ocl
::
cartToPolar
(
g
mat1
,
gmat2
,
gdst
,
gdst1
,
0
);
cv
::
ocl
::
cartToPolar
(
g
src1
,
gsrc2
,
gdst1
,
gdst2
);
Near
(
.5
);
Near
(
.5
);
Near1
(
.5
);
Near1
(
.5
);
}
}
}
}
//////////////////////////////// PolarToCart /////////////////////////////////////////////////
struct
PolarToCart
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
PolarToCart
;
TEST_P
(
PolarToCart
,
angleInDegree
)
TEST_P
(
PolarToCart
,
angleInDegree
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
polarToCart
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
1
);
cv
::
polarToCart
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
,
true
);
cv
::
ocl
::
polarToCart
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
1
);
cv
::
ocl
::
polarToCart
(
gsrc1
,
gsrc2
,
gdst1
,
gdst2
,
true
);
Near
(
.5
);
Near
(
.5
);
Near1
(
.5
);
Near1
(
.5
);
}
}
...
@@ -487,144 +599,179 @@ TEST_P(PolarToCart, angleInDegree)
...
@@ -487,144 +599,179 @@ TEST_P(PolarToCart, angleInDegree)
TEST_P
(
PolarToCart
,
angleInRadians
)
TEST_P
(
PolarToCart
,
angleInRadians
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
polarToCart
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
0
);
cv
::
polarToCart
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
);
cv
::
ocl
::
polarToCart
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
0
);
cv
::
ocl
::
polarToCart
(
gsrc1
,
gsrc2
,
gdst1
,
gdst2
);
Near
(
.5
);
Near
(
.5
);
Near1
(
.5
);
Near1
(
.5
);
}
}
}
}
//////////////////////////////// Magnitude /////////////////////////////////////////////////
typedef
ArithmTestBase
Magnitude
;
struct
Magnitude
:
ArithmTestBase
{};
TEST_P
(
Magnitude
,
Mat
)
TEST_P
(
Magnitude
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
magnitude
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
magnitude
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
magnitude
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
magnitude
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
1e-5
);
Near
(
depth
==
CV_64F
?
1e-5
:
1e-2
);
}
}
}
}
//////////////////////////////// Transpose /////////////////////////////////////////////////
struct
Transpose
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
Transpose
;
TEST_P
(
Transpose
,
Mat
)
TEST_P
(
Transpose
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
transpose
(
mat1_roi
,
dst_roi
);
cv
::
transpose
(
src1_roi
,
dst1_roi
);
cv
::
ocl
::
transpose
(
gmat1
,
gdst
);
cv
::
ocl
::
transpose
(
gsrc1
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Transpose
,
SquareInplace
)
{
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
int
value
=
randomInt
(
MIN_VALUE
,
MAX_VALUE
);
src1
=
randomMat
(
rng
,
Size
(
value
,
value
),
CV_MAKE_TYPE
(
depth
,
cn
),
5
,
16
,
false
);
struct
Flip
:
ArithmTestBase
{};
if
(
use_roi
)
{
roirows
=
roicols
=
randomInt
(
1
,
src1
.
cols
);
src1x
=
randomInt
(
0
,
src1
.
cols
-
roicols
);
src1y
=
randomInt
(
0
,
src1
.
rows
-
roirows
);
}
else
{
roicols
=
roirows
=
src1
.
cols
;
src1x
=
src1y
=
0
;
}
Rect
r
(
src1x
,
src1y
,
roicols
,
roirows
);
src1_roi
=
src1
(
r
);
gdst1_whole
=
src1
;
gdst1
=
gdst1_whole
(
r
);
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
cv
::
transpose
(
src1_roi
,
src1_roi
);
cv
::
ocl
::
transpose
(
gdst1
,
gdst1
);
EXPECT_MAT_NEAR
(
src1
,
Mat
(
gdst1_whole
),
0.0
);
EXPECT_MAT_NEAR
(
src1_roi
,
Mat
(
gdst1
),
0.0
);
}
}
//////////////////////////////// Flip /////////////////////////////////////////////////
typedef
ArithmTestBase
Flip
;
TEST_P
(
Flip
,
X
)
TEST_P
(
Flip
,
X
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
flip
(
mat1_roi
,
dst
_roi
,
0
);
cv
::
flip
(
src1_roi
,
dst1
_roi
,
0
);
cv
::
ocl
::
flip
(
g
mat1
,
gdst
,
0
);
cv
::
ocl
::
flip
(
g
src1
,
gdst1
,
0
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Flip
,
Y
)
TEST_P
(
Flip
,
Y
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
flip
(
mat1_roi
,
dst
_roi
,
1
);
cv
::
flip
(
src1_roi
,
dst1
_roi
,
1
);
cv
::
ocl
::
flip
(
g
mat1
,
gdst
,
1
);
cv
::
ocl
::
flip
(
g
src1
,
gdst1
,
1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Flip
,
BOTH
)
TEST_P
(
Flip
,
BOTH
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
flip
(
mat1_roi
,
dst
_roi
,
-
1
);
cv
::
flip
(
src1_roi
,
dst1
_roi
,
-
1
);
cv
::
ocl
::
flip
(
g
mat1
,
gdst
,
-
1
);
cv
::
ocl
::
flip
(
g
src1
,
gdst1
,
-
1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// MinMax /////////////////////////////////////////////////
struct
MinMax
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
MinMax
;
TEST_P
(
MinMax
,
MAT
)
TEST_P
(
MinMax
,
MAT
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
minVal
,
maxVal
;
double
minVal
,
maxVal
;
cv
::
Point
minLoc
,
maxLoc
;
if
(
mat1
.
depth
()
!=
CV_8S
)
if
(
src1
.
depth
()
!=
CV_8S
)
{
cv
::
minMaxIdx
(
src1_roi
,
&
minVal
,
&
maxVal
,
NULL
,
NULL
);
cv
::
minMaxLoc
(
mat1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
);
}
else
else
{
{
minVal
=
std
::
numeric_limits
<
double
>::
max
();
minVal
=
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
for
(
int
i
=
0
;
i
<
mat
1_roi
.
rows
;
++
i
)
for
(
int
i
=
0
;
i
<
src
1_roi
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat
1_roi
.
cols
;
++
j
)
for
(
int
j
=
0
;
j
<
src
1_roi
.
cols
;
++
j
)
{
{
signed
char
val
=
mat
1_roi
.
at
<
signed
char
>
(
i
,
j
);
signed
char
val
=
src
1_roi
.
at
<
signed
char
>
(
i
,
j
);
if
(
val
<
minVal
)
minVal
=
val
;
if
(
val
<
minVal
)
minVal
=
val
;
if
(
val
>
maxVal
)
maxVal
=
val
;
else
if
(
val
>
maxVal
)
maxVal
=
val
;
}
}
}
}
double
minVal_
,
maxVal_
;
double
minVal_
,
maxVal_
;
cv
::
ocl
::
minMax
(
g
mat
1
,
&
minVal_
,
&
maxVal_
);
cv
::
ocl
::
minMax
(
g
src
1
,
&
minVal_
,
&
maxVal_
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
}
}
}
}
TEST_P
(
MinMax
,
MASK
)
TEST_P
(
MinMax
,
DISABLED_
MASK
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
minVal
,
maxVal
;
double
minVal
,
maxVal
;
cv
::
Point
minLoc
,
maxLoc
;
cv
::
Point
minLoc
,
maxLoc
;
if
(
mat1
.
depth
()
!=
CV_8S
)
if
(
src1
.
depth
()
!=
CV_8S
)
{
cv
::
minMaxLoc
(
src1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
,
mask_roi
);
cv
::
minMaxLoc
(
mat1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
,
mask_roi
);
}
else
else
{
{
minVal
=
std
::
numeric_limits
<
double
>::
max
();
minVal
=
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
for
(
int
i
=
0
;
i
<
mat
1_roi
.
rows
;
++
i
)
for
(
int
i
=
0
;
i
<
src
1_roi
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat
1_roi
.
cols
;
++
j
)
for
(
int
j
=
0
;
j
<
src
1_roi
.
cols
;
++
j
)
{
{
signed
char
val
=
mat
1_roi
.
at
<
signed
char
>
(
i
,
j
);
signed
char
val
=
src
1_roi
.
at
<
signed
char
>
(
i
,
j
);
unsigned
char
m
=
mask_roi
.
at
<
unsigned
char
>
(
i
,
j
);
unsigned
char
m
=
mask_roi
.
at
<
unsigned
char
>
(
i
,
j
);
if
(
val
<
minVal
&&
m
)
minVal
=
val
;
if
(
val
<
minVal
&&
m
)
minVal
=
val
;
if
(
val
>
maxVal
&&
m
)
maxVal
=
val
;
if
(
val
>
maxVal
&&
m
)
maxVal
=
val
;
...
@@ -632,36 +779,37 @@ TEST_P(MinMax, MASK)
...
@@ -632,36 +779,37 @@ TEST_P(MinMax, MASK)
}
}
double
minVal_
,
maxVal_
;
double
minVal_
,
maxVal_
;
cv
::
ocl
::
minMax
(
g
mat
1
,
&
minVal_
,
&
maxVal_
,
gmask
);
cv
::
ocl
::
minMax
(
g
src
1
,
&
minVal_
,
&
maxVal_
,
gmask
);
EXPECT_DOUBLE_EQ
(
minVal
_
,
minVal
);
EXPECT_DOUBLE_EQ
(
minVal
,
minVal_
);
EXPECT_DOUBLE_EQ
(
maxVal
_
,
maxVal
);
EXPECT_DOUBLE_EQ
(
maxVal
,
maxVal_
);
}
}
}
}
//////////////////////////////// MinMaxLoc /////////////////////////////////////////////////
struct
MinMaxLoc
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
MinMaxLoc
;
TEST_P
(
MinMaxLoc
,
MAT
)
TEST_P
(
MinMaxLoc
,
MAT
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
minVal
,
maxVal
;
double
minVal
,
maxVal
;
cv
::
Point
minLoc
,
maxLoc
;
cv
::
Point
minLoc
,
maxLoc
;
int
depth
=
mat1
.
depth
();
int
depth
=
src1
.
depth
();
if
(
depth
!=
CV_8S
)
if
(
depth
!=
CV_8S
)
{
cv
::
minMaxLoc
(
src1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
);
cv
::
minMaxLoc
(
mat1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
);
}
else
else
{
{
minVal
=
std
::
numeric_limits
<
double
>::
max
();
minVal
=
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
for
(
int
i
=
0
;
i
<
mat
1_roi
.
rows
;
++
i
)
for
(
int
i
=
0
;
i
<
src
1_roi
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat
1_roi
.
cols
;
++
j
)
for
(
int
j
=
0
;
j
<
src
1_roi
.
cols
;
++
j
)
{
{
signed
char
val
=
mat
1_roi
.
at
<
signed
char
>
(
i
,
j
);
signed
char
val
=
src
1_roi
.
at
<
signed
char
>
(
i
,
j
);
if
(
val
<
minVal
)
if
(
val
<
minVal
)
{
{
minVal
=
val
;
minVal
=
val
;
...
@@ -679,71 +827,71 @@ TEST_P(MinMaxLoc, MAT)
...
@@ -679,71 +827,71 @@ TEST_P(MinMaxLoc, MAT)
double
minVal_
,
maxVal_
;
double
minVal_
,
maxVal_
;
cv
::
Point
minLoc_
,
maxLoc_
;
cv
::
Point
minLoc_
,
maxLoc_
;
cv
::
ocl
::
minMaxLoc
(
g
mat
1
,
&
minVal_
,
&
maxVal_
,
&
minLoc_
,
&
maxLoc_
,
cv
::
ocl
::
oclMat
());
cv
::
ocl
::
minMaxLoc
(
g
src
1
,
&
minVal_
,
&
maxVal_
,
&
minLoc_
,
&
maxLoc_
,
cv
::
ocl
::
oclMat
());
double
error0
=
0.
,
error1
=
0.
,
minlocVal
=
0.
,
minlocVal_
=
0.
,
maxlocVal
=
0.
,
maxlocVal_
=
0.
;
double
error0
=
0.
,
error1
=
0.
,
minlocVal
=
0.
,
minlocVal_
=
0.
,
maxlocVal
=
0.
,
maxlocVal_
=
0.
;
if
(
depth
==
0
)
if
(
depth
==
0
)
{
{
minlocVal
=
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
unsigned
char
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
unsigned
char
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
unsigned
char
>
(
minLoc_
)
-
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
unsigned
char
>
(
minLoc_
)
-
src
1_roi
.
at
<
unsigned
char
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
unsigned
char
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
unsigned
char
>
(
maxLoc_
)
-
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc
));
}
}
if
(
depth
==
1
)
if
(
depth
==
1
)
{
{
minlocVal
=
mat
1_roi
.
at
<
signed
char
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
signed
char
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
signed
char
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
signed
char
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
signed
char
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
signed
char
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
signed
char
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
signed
char
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
signed
char
>
(
minLoc_
)
-
mat
1_roi
.
at
<
signed
char
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
signed
char
>
(
minLoc_
)
-
src
1_roi
.
at
<
signed
char
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
signed
char
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
signed
char
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
signed
char
>
(
maxLoc_
)
-
src
1_roi
.
at
<
signed
char
>
(
maxLoc
));
}
}
if
(
depth
==
2
)
if
(
depth
==
2
)
{
{
minlocVal
=
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
unsigned
short
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
unsigned
short
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
unsigned
short
>
(
minLoc_
)
-
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
unsigned
short
>
(
minLoc_
)
-
src
1_roi
.
at
<
unsigned
short
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
unsigned
short
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
unsigned
short
>
(
maxLoc_
)
-
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc
));
}
}
if
(
depth
==
3
)
if
(
depth
==
3
)
{
{
minlocVal
=
mat
1_roi
.
at
<
signed
short
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
signed
short
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
signed
short
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
signed
short
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
signed
short
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
signed
short
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
signed
short
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
signed
short
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
signed
short
>
(
minLoc_
)
-
mat
1_roi
.
at
<
signed
short
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
signed
short
>
(
minLoc_
)
-
src
1_roi
.
at
<
signed
short
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
signed
short
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
signed
short
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
signed
short
>
(
maxLoc_
)
-
src
1_roi
.
at
<
signed
short
>
(
maxLoc
));
}
}
if
(
depth
==
4
)
if
(
depth
==
4
)
{
{
minlocVal
=
mat
1_roi
.
at
<
int
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
int
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
int
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
int
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
int
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
int
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
int
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
int
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
int
>
(
minLoc_
)
-
mat
1_roi
.
at
<
int
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
int
>
(
minLoc_
)
-
src
1_roi
.
at
<
int
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
int
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
int
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
int
>
(
maxLoc_
)
-
src
1_roi
.
at
<
int
>
(
maxLoc
));
}
}
if
(
depth
==
5
)
if
(
depth
==
5
)
{
{
minlocVal
=
mat
1_roi
.
at
<
float
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
float
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
float
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
float
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
float
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
float
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
float
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
float
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
float
>
(
minLoc_
)
-
mat
1_roi
.
at
<
float
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
float
>
(
minLoc_
)
-
src
1_roi
.
at
<
float
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
float
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
float
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
float
>
(
maxLoc_
)
-
src
1_roi
.
at
<
float
>
(
maxLoc
));
}
}
if
(
depth
==
6
)
if
(
depth
==
6
)
{
{
minlocVal
=
mat
1_roi
.
at
<
double
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
double
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
double
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
double
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
double
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
double
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
double
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
double
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
double
>
(
minLoc_
)
-
mat
1_roi
.
at
<
double
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
double
>
(
minLoc_
)
-
src
1_roi
.
at
<
double
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
double
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
double
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
double
>
(
maxLoc_
)
-
src
1_roi
.
at
<
double
>
(
maxLoc
));
}
}
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
...
@@ -756,27 +904,24 @@ TEST_P(MinMaxLoc, MAT)
...
@@ -756,27 +904,24 @@ TEST_P(MinMaxLoc, MAT)
}
}
}
}
TEST_P
(
MinMaxLoc
,
MASK
)
TEST_P
(
MinMaxLoc
,
MASK
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
minVal
,
maxVal
;
double
minVal
,
maxVal
;
cv
::
Point
minLoc
,
maxLoc
;
cv
::
Point
minLoc
,
maxLoc
;
int
depth
=
mat
1
.
depth
();
int
depth
=
src
1
.
depth
();
if
(
depth
!=
CV_8S
)
if
(
depth
!=
CV_8S
)
{
cv
::
minMaxLoc
(
src1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
,
mask_roi
);
cv
::
minMaxLoc
(
mat1_roi
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
,
mask_roi
);
}
else
else
{
{
minVal
=
std
::
numeric_limits
<
double
>::
max
();
minVal
=
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
maxVal
=
-
std
::
numeric_limits
<
double
>::
max
();
for
(
int
i
=
0
;
i
<
mat
1_roi
.
rows
;
++
i
)
for
(
int
i
=
0
;
i
<
src
1_roi
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat
1_roi
.
cols
;
++
j
)
for
(
int
j
=
0
;
j
<
src
1_roi
.
cols
;
++
j
)
{
{
signed
char
val
=
mat
1_roi
.
at
<
signed
char
>
(
i
,
j
);
signed
char
val
=
src
1_roi
.
at
<
signed
char
>
(
i
,
j
);
unsigned
char
m
=
mask_roi
.
at
<
unsigned
char
>
(
i
,
j
);
unsigned
char
m
=
mask_roi
.
at
<
unsigned
char
>
(
i
,
j
);
if
(
val
<
minVal
&&
m
)
if
(
val
<
minVal
&&
m
)
{
{
...
@@ -795,72 +940,72 @@ TEST_P(MinMaxLoc, MASK)
...
@@ -795,72 +940,72 @@ TEST_P(MinMaxLoc, MASK)
double
minVal_
,
maxVal_
;
double
minVal_
,
maxVal_
;
cv
::
Point
minLoc_
,
maxLoc_
;
cv
::
Point
minLoc_
,
maxLoc_
;
cv
::
ocl
::
minMaxLoc
(
g
mat
1
,
&
minVal_
,
&
maxVal_
,
&
minLoc_
,
&
maxLoc_
,
gmask
);
cv
::
ocl
::
minMaxLoc
(
g
src
1
,
&
minVal_
,
&
maxVal_
,
&
minLoc_
,
&
maxLoc_
,
gmask
);
double
error0
=
0.
,
error1
=
0.
,
minlocVal
=
0.
,
minlocVal_
=
0.
,
maxlocVal
=
0.
,
maxlocVal_
=
0.
;
double
error0
=
0.
,
error1
=
0.
,
minlocVal
=
0.
,
minlocVal_
=
0.
,
maxlocVal
=
0.
,
maxlocVal_
=
0.
;
if
(
minLoc_
.
x
==
-
1
||
minLoc_
.
y
==
-
1
||
maxLoc_
.
x
==
-
1
||
maxLoc_
.
y
==
-
1
)
continue
;
if
(
minLoc_
.
x
==
-
1
||
minLoc_
.
y
==
-
1
||
maxLoc_
.
x
==
-
1
||
maxLoc_
.
y
==
-
1
)
continue
;
if
(
depth
==
0
)
if
(
depth
==
0
)
{
{
minlocVal
=
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
unsigned
char
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
unsigned
char
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
unsigned
char
>
(
minLoc_
)
-
mat
1_roi
.
at
<
unsigned
char
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
unsigned
char
>
(
minLoc_
)
-
src
1_roi
.
at
<
unsigned
char
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
unsigned
char
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
unsigned
char
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
unsigned
char
>
(
maxLoc_
)
-
src
1_roi
.
at
<
unsigned
char
>
(
maxLoc
));
}
}
if
(
depth
==
1
)
if
(
depth
==
1
)
{
{
minlocVal
=
mat
1_roi
.
at
<
signed
char
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
signed
char
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
signed
char
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
signed
char
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
signed
char
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
signed
char
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
signed
char
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
signed
char
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
signed
char
>
(
minLoc_
)
-
mat
1_roi
.
at
<
signed
char
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
signed
char
>
(
minLoc_
)
-
src
1_roi
.
at
<
signed
char
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
signed
char
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
signed
char
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
signed
char
>
(
maxLoc_
)
-
src
1_roi
.
at
<
signed
char
>
(
maxLoc
));
}
}
if
(
depth
==
2
)
if
(
depth
==
2
)
{
{
minlocVal
=
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
unsigned
short
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
unsigned
short
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
unsigned
short
>
(
minLoc_
)
-
mat
1_roi
.
at
<
unsigned
short
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
unsigned
short
>
(
minLoc_
)
-
src
1_roi
.
at
<
unsigned
short
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
unsigned
short
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
unsigned
short
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
unsigned
short
>
(
maxLoc_
)
-
src
1_roi
.
at
<
unsigned
short
>
(
maxLoc
));
}
}
if
(
depth
==
3
)
if
(
depth
==
3
)
{
{
minlocVal
=
mat
1_roi
.
at
<
signed
short
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
signed
short
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
signed
short
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
signed
short
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
signed
short
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
signed
short
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
signed
short
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
signed
short
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
signed
short
>
(
minLoc_
)
-
mat
1_roi
.
at
<
signed
short
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
signed
short
>
(
minLoc_
)
-
src
1_roi
.
at
<
signed
short
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
signed
short
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
signed
short
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
signed
short
>
(
maxLoc_
)
-
src
1_roi
.
at
<
signed
short
>
(
maxLoc
));
}
}
if
(
depth
==
4
)
if
(
depth
==
4
)
{
{
minlocVal
=
mat
1_roi
.
at
<
int
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
int
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
int
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
int
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
int
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
int
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
int
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
int
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
int
>
(
minLoc_
)
-
mat
1_roi
.
at
<
int
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
int
>
(
minLoc_
)
-
src
1_roi
.
at
<
int
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
int
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
int
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
int
>
(
maxLoc_
)
-
src
1_roi
.
at
<
int
>
(
maxLoc
));
}
}
if
(
depth
==
5
)
if
(
depth
==
5
)
{
{
minlocVal
=
mat
1_roi
.
at
<
float
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
float
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
float
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
float
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
float
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
float
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
float
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
float
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
float
>
(
minLoc_
)
-
mat
1_roi
.
at
<
float
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
float
>
(
minLoc_
)
-
src
1_roi
.
at
<
float
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
float
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
float
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
float
>
(
maxLoc_
)
-
src
1_roi
.
at
<
float
>
(
maxLoc
));
}
}
if
(
depth
==
6
)
if
(
depth
==
6
)
{
{
minlocVal
=
mat
1_roi
.
at
<
double
>
(
minLoc
);
minlocVal
=
src
1_roi
.
at
<
double
>
(
minLoc
);
minlocVal_
=
mat
1_roi
.
at
<
double
>
(
minLoc_
);
minlocVal_
=
src
1_roi
.
at
<
double
>
(
minLoc_
);
maxlocVal
=
mat
1_roi
.
at
<
double
>
(
maxLoc
);
maxlocVal
=
src
1_roi
.
at
<
double
>
(
maxLoc
);
maxlocVal_
=
mat
1_roi
.
at
<
double
>
(
maxLoc_
);
maxlocVal_
=
src
1_roi
.
at
<
double
>
(
maxLoc_
);
error0
=
::
abs
(
mat1_roi
.
at
<
double
>
(
minLoc_
)
-
mat
1_roi
.
at
<
double
>
(
minLoc
));
error0
=
::
abs
(
src1_roi
.
at
<
double
>
(
minLoc_
)
-
src
1_roi
.
at
<
double
>
(
minLoc
));
error1
=
::
abs
(
mat1_roi
.
at
<
double
>
(
maxLoc_
)
-
mat
1_roi
.
at
<
double
>
(
maxLoc
));
error1
=
::
abs
(
src1_roi
.
at
<
double
>
(
maxLoc_
)
-
src
1_roi
.
at
<
double
>
(
maxLoc
));
}
}
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
...
@@ -873,16 +1018,18 @@ TEST_P(MinMaxLoc, MASK)
...
@@ -873,16 +1018,18 @@ TEST_P(MinMaxLoc, MASK)
}
}
}
}
//////////////////////////////// Sum /////////////////////////////////////////////////
struct
Sum
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
Sum
;
TEST_P
(
Sum
,
MAT
)
TEST_P
(
Sum
,
DISABLED_
MAT
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
Scalar
cpures
=
cv
::
sum
(
mat1_roi
);
Scalar
gpures
=
cv
::
ocl
::
sum
(
gmat1
);
Scalar
cpures
=
cv
::
sum
(
src1_roi
);
Scalar
gpures
=
cv
::
ocl
::
sum
(
gsrc1
);
//check results
//check results
EXPECT_NEAR
(
cpures
[
0
],
gpures
[
0
],
0.1
);
EXPECT_NEAR
(
cpures
[
0
],
gpures
[
0
],
0.1
);
...
@@ -892,398 +1039,294 @@ TEST_P(Sum, MAT)
...
@@ -892,398 +1039,294 @@ TEST_P(Sum, MAT)
}
}
}
}
//////////////////////////////// CountNonZero /////////////////////////////////////////////////
struct
CountNonZero
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
CountNonZero
;
TEST_P
(
CountNonZero
,
MAT
)
TEST_P
(
CountNonZero
,
MAT
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
int
cpures
=
cv
::
countNonZero
(
mat
1_roi
);
int
cpures
=
cv
::
countNonZero
(
src
1_roi
);
int
gpures
=
cv
::
ocl
::
countNonZero
(
g
mat
1
);
int
gpures
=
cv
::
ocl
::
countNonZero
(
g
src
1
);
EXPECT_DOUBLE_EQ
((
double
)
cpures
,
(
double
)
gpures
);
EXPECT_DOUBLE_EQ
((
double
)
cpures
,
(
double
)
gpures
);
}
}
}
}
//////////////////////////////// Phase /////////////////////////////////////////////////
typedef
ArithmTestBase
Phase
;
////////////////////////////////phase/////////////////////////////////////////////////
TEST_P
(
Phase
,
DISABLED_Mat
)
struct
Phase
:
ArithmTestBase
{};
TEST_P
(
Phase
,
Mat
)
{
{
if
(
mat1
.
depth
()
!=
CV_32F
&&
mat1
.
depth
()
!=
CV_64F
)
for
(
int
angelInDegrees
=
0
;
angelInDegrees
<
2
;
angelInDegrees
++
)
{
cout
<<
"
\t
Unsupported type
\t\n
"
;
}
for
(
int
angelInDegrees
=
0
;
angelInDegrees
<
2
;
angelInDegrees
++
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
phase
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
angelInDegrees
?
true
:
false
);
cv
::
phase
(
src1_roi
,
src2_roi
,
dst1
_roi
,
angelInDegrees
?
true
:
false
);
cv
::
ocl
::
phase
(
g
mat1
,
gmat2
,
gdst
,
angelInDegrees
?
true
:
false
);
cv
::
ocl
::
phase
(
g
src1
,
gsrc2
,
gdst1
,
angelInDegrees
?
true
:
false
);
Near
(
1e-2
);
Near
(
1e-2
);
}
}
}
}
}
}
//////////////////////////////// Bitwise_and /////////////////////////////////////////////////
////////////////////////////////bitwise_and/////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_and
;
struct
Bitwise_and
:
ArithmTestBase
{};
TEST_P
(
Bitwise_and
,
Mat
)
TEST_P
(
Bitwise_and
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_and
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
bitwise_and
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
bitwise_and
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
bitwise_and
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_and
,
Mat_Mask
)
TEST_P
(
Bitwise_and
,
Mat_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_and
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_and
(
src1_roi
,
src2_roi
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_and
(
g
mat1
,
gmat2
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_and
(
g
src1
,
gsrc2
,
gdst1
,
gmask
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_and
,
Scalar
)
TEST_P
(
Bitwise_and
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_and
(
mat1_roi
,
val
,
dst
_roi
);
cv
::
bitwise_and
(
src1_roi
,
val
,
dst1
_roi
);
cv
::
ocl
::
bitwise_and
(
g
mat1
,
val
,
gdst
);
cv
::
ocl
::
bitwise_and
(
g
src1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Bitwise_and
,
Scalar_Mask
)
TEST_P
(
Bitwise_and
,
Scalar_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_and
(
mat1_roi
,
val
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_and
(
src1_roi
,
val
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_and
(
g
mat1
,
val
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_and
(
g
src1
,
val
,
gdst1
,
gmask
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// Bitwise_or /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_or
;
////////////////////////////////bitwise_or/////////////////////////////////////////////////
struct
Bitwise_or
:
ArithmTestBase
{};
TEST_P
(
Bitwise_or
,
Mat
)
TEST_P
(
Bitwise_or
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_or
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
bitwise_or
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
bitwise_or
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
bitwise_or
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_or
,
Mat_Mask
)
TEST_P
(
Bitwise_or
,
Mat_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_or
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_or
(
src1_roi
,
src2_roi
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_or
(
g
mat1
,
gmat2
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_or
(
g
src1
,
gsrc2
,
gdst1
,
gmask
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_or
,
Scalar
)
TEST_P
(
Bitwise_or
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_or
(
mat1_roi
,
val
,
dst
_roi
);
cv
::
bitwise_or
(
src1_roi
,
val
,
dst1
_roi
);
cv
::
ocl
::
bitwise_or
(
g
mat1
,
val
,
gdst
);
cv
::
ocl
::
bitwise_or
(
g
src1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Bitwise_or
,
Scalar_Mask
)
TEST_P
(
Bitwise_or
,
Scalar_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_or
(
mat1_roi
,
val
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_or
(
src1_roi
,
val
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_or
(
g
mat1
,
val
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_or
(
g
src1
,
val
,
gdst1
,
gmask
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// Bitwise_xor /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_xor
;
////////////////////////////////bitwise_xor/////////////////////////////////////////////////
struct
Bitwise_xor
:
ArithmTestBase
{};
TEST_P
(
Bitwise_xor
,
Mat
)
TEST_P
(
Bitwise_xor
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_xor
(
mat1_roi
,
mat2_roi
,
dst
_roi
);
cv
::
bitwise_xor
(
src1_roi
,
src2_roi
,
dst1
_roi
);
cv
::
ocl
::
bitwise_xor
(
g
mat1
,
gmat2
,
gdst
);
cv
::
ocl
::
bitwise_xor
(
g
src1
,
gsrc2
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_xor
,
Mat_Mask
)
TEST_P
(
Bitwise_xor
,
Mat_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_xor
(
mat1_roi
,
mat2_roi
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_xor
(
src1_roi
,
src2_roi
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_xor
(
g
mat1
,
gmat2
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_xor
(
g
src1
,
gsrc2
,
gdst1
,
gmask
);
Near
(
0
);
Near
(
0
);
}
}
}
}
TEST_P
(
Bitwise_xor
,
Scalar
)
TEST_P
(
Bitwise_xor
,
Scalar
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_xor
(
mat1_roi
,
val
,
dst
_roi
);
cv
::
bitwise_xor
(
src1_roi
,
val
,
dst1
_roi
);
cv
::
ocl
::
bitwise_xor
(
g
mat1
,
val
,
gdst
);
cv
::
ocl
::
bitwise_xor
(
g
src1
,
val
,
gdst1
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
TEST_P
(
Bitwise_xor
,
Scalar_Mask
)
TEST_P
(
Bitwise_xor
,
Scalar_Mask
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_xor
(
mat1_roi
,
val
,
dst
_roi
,
mask_roi
);
cv
::
bitwise_xor
(
src1_roi
,
val
,
dst1
_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_xor
(
g
mat1
,
val
,
gdst
,
gmask
);
cv
::
ocl
::
bitwise_xor
(
g
src1
,
val
,
gdst1
,
gmask
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////// Bitwise_not /////////////////////////////////////////////////
////////////////////////////////bitwise_not/////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_not
;
struct
Bitwise_not
:
ArithmTestBase
{};
TEST_P
(
Bitwise_not
,
Mat
)
TEST_P
(
Bitwise_not
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
bitwise_not
(
mat1_roi
,
dst
_roi
);
cv
::
bitwise_not
(
src1_roi
,
dst1
_roi
);
cv
::
ocl
::
bitwise_not
(
g
mat1
,
gdst
);
cv
::
ocl
::
bitwise_not
(
g
src1
,
gdst1
);
Near
(
0
);
Near
(
0
);
}
}
}
}
//////////////////////////////// Compare /////////////////////////////////////////////////
////////////////////////////////compare/////////////////////////////////////////////////
typedef
ArithmTestBase
Compare
;
struct
Compare
:
ArithmTestBase
{};
TEST_P
(
Compare
,
Mat
)
TEST_P
(
Compare
,
Mat
)
{
{
if
(
mat1
.
type
()
==
CV_8SC1
)
int
cmp_codes
[]
=
{
CMP_EQ
,
CMP_GT
,
CMP_GE
,
CMP_LT
,
CMP_LE
,
CMP_NE
};
//if(mat1.type() != CV_8UC1 || mat1.type()!= CV_16UC1 || mat1.type()!= CV_16SC1|| mat1.type()!= CV_32SC1 || mat1.type()!= CV_32FC1|| mat1.type()!= CV_64FC1)
{
cout
<<
"
\t
Unsupported type
\t\n
"
;
}
int
cmp_codes
[]
=
{
CMP_EQ
,
CMP_GT
,
CMP_GE
,
CMP_LT
,
CMP_LE
,
CMP_NE
};
//const char *cmp_str[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};
int
cmp_num
=
sizeof
(
cmp_codes
)
/
sizeof
(
int
);
int
cmp_num
=
sizeof
(
cmp_codes
)
/
sizeof
(
int
);
for
(
int
i
=
0
;
i
<
cmp_num
;
++
i
)
for
(
int
i
=
0
;
i
<
cmp_num
;
++
i
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
cv
::
compare
(
mat1_roi
,
mat2_roi
,
dst_roi
,
cmp_codes
[
i
]);
cv
::
compare
(
src1_roi
,
src2_roi
,
dst1_roi
,
cmp_codes
[
i
]);
cv
::
ocl
::
compare
(
gmat1
,
gmat2
,
gdst
,
cmp_codes
[
i
]);
cv
::
ocl
::
compare
(
gsrc1
,
gsrc2
,
gdst1
,
cmp_codes
[
i
]);
Near
(
0
);
Near
(
0
);
}
}
}
}
}
//////////////////////////////// Pow /////////////////////////////////////////////////
struct
Pow
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
Pow
;
TEST_P
(
Pow
,
Mat
)
TEST_P
(
Pow
,
Mat
)
{
{
if
(
mat1
.
depth
()
!=
CV_32F
&&
mat1
.
depth
()
!=
CV_64F
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
cout
<<
"
\t
Unsupported type
\t\n
"
;
}
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
p
=
4.5
;
double
p
=
4.5
;
cv
::
pow
(
mat1_roi
,
p
,
dst
_roi
);
cv
::
pow
(
src1_roi
,
p
,
dst1
_roi
);
cv
::
ocl
::
pow
(
g
mat1
,
p
,
gdst
);
cv
::
ocl
::
pow
(
g
src1
,
p
,
gdst1
);
Near
(
1
);
Near
(
1
);
}
}
}
}
//////////////////////////////// AddWeighted /////////////////////////////////////////////////
struct
AddWeighted
:
ArithmTestBase
{}
;
typedef
ArithmTestBase
AddWeighted
;
TEST_P
(
AddWeighted
,
Mat
)
TEST_P
(
AddWeighted
,
Mat
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
double
alpha
=
2.0
,
beta
=
1.0
,
gama
=
3.0
;
c
v
::
addWeighted
(
mat1_roi
,
alpha
,
mat2_roi
,
beta
,
gama
,
dst_roi
)
;
c
onst
double
alpha
=
2.0
,
beta
=
1.0
,
gama
=
3.0
;
// cv::ocl::oclMat clmat1(mat1),clmat2(mat2),cldst;
cv
::
addWeighted
(
src1_roi
,
alpha
,
src2_roi
,
beta
,
gama
,
dst1_roi
);
cv
::
ocl
::
addWeighted
(
gsrc1
,
alpha
,
gsrc2
,
beta
,
gama
,
gdst1
);
cv
::
ocl
::
addWeighted
(
gmat1
,
alpha
,
gmat2
,
beta
,
gama
,
gdst
);
Near
(
1e-5
);
Near
(
1e-5
);
}
}
}
}
//////////////////////////////////////// Instantiation /////////////////////////////////////////
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
(),
Bool
()));
// +
//********test****************
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Exp
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Log
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Add
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sub
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Mul
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Div
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Exp
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Absdiff
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
CV_32FC1
,
CV_32FC1
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
CartToPolar
,
Combine
(
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
PolarToCart
,
Combine
(
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Magnitude
,
Combine
(
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Log
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Transpose
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
CV_32FC1
,
CV_32FC1
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Flip
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
MinMax
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
Values
(
1
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
MinMaxLoc
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
Values
(
1
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Add
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sum
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
CountNonZero
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
Values
(
1
),
Bool
()));
// +
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Phase
,
Combine
(
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_and
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sub
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_or
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_xor
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_not
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Compare
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
Values
(
1
),
Bool
()));
// +
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Mul
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Pow
,
Combine
(
Values
(
CV_32F
,
CV_64F
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
INSTANTIATE_TEST_CASE_P
(
Arithm
,
AddWeighted
,
Combine
(
testing
::
Range
(
CV_8U
,
CV_USRTYPE1
),
testing
::
Range
(
1
,
5
),
Bool
()));
// +
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Div
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Absdiff
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
CartToPolar
,
Combine
(
Values
(
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
PolarToCart
,
Combine
(
Values
(
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Magnitude
,
Combine
(
Values
(
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Transpose
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32FC1
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Flip
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
MinMax
,
Combine
(
Values
(
CV_8UC1
,
CV_32SC1
,
CV_32FC1
),
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
MinMaxLoc
,
Combine
(
Values
(
CV_8UC1
,
CV_32SC1
,
CV_32FC1
),
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sum
,
Combine
(
Values
(
CV_8U
,
CV_32S
,
CV_32F
),
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
CountNonZero
,
Combine
(
Values
(
CV_8U
,
CV_32S
,
CV_32F
),
Values
(
false
)));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Phase
,
Combine
(
Values
(
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_and
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32SC3
,
CV_32SC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
//Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_or
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
//Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_xor
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
//Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_not
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32SC1
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
//Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Compare
,
Combine
(
Values
(
CV_8UC1
,
CV_32SC1
,
CV_32FC1
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Pow
,
Combine
(
Values
(
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
false
)));
// Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
Arithm
,
AddWeighted
,
Combine
(
Values
(
CV_8UC1
,
CV_32SC1
,
CV_32FC1
),
Values
(
false
)));
// Values(false) is the reserved parameter
#endif // HAVE_OPENCL
#endif // HAVE_OPENCL
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