Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
5bc9f15d
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
5bc9f15d
编写于
12月 11, 2013
作者:
P
Peter Andreas Entschev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OCL: included sqrt matrix operation.
上级
f3e2bfea
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
186 addition
and
3 deletion
+186
-3
modules/ocl/doc/operations_on_matrices.rst
modules/ocl/doc/operations_on_matrices.rst
+12
-0
modules/ocl/include/opencv2/ocl.hpp
modules/ocl/include/opencv2/ocl.hpp
+4
-0
modules/ocl/perf/perf_arithm.cpp
modules/ocl/perf/perf_arithm.cpp
+34
-0
modules/ocl/src/arithm.cpp
modules/ocl/src/arithm.cpp
+8
-3
modules/ocl/src/opencl/arithm_sqrt.cl
modules/ocl/src/opencl/arithm_sqrt.cl
+111
-0
modules/ocl/test/test_arithm.cpp
modules/ocl/test/test_arithm.cpp
+17
-0
未找到文件。
modules/ocl/doc/operations_on_matrices.rst
浏览文件 @
5bc9f15d
...
...
@@ -557,6 +557,18 @@ Returns void
The functions split split multi-channel array into separate single-channel arrays. Supports all data types.
ocl::sqrt
------------------
Returns void
.. ocv:function:: void ocl::sqrt(const oclMat &src, oclMat &dst)
:param src: the first source array.
:param dst: the dst array; must have the same size and same type as ``src``.
The function ``sqrt`` calculates the square root of each input array element. Supports only ``CV_32FC1`` and ``CV_64F`` data types.
ocl::subtract
------------------
Returns void
...
...
modules/ocl/include/opencv2/ocl.hpp
浏览文件 @
5bc9f15d
...
...
@@ -559,6 +559,10 @@ namespace cv
// supports only CV_32FC1, CV_64FC1 type
CV_EXPORTS
void
log
(
const
oclMat
&
src
,
oclMat
&
dst
);
//! computes square root of each matrix element
// supports only CV_32FC1, CV_64FC1 type
CV_EXPORTS
void
sqrt
(
const
oclMat
&
src
,
oclMat
&
dst
);
//! computes magnitude of each (x(i), y(i)) vector
// supports only CV_32F, CV_64F type
CV_EXPORTS
void
magnitude
(
const
oclMat
&
x
,
const
oclMat
&
y
,
oclMat
&
magnitude
);
...
...
modules/ocl/perf/perf_arithm.cpp
浏览文件 @
5bc9f15d
...
...
@@ -162,6 +162,40 @@ PERF_TEST_P(LogFixture, Log, OCL_TYPICAL_MAT_SIZES)
SANITY_CHECK
(
dst
,
eps
,
ERROR_RELATIVE
);
}
///////////// SQRT ///////////////////////
typedef
TestBaseWithParam
<
Size
>
SqrtFixture
;
PERF_TEST_P
(
SqrtFixture
,
Sqrt
,
OCL_TYPICAL_MAT_SIZES
)
{
// getting params
const
Size
srcSize
=
GetParam
();
const
double
eps
=
1e-6
;
// creating src data
Mat
src
(
srcSize
,
CV_32F
),
dst
(
srcSize
,
src
.
type
());
randu
(
src
,
0
,
10
);
declare
.
in
(
src
).
out
(
dst
);
// select implementation
if
(
RUN_OCL_IMPL
)
{
ocl
::
oclMat
oclSrc
(
src
),
oclDst
(
srcSize
,
src
.
type
());
OCL_TEST_CYCLE
()
cv
::
ocl
::
sqrt
(
oclSrc
,
oclDst
);
oclDst
.
download
(
dst
);
}
else
if
(
RUN_PLAIN_IMPL
)
{
TEST_CYCLE
()
cv
::
sqrt
(
src
,
dst
);
}
else
OCL_PERF_ELSE
SANITY_CHECK
(
dst
,
eps
,
ERROR_RELATIVE
);
}
///////////// Add ////////////////////////
typedef
Size_MatType
AddFixture
;
...
...
modules/ocl/src/arithm.cpp
浏览文件 @
5bc9f15d
...
...
@@ -839,7 +839,7 @@ void cv::ocl::LUT(const oclMat &src, const oclMat &lut, oclMat &dst)
//////////////////////////////// exp log /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_exp_log_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
String
kernelName
,
const
cv
::
ocl
::
ProgramEntry
*
source
)
static
void
arithmetic_exp_log_
sqrt_
run
(
const
oclMat
&
src
,
oclMat
&
dst
,
String
kernelName
,
const
cv
::
ocl
::
ProgramEntry
*
source
)
{
Context
*
clCxt
=
src
.
clCxt
;
if
(
!
clCxt
->
supportsFeature
(
FEATURE_CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
...
...
@@ -882,12 +882,17 @@ static void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, String kernel
void
cv
::
ocl
::
exp
(
const
oclMat
&
src
,
oclMat
&
dst
)
{
arithmetic_exp_log_run
(
src
,
dst
,
"arithm_exp"
,
&
arithm_exp
);
arithmetic_exp_log_
sqrt_
run
(
src
,
dst
,
"arithm_exp"
,
&
arithm_exp
);
}
void
cv
::
ocl
::
log
(
const
oclMat
&
src
,
oclMat
&
dst
)
{
arithmetic_exp_log_run
(
src
,
dst
,
"arithm_log"
,
&
arithm_log
);
arithmetic_exp_log_sqrt_run
(
src
,
dst
,
"arithm_log"
,
&
arithm_log
);
}
void
cv
::
ocl
::
sqrt
(
const
oclMat
&
src
,
oclMat
&
dst
)
{
arithmetic_exp_log_sqrt_run
(
src
,
dst
,
"arithm_sqrt"
,
&
arithm_sqrt
);
}
//////////////////////////////////////////////////////////////////////////////
...
...
modules/ocl/src/opencl/arithm_sqrt.cl
0 → 100644
浏览文件 @
5bc9f15d
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//
IMPORTANT:
READ
BEFORE
DOWNLOADING,
COPYING,
INSTALLING
OR
USING.
//
//
By
downloading,
copying,
installing
or
using
the
software
you
agree
to
this
license.
//
If
you
do
not
agree
to
this
license,
do
not
download,
install,
//
copy
or
use
the
software.
//
//
//
License
Agreement
//
For
Open
Source
Computer
Vision
Library
//
//
Copyright
(
C
)
2010-2012,
Institute
Of
Software
Chinese
Academy
Of
Science,
all
rights
reserved.
//
Copyright
(
C
)
2010-2012,
Advanced
Micro
Devices,
Inc.,
all
rights
reserved.
//
Third
party
copyrights
are
property
of
their
respective
owners.
//
//
@Authors
//
Peter
Andreas
Entschev,
peter@entschev.com
//
//
Redistribution
and
use
in
source
and
binary
forms,
with
or
without
modification,
//
are
permitted
provided
that
the
following
conditions
are
met:
//
//
*
Redistribution
's
of
source
code
must
retain
the
above
copyright
notice,
//
this
list
of
conditions
and
the
following
disclaimer.
//
//
*
Redistribution
's
in
binary
form
must
reproduce
the
above
copyright
notice,
//
this
list
of
conditions
and
the
following
disclaimer
in
the
documentation
//
and/or
other
materials
provided
with
the
distribution.
//
//
*
The
name
of
the
copyright
holders
may
not
be
used
to
endorse
or
promote
products
//
derived
from
this
software
without
specific
prior
written
permission.
//
//
This
software
is
provided
by
the
copyright
holders
and
contributors
as
is
and
//
any
express
or
implied
warranties,
including,
but
not
limited
to,
the
implied
//
warranties
of
merchantability
and
fitness
for
a
particular
purpose
are
disclaimed.
//
In
no
event
shall
the
Intel
Corporation
or
contributors
be
liable
for
any
direct,
//
indirect,
incidental,
special,
exemplary,
or
consequential
damages
//
(
including,
but
not
limited
to,
procurement
of
substitute
goods
or
services
;
//
loss
of
use,
data,
or
profits
; or business interruption) however caused
//
and
on
any
theory
of
liability,
whether
in
contract,
strict
liability,
//
or
tort
(
including
negligence
or
otherwise
)
arising
in
any
way
out
of
//
the
use
of
this
software,
even
if
advised
of
the
possibility
of
such
damage.
//
//M*/
#
ifdef
DOUBLE_SUPPORT
#
ifdef
cl_amd_fp64
#
pragma
OPENCL
EXTENSION
cl_amd_fp64:enable
#
elif
defined
(
cl_khr_fp64
)
#
pragma
OPENCL
EXTENSION
cl_khr_fp64:enable
#
endif
#
endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////LOG/////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
__kernel
void
arithm_sqrt_C1
(
__global
srcT
*src,
__global
srcT
*dst,
int
cols1,
int
rows,
int
srcOffset1,
int
dstOffset1,
int
srcStep1,
int
dstStep1
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols1
&&
y
<
rows
)
{
int
srcIdx
=
mad24
(
y,
srcStep1,
x
+
srcOffset1
)
;
int
dstIdx
=
mad24
(
y,
dstStep1,
x
+
dstOffset1
)
;
dst[dstIdx]
=
sqrt
(
src[srcIdx]
)
;
}
}
__kernel
void
arithm_sqrt_C2
(
__global
srcT
*src,
__global
srcT
*dst,
int
cols1,
int
rows,
int
srcOffset1,
int
dstOffset1,
int
srcStep1,
int
dstStep1
)
{
int
x1
=
get_global_id
(
0
)
<<
1
;
int
y
=
get_global_id
(
1
)
;
if
(
x1
<
cols1
&&
y
<
rows
)
{
int
srcIdx
=
mad24
(
y,
srcStep1,
x1
+
srcOffset1
)
;
int
dstIdx
=
mad24
(
y,
dstStep1,
x1
+
dstOffset1
)
;
dst[dstIdx]
=
sqrt
(
src[srcIdx]
)
;
dst[dstIdx
+
1]
=
x1
+
1
<
cols1
?
sqrt
(
src[srcIdx
+
1]
)
:
dst[dstIdx
+
1]
;
}
}
__kernel
void
arithm_sqrt_C4
(
__global
srcT
*src,
__global
srcT
*dst,
int
cols1,
int
rows,
int
srcOffset1,
int
dstOffset1,
int
srcStep1,
int
dstStep1
)
{
int
x1
=
get_global_id
(
0
)
<<
2
;
int
y
=
get_global_id
(
1
)
;
if
(
x1
<
cols1
&&
y
<
rows
)
{
int
srcIdx
=
mad24
(
y,
srcStep1,
x1
+
srcOffset1
)
;
int
dstIdx
=
mad24
(
y,
dstStep1,
x1
+
dstOffset1
)
;
dst[dstIdx]
=
sqrt
(
src[srcIdx]
)
;
dst[dstIdx
+
1]
=
x1
+
1
<
cols1
?
sqrt
(
src[srcIdx
+
1]
)
:
dst[dstIdx
+
1]
;
dst[dstIdx
+
2]
=
x1
+
2
<
cols1
?
sqrt
(
src[srcIdx
+
2]
)
:
dst[dstIdx
+
2]
;
dst[dstIdx
+
3]
=
x1
+
3
<
cols1
?
sqrt
(
src[srcIdx
+
3]
)
:
dst[dstIdx
+
3]
;
}
}
modules/ocl/test/test_arithm.cpp
浏览文件 @
5bc9f15d
...
...
@@ -278,6 +278,22 @@ OCL_TEST_P(Log, Mat)
}
}
//////////////////////////////// Sqrt ////////////////////////////////////////////////
typedef
ArithmTestBase
Sqrt
;
OCL_TEST_P
(
Sqrt
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
sqrt
(
src1_roi
,
dst1_roi
);
cv
::
ocl
::
sqrt
(
gsrc1_roi
,
gdst1_roi
);
Near
(
1
);
}
}
//////////////////////////////// Add /////////////////////////////////////////////////
typedef
ArithmTestBase
Add
;
...
...
@@ -1569,6 +1585,7 @@ OCL_TEST_P(Repeat, Mat)
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
Values
(
CV_8U
,
CV_8S
,
CV_16U
,
CV_16S
,
CV_32S
,
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
(),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Exp
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Log
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sqrt
,
Combine
(
testing
::
Values
(
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Add
,
Combine
(
Values
(
CV_8U
,
CV_8S
,
CV_16U
,
CV_16S
,
CV_32S
,
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sub
,
Combine
(
Values
(
CV_8U
,
CV_8S
,
CV_16U
,
CV_16S
,
CV_32S
,
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Mul
,
Combine
(
Values
(
CV_8U
,
CV_8S
,
CV_16U
,
CV_16S
,
CV_32S
,
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
Bool
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录