Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
997ec608
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
997ec608
编写于
11月 30, 2013
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added OCL-TAPI arithm tests
上级
90c23067
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
660 addition
and
27 deletion
+660
-27
modules/core/src/arithm.cpp
modules/core/src/arithm.cpp
+20
-16
modules/core/src/opencl/arithm.cl
modules/core/src/opencl/arithm.cl
+5
-3
modules/core/test/ocl/test_arithm.cpp
modules/core/test/ocl/test_arithm.cpp
+635
-8
未找到文件。
modules/core/src/arithm.cpp
浏览文件 @
997ec608
...
...
@@ -929,12 +929,9 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
int
srcdepth
=
CV_MAT_DEPTH
(
srctype
);
int
cn
=
CV_MAT_CN
(
srctype
);
if
(
oclop
<
0
||
((
haveMask
||
haveScalar
)
&&
cn
>
4
)
)
if
(
oclop
<
0
||
((
haveMask
||
haveScalar
)
&&
cn
>
4
)
||
cn
==
3
)
return
false
;
UMat
src1
=
_src1
.
getUMat
(),
src2
;
UMat
dst
=
_dst
.
getUMat
(),
mask
=
_mask
.
getUMat
();
char
opts
[
1024
];
int
kercn
=
haveMask
||
haveScalar
?
cn
:
1
;
sprintf
(
opts
,
"-D %s%s -D %s -D dstT=%s"
,
...
...
@@ -946,6 +943,9 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if
(
k
.
empty
()
)
return
false
;
UMat
src1
=
_src1
.
getUMat
(),
src2
;
UMat
dst
=
_dst
.
getUMat
(),
mask
=
_mask
.
getUMat
();
int
cscale
=
cn
/
kercn
;
ocl
::
KernelArg
src1arg
=
ocl
::
KernelArg
::
ReadOnlyNoSize
(
src1
,
cscale
);
ocl
::
KernelArg
dstarg
=
haveMask
?
ocl
::
KernelArg
::
ReadWrite
(
dst
,
cscale
)
:
...
...
@@ -1280,24 +1280,28 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
void
*
usrdata
,
int
oclop
,
bool
haveScalar
)
{
bool
doubleSupport
=
ocl
::
Device
::
getDefault
().
doubleFPConfig
()
>
0
;
int
type1
=
_src1
.
type
(),
depth1
=
CV_MAT_DEPTH
(
type1
),
cn
=
CV_MAT_CN
(
type1
);
bool
haveMask
=
!
_mask
.
empty
();
if
(
((
haveMask
||
haveScalar
)
&&
cn
>
4
)
||
cn
==
3
)
// TODO need fix for 3 channels
if
(
((
haveMask
||
haveScalar
)
&&
cn
>
4
)
||
cn
==
3
)
return
false
;
int
dtype
=
_dst
.
type
(),
ddepth
=
CV_MAT_DEPTH
(
dtype
),
wdepth
=
std
::
max
(
CV_32S
,
CV_MAT_DEPTH
(
wtype
));
if
(
!
doubleSupport
)
wdepth
=
std
::
min
(
wdepth
,
CV_32F
);
wtype
=
CV_MAKETYPE
(
wdepth
,
cn
);
int
type2
=
haveScalar
?
wtype
:
_src2
.
type
(),
depth2
=
CV_MAT_DEPTH
(
type2
);
int
kercn
=
haveMask
||
haveScalar
?
cn
:
1
;
if
(
!
doubleSupport
&&
(
depth2
==
CV_64F
||
depth1
==
CV_64F
))
return
false
;
UMat
src1
=
_src1
.
getUMat
(),
src2
;
UMat
dst
=
_dst
.
getUMat
(),
mask
=
_mask
.
getUMat
();
int
kercn
=
haveMask
||
haveScalar
?
cn
:
1
;
char
cvtstr
[
3
][
32
],
opts
[
1024
];
sprintf
(
opts
,
"-D %s%s -D %s -D srcT1=%s -D srcT2=%s "
"-D dstT=%s -D workT=%s -D convertToWT1=%s "
"-D convertToWT2=%s -D convertToDT=%s"
,
"-D convertToWT2=%s -D convertToDT=%s
%s
"
,
(
haveMask
?
"MASK_"
:
""
),
(
haveScalar
?
"UNARY_OP"
:
"BINARY_OP"
),
oclop2str
[
oclop
],
ocl
::
typeToStr
(
CV_MAKETYPE
(
depth1
,
kercn
)),
ocl
::
typeToStr
(
CV_MAKETYPE
(
depth2
,
kercn
)),
...
...
@@ -1305,7 +1309,8 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
ocl
::
typeToStr
(
CV_MAKETYPE
(
wdepth
,
kercn
)),
ocl
::
convertTypeStr
(
depth1
,
wdepth
,
kercn
,
cvtstr
[
0
]),
ocl
::
convertTypeStr
(
depth2
,
wdepth
,
kercn
,
cvtstr
[
1
]),
ocl
::
convertTypeStr
(
wdepth
,
ddepth
,
kercn
,
cvtstr
[
2
]));
ocl
::
convertTypeStr
(
wdepth
,
ddepth
,
kercn
,
cvtstr
[
2
]),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
);
const
uchar
*
usrdata_p
=
(
const
uchar
*
)
usrdata
;
const
double
*
usrdata_d
=
(
const
double
*
)
usrdata
;
...
...
@@ -1323,6 +1328,9 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if
(
k
.
empty
()
)
return
false
;
UMat
src1
=
_src1
.
getUMat
(),
src2
;
UMat
dst
=
_dst
.
getUMat
(),
mask
=
_mask
.
getUMat
();
int
cscale
=
cn
/
kercn
;
ocl
::
KernelArg
src1arg
=
ocl
::
KernelArg
::
ReadOnlyNoSize
(
src1
,
cscale
);
...
...
@@ -1337,9 +1345,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
Mat
src2sc
=
_src2
.
getMat
();
if
(
!
src2sc
.
empty
()
)
{
convertAndUnrollScalar
(
src2sc
,
wtype
,
(
uchar
*
)
buf
,
1
);
}
ocl
::
KernelArg
scalararg
=
ocl
::
KernelArg
(
0
,
0
,
0
,
buf
,
esz
);
if
(
!
haveMask
)
...
...
@@ -1369,12 +1375,10 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
CV_Error
(
Error
::
StsNotImplemented
,
"unsupported number of extra parameters"
);
}
else
{
k
.
args
(
src1arg
,
src2arg
,
maskarg
,
dstarg
);
}
}
size_t
globalsize
[]
=
{
src1
.
cols
*
cscale
,
src1
.
rows
};
size_t
globalsize
[]
=
{
src1
.
cols
*
cscale
,
src1
.
rows
};
return
k
.
run
(
2
,
globalsize
,
NULL
,
false
);
}
...
...
@@ -2075,7 +2079,7 @@ void cv::multiply(InputArray src1, InputArray src2,
OutputArray
dst
,
double
scale
,
int
dtype
)
{
arithm_op
(
src1
,
src2
,
dst
,
noArray
(),
dtype
,
getMulTab
(),
true
,
&
scale
,
s
cale
==
1.
?
OCL_OP_MUL
:
OCL_OP_MUL_SCALE
);
true
,
&
scale
,
s
td
::
abs
(
scale
-
1.0
)
<
DBL_EPSILON
?
OCL_OP_MUL
:
OCL_OP_MUL_SCALE
);
}
void
cv
::
divide
(
InputArray
src1
,
InputArray
src2
,
...
...
modules/core/src/opencl/arithm.cl
浏览文件 @
997ec608
...
...
@@ -57,7 +57,7 @@
-D workDepth=<work depth> [-D cn=<num channels>]"
-
for
mixed-type
operations
*/
#
if
defined
(
DOUBLE_SUPPORT
)
#
if
def
DOUBLE_SUPPORT
#
ifdef
cl_khr_fp64
#
pragma
OPENCL
EXTENSION
cl_khr_fp64:enable
#
elif
defined
(
cl_amd_fp64
)
...
...
@@ -69,7 +69,7 @@
#
define
CV_32F
5
#
define
dstelem
*
(
__global
dstT*
)(
dstptr
+
dst_index
)
#
define
noconvert
(
x
)
x
#
define
noconvert
#
ifndef
workT
...
...
@@ -99,7 +99,9 @@
#
define
PROCESS_ELEM
dstelem
=
convertToDT
(
srcelem2
-
srcelem1
)
#
elif
defined
OP_ABSDIFF
#
define
PROCESS_ELEM
dstelem
=
abs_diff
(
srcelem1,
srcelem2
)
#
define
PROCESS_ELEM
\
workT
v
=
srcelem1
-
srcelem2
; \
dstelem
=
convertToDT
(
v
>=
(
workT
)(
0
)
?
v
:
-v
)
;
#
elif
defined
OP_AND
#
define
PROCESS_ELEM
dstelem
=
srcelem1
&
srcelem2
...
...
modules/core/test/ocl/test_arithm.cpp
浏览文件 @
997ec608
...
...
@@ -119,7 +119,6 @@ PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool)
bool
use_roi
;
cv
::
Scalar
val
;
// declare Mat + UMat mirrors
TEST_DECLARE_INPUT_PARAMETER
(
src1
)
TEST_DECLARE_INPUT_PARAMETER
(
src2
)
TEST_DECLARE_INPUT_PARAMETER
(
mask
)
...
...
@@ -281,6 +280,614 @@ OCL_TEST_P(Subtract, Scalar_Mask)
}
}
//////////////////////////////// Mul /////////////////////////////////////////////////
typedef
ArithmTestBase
Mul
;
OCL_TEST_P
(
Mul
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
multiply
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
multiply
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Mul
,
DISABLED_Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
multiply
(
src1_roi
,
val
,
dst1_roi
));
OCL_ON
(
cv
::
multiply
(
val
,
usrc1_roi
,
udst1_roi
));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
}
}
OCL_TEST_P
(
Mul
,
DISABLED_Mat_Scale
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
multiply
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
multiply
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
val
[
0
]));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
}
}
//////////////////////////////// Div /////////////////////////////////////////////////
typedef
ArithmTestBase
Div
;
OCL_TEST_P
(
Div
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
divide
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
1
);
}
}
OCL_TEST_P
(
Div
,
DISABLED_Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
divide
(
val
,
src1_roi
,
dst1_roi
));
OCL_ON
(
cv
::
divide
(
val
,
usrc1_roi
,
udst1_roi
));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
1e-3
:
1
);
}
}
OCL_TEST_P
(
Div
,
Mat_Scale
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
divide
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
val
[
0
]));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
4e-3
:
1
);
}
}
OCL_TEST_P
(
Div
,
DISABLED_Mat_Scalar_Scale
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
divide
(
src1_roi
,
val
,
dst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
divide
(
usrc1_roi
,
val
,
udst1_roi
,
val
[
0
]));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
4e-3
:
1
);
}
}
//////////////////////////////// Min/Max /////////////////////////////////////////////////
typedef
ArithmTestBase
Min
;
OCL_TEST_P
(
Min
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
max
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
max
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
typedef
ArithmTestBase
Max
;
OCL_TEST_P
(
Max
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
min
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
min
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
//////////////////////////////// Absdiff /////////////////////////////////////////////////
typedef
ArithmTestBase
Absdiff
;
OCL_TEST_P
(
Absdiff
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
absdiff
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
absdiff
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Absdiff
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
absdiff
(
src1_roi
,
val
,
dst1_roi
));
OCL_ON
(
cv
::
absdiff
(
usrc1_roi
,
val
,
udst1_roi
));
Near
(
1e-5
);
}
}
//////////////////////////////// CartToPolar /////////////////////////////////////////////////
typedef
ArithmTestBase
CartToPolar
;
OCL_TEST_P
(
CartToPolar
,
angleInDegree
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
cartToPolar
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
,
true
));
OCL_ON
(
cv
::
cartToPolar
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
udst2_roi
,
true
));
Near
(
0.5
);
Near1
(
0.5
);
}
}
OCL_TEST_P
(
CartToPolar
,
angleInRadians
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
cartToPolar
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
));
OCL_ON
(
cv
::
cartToPolar
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
udst2_roi
));
Near
(
0.5
);
Near1
(
0.5
);
}
}
//////////////////////////////// PolarToCart /////////////////////////////////////////////////
typedef
ArithmTestBase
PolarToCart
;
OCL_TEST_P
(
PolarToCart
,
angleInDegree
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
polarToCart
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
,
true
));
OCL_ON
(
cv
::
polarToCart
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
udst2_roi
,
true
));
Near
(
0.5
);
Near1
(
0.5
);
}
}
OCL_TEST_P
(
PolarToCart
,
angleInRadians
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
polarToCart
(
src1_roi
,
src2_roi
,
dst1_roi
,
dst2_roi
));
OCL_ON
(
cv
::
polarToCart
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
udst2_roi
));
Near
(
0.5
);
Near1
(
0.5
);
}
}
//////////////////////////////// Transpose /////////////////////////////////////////////////
typedef
ArithmTestBase
Transpose
;
OCL_TEST_P
(
Transpose
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
transpose
(
src1_roi
,
dst1_roi
));
OCL_ON
(
cv
::
transpose
(
usrc1_roi
,
udst1_roi
));
Near
(
1e-5
);
}
}
OCL_TEST_P
(
Transpose
,
SquareInplace
)
{
const
int
type
=
CV_MAKE_TYPE
(
depth
,
cn
);
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
roiSize
.
height
=
roiSize
.
width
;
// make it square
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src1
,
src1_roi
,
roiSize
,
srcBorder
,
type
,
5
,
16
);
UMAT_UPLOAD_OUTPUT_PARAMETER
(
src1
);
OCL_OFF
(
cv
::
transpose
(
src1_roi
,
src1_roi
));
OCL_ON
(
cv
::
transpose
(
usrc1_roi
,
usrc1_roi
));
EXPECT_MAT_NEAR
(
src1
,
usrc1
,
0.0
);
EXPECT_MAT_NEAR
(
src1_roi
,
usrc1_roi
,
0.0
);
}
}
//////////////////////////////// Bitwise_and /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_and
;
OCL_TEST_P
(
Bitwise_and
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_and
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_and
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_and
,
Mat_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_and
(
src1_roi
,
src2_roi
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_and
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
umask_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_and
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_and
(
src1_roi
,
val
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_and
(
usrc1_roi
,
val
,
udst1_roi
));
Near
(
1e-5
);
}
}
OCL_TEST_P
(
Bitwise_and
,
Scalar_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_and
(
src1_roi
,
val
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_and
(
usrc1_roi
,
val
,
udst1_roi
,
umask_roi
));
Near
(
1e-5
);
}
}
//////////////////////////////// Bitwise_or /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_or
;
OCL_TEST_P
(
Bitwise_or
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_or
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_or
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_or
,
Mat_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_or
(
src1_roi
,
src2_roi
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_or
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
umask_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_or
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_or
(
src1_roi
,
val
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_or
(
usrc1_roi
,
val
,
udst1_roi
));
Near
(
1e-5
);
}
}
OCL_TEST_P
(
Bitwise_or
,
Scalar_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_or
(
src1_roi
,
val
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_or
(
val
,
usrc1_roi
,
udst1_roi
,
umask_roi
));
Near
(
1e-5
);
}
}
//////////////////////////////// Bitwise_xor /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_xor
;
OCL_TEST_P
(
Bitwise_xor
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_xor
(
src1_roi
,
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_xor
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_xor
,
Mat_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_xor
(
src1_roi
,
src2_roi
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_xor
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
umask_roi
));
Near
(
0
);
}
}
OCL_TEST_P
(
Bitwise_xor
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_xor
(
src1_roi
,
val
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_xor
(
usrc1_roi
,
val
,
udst1_roi
));
Near
(
1e-5
);
}
}
OCL_TEST_P
(
Bitwise_xor
,
Scalar_Mask
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_xor
(
src1_roi
,
val
,
dst1_roi
,
mask_roi
));
OCL_ON
(
cv
::
bitwise_xor
(
usrc1_roi
,
val
,
udst1_roi
,
umask_roi
));
Near
(
1e-5
);
}
}
//////////////////////////////// Bitwise_not /////////////////////////////////////////////////
typedef
ArithmTestBase
Bitwise_not
;
OCL_TEST_P
(
Bitwise_not
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
bitwise_not
(
src1_roi
,
dst1_roi
));
OCL_ON
(
cv
::
bitwise_not
(
usrc1_roi
,
udst1_roi
));
Near
(
0
);
}
}
//////////////////////////////// Compare /////////////////////////////////////////////////
typedef
ArithmTestBase
Compare
;
OCL_TEST_P
(
Compare
,
Mat
)
{
int
cmp_codes
[]
=
{
CMP_EQ
,
CMP_GT
,
CMP_GE
,
CMP_LT
,
CMP_LE
,
CMP_NE
};
int
cmp_num
=
sizeof
(
cmp_codes
)
/
sizeof
(
int
);
for
(
int
i
=
0
;
i
<
cmp_num
;
++
i
)
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
compare
(
src1_roi
,
src2_roi
,
dst1_roi
,
cmp_codes
[
i
]));
OCL_ON
(
cv
::
compare
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
cmp_codes
[
i
]));
Near
(
0
);
}
}
//////////////////////////////// Pow /////////////////////////////////////////////////
typedef
ArithmTestBase
Pow
;
OCL_TEST_P
(
Pow
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
double
p
=
4.5
;
OCL_OFF
(
cv
::
pow
(
src1_roi
,
p
,
dst1_roi
));
OCL_ON
(
cv
::
pow
(
usrc1_roi
,
p
,
udst1_roi
));
Near
(
1
);
}
}
//////////////////////////////// AddWeighted /////////////////////////////////////////////////
typedef
ArithmTestBase
AddWeighted
;
OCL_TEST_P
(
AddWeighted
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
const
double
alpha
=
2.0
,
beta
=
1.0
,
gama
=
3.0
;
OCL_OFF
(
cv
::
addWeighted
(
src1_roi
,
alpha
,
src2_roi
,
beta
,
gama
,
dst1_roi
));
OCL_ON
(
cv
::
addWeighted
(
usrc1_roi
,
alpha
,
usrc2_roi
,
beta
,
gama
,
udst1_roi
));
Near
(
3e-4
);
}
}
//////////////////////////////// setIdentity /////////////////////////////////////////////////
typedef
ArithmTestBase
SetIdentity
;
OCL_TEST_P
(
SetIdentity
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
setIdentity
(
dst1_roi
,
val
));
OCL_ON
(
cv
::
setIdentity
(
udst1_roi
,
val
));
Near
(
0
);
}
}
//// Repeat
struct
RepeatTestCase
:
public
ArithmTestBase
{
int
nx
,
ny
;
virtual
void
generateTestData
()
{
const
int
type
=
CV_MAKE_TYPE
(
depth
,
cn
);
nx
=
2
;
//randomInt(1, 4);
ny
=
2
;
//randomInt(1, 4);
Size
srcRoiSize
=
randomSize
(
1
,
MAX_VALUE
);
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src1
,
src1_roi
,
srcRoiSize
,
srcBorder
,
type
,
2
,
11
);
Size
dstRoiSize
(
srcRoiSize
.
width
*
nx
,
srcRoiSize
.
height
*
ny
);
Border
dst1Border
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst1
,
dst1_roi
,
dstRoiSize
,
dst1Border
,
type
,
5
,
16
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src1
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst1
)
}
};
typedef
RepeatTestCase
Repeat
;
OCL_TEST_P
(
Repeat
,
DISABLED_Mat
)
{
for
(
int
i
=
0
;
i
<
test_loop_times
;
++
i
)
{
generateTestData
();
OCL_OFF
(
cv
::
repeat
(
src1_roi
,
ny
,
nx
,
dst1_roi
));
OCL_ON
(
cv
::
repeat
(
usrc1_roi
,
ny
,
nx
,
udst1_roi
));
Near
();
}
}
//////////////////////////////// CountNonZero /////////////////////////////////////////////////
typedef
ArithmTestBase
CountNonZero
;
OCL_TEST_P
(
CountNonZero
,
MAT
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
int
cpures
,
gpures
;
OCL_OFF
(
cpures
=
cv
::
countNonZero
(
src1_roi
));
OCL_ON
(
gpures
=
cv
::
countNonZero
(
usrc1_roi
));
EXPECT_EQ
(
cpures
,
gpures
);
}
}
//////////////////////////////// Sum /////////////////////////////////////////////////
typedef
ArithmTestBase
Sum
;
OCL_TEST_P
(
Sum
,
MAT
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
Scalar
cpures
,
gpures
;
OCL_OFF
(
cpures
=
cv
::
sum
(
src1_roi
));
OCL_ON
(
gpures
=
cv
::
sum
(
usrc1_roi
));
for
(
int
i
=
0
;
i
<
cn
;
++
i
)
EXPECT_NEAR
(
cpures
[
i
],
gpures
[
i
],
0.1
);
}
}
//////////////////////////////// meanStdDev /////////////////////////////////////////////////
typedef
ArithmTestBase
MeanStdDev
;
OCL_TEST_P
(
MeanStdDev
,
Mat
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
Scalar
cpu_mean
,
cpu_stddev
;
Scalar
gpu_mean
,
gpu_stddev
;
OCL_OFF
(
cv
::
meanStdDev
(
src1_roi
,
cpu_mean
,
cpu_stddev
));
OCL_ON
(
cv
::
meanStdDev
(
usrc1_roi
,
gpu_mean
,
gpu_stddev
));
for
(
int
i
=
0
;
i
<
cn
;
++
i
)
{
EXPECT_NEAR
(
cpu_mean
[
i
],
gpu_mean
[
i
],
0.1
);
EXPECT_NEAR
(
cpu_stddev
[
i
],
gpu_stddev
[
i
],
0.1
);
}
}
}
//////////////////////////////////////// Log /////////////////////////////////////////
typedef
ArithmTestBase
Log
;
...
...
@@ -359,13 +966,33 @@ OCL_TEST_P(Magnitude, Mat)
//////////////////////////////////////// Instantiation /////////////////////////////////////////
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
::
testing
::
Values
(
CV_8U
,
CV_8S
),
OCL_ALL_DEPTHS
,
::
testing
::
Values
(
1
,
2
,
3
,
4
),
Bool
(),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Add
,
Combine
(
OCL_ALL_DEPTHS
,
::
testing
::
Values
(
1
,
2
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Subtract
,
Combine
(
OCL_ALL_DEPTHS
,
::
testing
::
Values
(
1
,
2
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Log
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
::
testing
::
Values
(
1
,
2
,
3
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Exp
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
::
testing
::
Values
(
1
,
2
,
3
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Phase
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
::
testing
::
Values
(
1
,
2
,
3
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Magnitude
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
::
testing
::
Values
(
1
,
2
,
3
,
4
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
::
testing
::
Values
(
CV_8U
,
CV_8S
),
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
(),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Add
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Subtract
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Log
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Exp
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Phase
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Magnitude
,
Combine
(
::
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Mul
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Div
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Min
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Max
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Absdiff
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
CartToPolar
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
PolarToCart
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Transpose
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_and
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_not
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_xor
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Bitwise_or
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Pow
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Compare
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
AddWeighted
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
SetIdentity
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Repeat
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
CountNonZero
,
Combine
(
OCL_ALL_DEPTHS
,
testing
::
Values
(
Channels
(
1
)),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sum
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Arithm
,
MeanStdDev
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
}
}
// namespace cvtest::ocl
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录