Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
72eccb76
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,发现更多精彩内容 >>
提交
72eccb76
编写于
10月 15, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12825 from alalek:issue_8413_3.4
上级
7bac615d
5677a683
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
155 addition
and
30 deletion
+155
-30
modules/core/src/arithm.cpp
modules/core/src/arithm.cpp
+15
-11
modules/core/src/convert_scale.cpp
modules/core/src/convert_scale.cpp
+2
-2
modules/core/src/mathfuncs.cpp
modules/core/src/mathfuncs.cpp
+13
-12
modules/core/src/matmul.cpp
modules/core/src/matmul.cpp
+2
-2
modules/core/src/opencl/arithm.cl
modules/core/src/opencl/arithm.cl
+26
-3
modules/core/test/test_arithm.cpp
modules/core/test/test_arithm.cpp
+97
-0
未找到文件。
modules/core/src/arithm.cpp
浏览文件 @
72eccb76
...
...
@@ -105,14 +105,18 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
int
scalarcn
=
kercn
==
3
?
4
:
kercn
;
int
rowsPerWI
=
d
.
isIntel
()
?
4
:
1
;
sprintf
(
opts
,
"-D %s%s -D %s -D dstT=%s%s -D dstT_C1=%s -D workST=%s -D cn=%d -D rowsPerWI=%d"
,
const
int
dstDepth
=
srcdepth
;
const
int
dstType
=
CV_MAKETYPE
(
dstDepth
,
kercn
);
const
int
dstType1
=
CV_MAKETYPE
(
dstDepth
,
1
);
const
int
scalarType
=
CV_MAKETYPE
(
srcdepth
,
scalarcn
);
sprintf
(
opts
,
"-D %s%s -D %s%s -D dstT=%s -D DEPTH_dst=%d -D dstT_C1=%s -D workST=%s -D cn=%d -D rowsPerWI=%d"
,
haveMask
?
"MASK_"
:
""
,
haveScalar
?
"UNARY_OP"
:
"BINARY_OP"
,
oclop2str
[
oclop
],
bitwise
?
ocl
::
memopTypeToStr
(
CV_MAKETYPE
(
srcdepth
,
kercn
))
:
ocl
::
typeToStr
(
CV_MAKETYPE
(
srcdepth
,
kercn
)),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
,
bitwise
?
ocl
::
memopTypeToStr
(
CV_MAKETYPE
(
srcdepth
,
1
))
:
ocl
::
typeToStr
(
CV_MAKETYPE
(
srcdepth
,
1
)),
bitwise
?
ocl
::
memopTypeToStr
(
CV_MAKETYPE
(
srcdepth
,
scalarcn
))
:
ocl
::
typeToStr
(
CV_MAKETYPE
(
srcdepth
,
scalarcn
)),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
,
bitwise
?
ocl
::
memopTypeToStr
(
dstType
)
:
ocl
::
typeToStr
(
dstType
),
dstDepth
,
bitwise
?
ocl
::
memopTypeToStr
(
dstType1
)
:
ocl
::
typeToStr
(
dstType1
),
bitwise
?
ocl
::
memopTypeToStr
(
scalarType
)
:
ocl
::
typeToStr
(
scalarType
),
kercn
,
rowsPerWI
);
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
opts
);
...
...
@@ -501,12 +505,12 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
char
cvtstr
[
4
][
32
],
opts
[
1024
];
sprintf
(
opts
,
"-D %s%s -D %s -D srcT1=%s -D srcT1_C1=%s -D srcT2=%s -D srcT2_C1=%s "
"-D dstT=%s -D dstT_C1=%s -D workT=%s -D workST=%s -D scaleT=%s -D wdepth=%d -D convertToWT1=%s "
"-D dstT=%s -D
DEPTH_dst=%d -D
dstT_C1=%s -D workT=%s -D workST=%s -D scaleT=%s -D wdepth=%d -D convertToWT1=%s "
"-D convertToWT2=%s -D convertToDT=%s%s -D cn=%d -D rowsPerWI=%d -D convertFromU=%s"
,
(
haveMask
?
"MASK_"
:
""
),
(
haveScalar
?
"UNARY_OP"
:
"BINARY_OP"
),
oclop2str
[
oclop
],
ocl
::
typeToStr
(
CV_MAKETYPE
(
depth1
,
kercn
)),
ocl
::
typeToStr
(
depth1
),
ocl
::
typeToStr
(
CV_MAKETYPE
(
depth2
,
kercn
)),
ocl
::
typeToStr
(
depth2
),
ocl
::
typeToStr
(
CV_MAKETYPE
(
ddepth
,
kercn
)),
ocl
::
typeToStr
(
depth2
),
ocl
::
typeToStr
(
CV_MAKETYPE
(
ddepth
,
kercn
)),
ddepth
,
ocl
::
typeToStr
(
ddepth
),
ocl
::
typeToStr
(
CV_MAKETYPE
(
wdepth
,
kercn
)),
ocl
::
typeToStr
(
CV_MAKETYPE
(
wdepth
,
scalarcn
)),
ocl
::
typeToStr
(
wdepth
),
wdepth
,
...
...
@@ -1152,12 +1156,12 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
const
char
*
const
operationMap
[]
=
{
"=="
,
">"
,
">="
,
"<"
,
"<="
,
"!="
};
char
cvt
[
40
];
String
opts
=
format
(
"-D %s -D srcT1=%s -D dstT=%s -D workT=srcT1 -D cn=%d"
String
opts
=
format
(
"-D %s -D srcT1=%s -D dstT=%s -D
DEPTH_dst=%d -D
workT=srcT1 -D cn=%d"
" -D convertToDT=%s -D OP_CMP -D CMP_OPERATOR=%s -D srcT1_C1=%s"
" -D srcT2_C1=%s -D dstT_C1=%s -D workST=%s -D rowsPerWI=%d%s"
,
haveScalar
?
"UNARY_OP"
:
"BINARY_OP"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth1
,
kercn
)),
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
kercn
,
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
CV_8U
,
kercn
,
ocl
::
convertTypeStr
(
depth1
,
CV_8U
,
kercn
,
cvt
),
operationMap
[
op
],
ocl
::
typeToStr
(
depth1
),
ocl
::
typeToStr
(
depth1
),
ocl
::
typeToStr
(
CV_8U
),
...
...
modules/core/src/convert_scale.cpp
浏览文件 @
72eccb76
...
...
@@ -376,10 +376,10 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
int
rowsPerWI
=
d
.
isIntel
()
?
4
:
1
;
char
cvt
[
2
][
50
];
int
wdepth
=
std
::
max
(
depth
,
CV_32F
);
String
build_opt
=
format
(
"-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s"
String
build_opt
=
format
(
"-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D
DEPTH_dst=%d -D
srcT1=%s"
" -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s"
" -D workT1=%s -D rowsPerWI=%d%s"
,
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
CV_8U
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
wdepth
,
kercn
)),
wdepth
,
ocl
::
convertTypeStr
(
depth
,
wdepth
,
kercn
,
cvt
[
0
]),
...
...
modules/core/src/mathfuncs.cpp
浏览文件 @
72eccb76
...
...
@@ -71,8 +71,8 @@ static bool ocl_math_op(InputArray _src1, InputArray _src2, OutputArray _dst, in
int
rowsPerWI
=
d
.
isIntel
()
?
4
:
1
;
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D %s -D %s -D dstT=%s -D rowsPerWI=%d%s"
,
_src2
.
empty
()
?
"UNARY_OP"
:
"BINARY_OP"
,
oclop2str
[
oclop
],
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
rowsPerWI
,
format
(
"-D %s -D %s -D dstT=%s -D
DEPTH_dst=%d -D
rowsPerWI=%d%s"
,
_src2
.
empty
()
?
"UNARY_OP"
:
"BINARY_OP"
,
oclop2str
[
oclop
],
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
depth
,
rowsPerWI
,
double_support
?
" -D DOUBLE_SUPPORT"
:
""
));
if
(
k
.
empty
())
return
false
;
...
...
@@ -238,9 +238,9 @@ static bool ocl_cartToPolar( InputArray _src1, InputArray _src2,
return
false
;
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D BINARY_OP -D dstT=%s -D
depth
=%d -D rowsPerWI=%d -D OP_CTP_%s%s"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
1
)),
depth
,
rowsPerWI
,
angleInDegrees
?
"AD"
:
"AR"
,
format
(
"-D BINARY_OP -D dstT=%s -D
DEPTH_dst
=%d -D rowsPerWI=%d -D OP_CTP_%s%s"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
1
)),
depth
,
rowsPerWI
,
angleInDegrees
?
"AD"
:
"AR"
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
if
(
k
.
empty
())
return
false
;
...
...
@@ -474,9 +474,10 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle,
return
false
;
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D dstT=%s -D rowsPerWI=%d -D depth=%d -D BINARY_OP -D OP_PTC_%s%s"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
1
)),
rowsPerWI
,
depth
,
angleInDegrees
?
"AD"
:
"AR"
,
format
(
"-D dstT=%s -D DEPTH_dst=%d -D rowsPerWI=%d -D BINARY_OP -D OP_PTC_%s%s"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
1
)),
depth
,
rowsPerWI
,
angleInDegrees
?
"AD"
:
"AR"
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
if
(
k
.
empty
())
return
false
;
...
...
@@ -1174,8 +1175,8 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst,
const
char
*
const
op
=
issqrt
?
"OP_SQRT"
:
is_ipower
?
"OP_POWN"
:
"OP_POW"
;
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D dstT=%s -D
depth
=%d -D rowsPerWI=%d -D %s -D UNARY_OP%s"
,
ocl
::
typeToStr
(
depth
),
depth
,
rowsPerWI
,
op
,
format
(
"-D dstT=%s -D
DEPTH_dst
=%d -D rowsPerWI=%d -D %s -D UNARY_OP%s"
,
ocl
::
typeToStr
(
depth
),
depth
,
rowsPerWI
,
op
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
if
(
k
.
empty
())
return
false
;
...
...
@@ -1565,8 +1566,8 @@ static bool ocl_patchNaNs( InputOutputArray _a, float value )
{
int
rowsPerWI
=
ocl
::
Device
::
getDefault
().
isIntel
()
?
4
:
1
;
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D UNARY_OP -D OP_PATCH_NANS -D dstT=float -D rowsPerWI=%d"
,
rowsPerWI
));
format
(
"-D UNARY_OP -D OP_PATCH_NANS -D dstT=float -D
DEPTH_dst=%d -D
rowsPerWI=%d"
,
CV_32F
,
rowsPerWI
));
if
(
k
.
empty
())
return
false
;
...
...
modules/core/src/matmul.cpp
浏览文件 @
72eccb76
...
...
@@ -2359,10 +2359,10 @@ static bool ocl_scaleAdd( InputArray _src1, double alpha, InputArray _src2, Outp
char
cvt
[
2
][
50
];
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
format
(
"-D OP_SCALE_ADD -D BINARY_OP -D dstT=%s -D workT=%s -D convertToWT1=%s"
format
(
"-D OP_SCALE_ADD -D BINARY_OP -D dstT=%s -D
DEPTH_dst=%d -D
workT=%s -D convertToWT1=%s"
" -D srcT1=dstT -D srcT2=dstT -D convertToDT=%s -D workT1=%s"
" -D wdepth=%d%s -D rowsPerWI=%d"
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
depth
,
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
wdepth
,
kercn
)),
ocl
::
convertTypeStr
(
depth
,
wdepth
,
kercn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
wdepth
,
depth
,
kercn
,
cvt
[
1
]),
...
...
modules/core/src/opencl/arithm.cl
浏览文件 @
72eccb76
...
...
@@ -71,7 +71,30 @@
#
pragma
OPENCL
FP_FAST_FMA
ON
#
endif
#
if
depth
<=
5
#
if
!defined
(
DEPTH_dst
)
#
error
"Kernel configuration error: DEPTH_dst value is required"
#
elif
!
(
DEPTH_dst
>=
0
&&
DEPTH_dst
<=
7
)
#
error
"Kernel configuration error: invalid DEPTH_dst value"
#
endif
#
if
defined
(
depth
)
#
error
"Kernel configuration error: ambiguous 'depth' value is defined, use 'DEPTH_dst' instead"
#
endif
#
if
DEPTH_dst
<
5
/*
CV_32F
*/
#
define
CV_DST_TYPE_IS_INTEGER
#
else
#
define
CV_DST_TYPE_IS_FP
#
endif
#
if
DEPTH_dst
!=
6
/*
CV_64F
*/
#
define
CV_DST_TYPE_FIT_32F
1
#
else
#
define
CV_DST_TYPE_FIT_32F
0
#
endif
#
if
CV_DST_TYPE_FIT_32F
#
define
CV_PI
M_PI_F
#
else
#
define
CV_PI
M_PI
...
...
@@ -283,7 +306,7 @@
#define PROCESS_ELEM storedst(pown(srcelem1, srcelem2))
#elif defined OP_SQRT
#if
depth <= 5
#if
CV_DST_TYPE_FIT_32F
#define PROCESS_ELEM storedst(native_sqrt(srcelem1))
#else
#define PROCESS_ELEM storedst(sqrt(srcelem1))
...
...
@@ -324,7 +347,7 @@
#endif
#elif defined OP_CTP_AD || defined OP_CTP_AR
#if
depth <= 5
#if
CV_DST_TYPE_FIT_32F
#define CV_EPSILON FLT_EPSILON
#else
#define CV_EPSILON DBL_EPSILON
...
...
modules/core/test/test_arithm.cpp
浏览文件 @
72eccb76
...
...
@@ -2201,4 +2201,101 @@ TEST(Core_MeanStdDev, regression_multichannel)
}
}
template
<
typename
T
>
static
inline
void
testDivideInitData
(
Mat
&
src1
,
Mat
&
src2
)
{
CV_StaticAssert
(
std
::
numeric_limits
<
T
>::
is_integer
,
""
);
const
static
T
src1_
[]
=
{
0
,
0
,
0
,
0
,
8
,
8
,
8
,
8
,
-
8
,
-
8
,
-
8
,
-
8
};
Mat
(
3
,
4
,
traits
::
Type
<
T
>::
value
,
(
void
*
)
src1_
).
copyTo
(
src1
);
const
static
T
src2_
[]
=
{
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
max
(),
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
max
(),
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
max
(),
};
Mat
(
3
,
4
,
traits
::
Type
<
T
>::
value
,
(
void
*
)
src2_
).
copyTo
(
src2
);
}
template
<
typename
T
>
static
inline
void
testDivideInitDataFloat
(
Mat
&
src1
,
Mat
&
src2
)
{
CV_StaticAssert
(
!
std
::
numeric_limits
<
T
>::
is_integer
,
""
);
const
static
T
src1_
[]
=
{
0
,
0
,
0
,
0
,
8
,
8
,
8
,
8
,
-
8
,
-
8
,
-
8
,
-
8
};
Mat
(
3
,
4
,
traits
::
Type
<
T
>::
value
,
(
void
*
)
src1_
).
copyTo
(
src1
);
const
static
T
src2_
[]
=
{
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
infinity
(),
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
infinity
(),
1
,
2
,
0
,
std
::
numeric_limits
<
T
>::
infinity
(),
};
Mat
(
3
,
4
,
traits
::
Type
<
T
>::
value
,
(
void
*
)
src2_
).
copyTo
(
src2
);
}
template
<
>
inline
void
testDivideInitData
<
float
>
(
Mat
&
src1
,
Mat
&
src2
)
{
testDivideInitDataFloat
<
float
>
(
src1
,
src2
);
}
template
<
>
inline
void
testDivideInitData
<
double
>
(
Mat
&
src1
,
Mat
&
src2
)
{
testDivideInitDataFloat
<
double
>
(
src1
,
src2
);
}
template
<
typename
T
>
static
inline
void
testDivideChecks
(
const
Mat
&
dst
)
{
ASSERT_FALSE
(
dst
.
empty
());
for
(
int
y
=
0
;
y
<
dst
.
rows
;
y
++
)
{
for
(
int
x
=
0
;
x
<
dst
.
cols
;
x
++
)
{
if
(
x
==
2
)
{
EXPECT_EQ
(
0
,
dst
.
at
<
T
>
(
y
,
x
))
<<
"dst("
<<
y
<<
", "
<<
x
<<
") = "
<<
dst
.
at
<
T
>
(
y
,
x
);
}
}
}
}
template
<
typename
T
,
bool
isUMat
>
static
inline
void
testDivide
()
{
Mat
src1
,
src2
;
testDivideInitData
<
T
>
(
src1
,
src2
);
ASSERT_FALSE
(
src1
.
empty
());
ASSERT_FALSE
(
src2
.
empty
());
Mat
dst
;
if
(
!
isUMat
)
{
cv
::
divide
(
src1
,
src2
,
dst
);
}
else
{
UMat
usrc1
,
usrc2
,
udst
;
src1
.
copyTo
(
usrc1
);
src2
.
copyTo
(
usrc2
);
cv
::
divide
(
usrc1
,
usrc2
,
udst
);
udst
.
copyTo
(
dst
);
}
testDivideChecks
<
T
>
(
dst
);
if
(
::
testing
::
Test
::
HasFailure
())
{
std
::
cout
<<
"src1 = "
<<
std
::
endl
<<
src1
<<
std
::
endl
;
std
::
cout
<<
"src2 = "
<<
std
::
endl
<<
src2
<<
std
::
endl
;
std
::
cout
<<
"dst = "
<<
std
::
endl
<<
dst
<<
std
::
endl
;
}
}
TEST
(
Core_DivideRules
,
type_32s
)
{
testDivide
<
int
,
false
>
();
}
TEST
(
UMat_Core_DivideRules
,
type_32s
)
{
testDivide
<
int
,
true
>
();
}
TEST
(
Core_DivideRules
,
type_16s
)
{
testDivide
<
short
,
false
>
();
}
TEST
(
UMat_Core_DivideRules
,
type_16s
)
{
testDivide
<
short
,
true
>
();
}
TEST
(
Core_DivideRules
,
type_32f
)
{
testDivide
<
float
,
false
>
();
}
TEST
(
UMat_Core_DivideRules
,
type_32f
)
{
testDivide
<
float
,
true
>
();
}
TEST
(
Core_DivideRules
,
type_64f
)
{
testDivide
<
double
,
false
>
();
}
TEST
(
UMat_Core_DivideRules
,
type_64f
)
{
testDivide
<
double
,
true
>
();
}
}}
// namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录