Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
e80f5bed
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 10 个月
通知
995
Star
71100
Fork
55580
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e80f5bed
编写于
10月 31, 2013
作者:
A
Andrey Pavlenko
提交者:
OpenCV Buildbot
10月 31, 2013
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1710 from melody-rain:2.4_moments_ocl
上级
ef9f6905
3dbcd054
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
617 addition
and
1101 deletion
+617
-1101
modules/ocl/include/opencv2/ocl/ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+6
-1
modules/ocl/perf/perf_moments.cpp
modules/ocl/perf/perf_moments.cpp
+22
-21
modules/ocl/src/moments.cpp
modules/ocl/src/moments.cpp
+306
-258
modules/ocl/src/opencl/moments.cl
modules/ocl/src/opencl/moments.cl
+271
-805
modules/ocl/test/test_moments.cpp
modules/ocl/test/test_moments.cpp
+12
-16
未找到文件。
modules/ocl/include/opencv2/ocl/ocl.hpp
浏览文件 @
e80f5bed
...
...
@@ -1520,7 +1520,12 @@ namespace cv
float
pos
,
oclMat
&
newFrame
,
oclMat
&
buf
);
//! computes moments of the rasterized shape or a vector of points
CV_EXPORTS
Moments
ocl_moments
(
InputArray
_array
,
bool
binaryImage
);
//! _array should be a vector a points standing for the contour
CV_EXPORTS
Moments
ocl_moments
(
InputArray
contour
);
//! src should be a general image uploaded to the GPU.
//! the supported oclMat type are CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 and CV_64FC1
//! to use type of CV_64FC1, the GPU should support CV_64FC1
CV_EXPORTS
Moments
ocl_moments
(
oclMat
&
src
,
bool
binary
);
class
CV_EXPORTS
StereoBM_OCL
{
...
...
modules/ocl/perf/perf_moments.cpp
浏览文件 @
e80f5bed
...
...
@@ -26,7 +26,7 @@
//
// * 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
m
aterials provided with the distribution.
// and/or other
M
aterials 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.
...
...
@@ -49,41 +49,42 @@
using
namespace
perf
;
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
std
;
///////////// Moments ////////////////////////
typedef
Size_MatType
MomentsFixture
;
///////////// Moments ////////////////////////
//*! performance of image
typedef
tuple
<
Size
,
MatType
,
bool
>
MomentsParamType
;
typedef
TestBaseWithParam
<
MomentsParamType
>
MomentsFixture
;
PERF_TEST_P
(
MomentsFixture
,
DISABLED_
Moments
,
::
testing
::
Combine
(
OCL_TYPICAL_MAT_SIZES
,
OCL_PERF_ENUM
(
CV_8UC1
,
CV_16SC1
,
CV_32FC1
,
CV_64FC1
)))
// TODO does not work properly (see below
)
PERF_TEST_P
(
MomentsFixture
,
Moments
,
::
testing
::
Combine
(
OCL_TYPICAL_MAT_SIZES
,
OCL_PERF_ENUM
(
CV_8UC1
,
CV_16SC1
,
CV_16UC1
,
CV_32FC1
),
::
testing
::
Values
(
false
,
true
))
)
{
const
Size_MatType_t
params
=
GetParam
();
const
MomentsParamType
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
);
const
bool
binaryImage
=
get
<
2
>
(
params
);
Mat
src
(
srcSize
,
type
),
dst
(
7
,
1
,
CV_64F
);
const
bool
binaryImage
=
false
;
cv
::
Moments
mom
;
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
Mat
src
(
srcSize
,
type
),
dst
(
7
,
1
,
CV_64F
);
randu
(
src
,
0
,
255
);
oclMat
src_d
(
src
);
cv
::
Moments
mom
;
if
(
RUN_OCL_IMPL
)
{
ocl
::
oclMat
oclSrc
(
src
);
OCL_TEST_CYCLE
()
mom
=
cv
::
ocl
::
ocl_moments
(
oclSrc
,
binaryImage
);
// TODO Use oclSrc
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
);
OCL_TEST_CYCLE
()
mom
=
cv
::
ocl
::
ocl_moments
(
src_d
,
binaryImage
);
}
else
if
(
RUN_PLAIN_IMPL
)
{
TEST_CYCLE
()
mom
=
cv
::
moments
(
src
,
binaryImage
);
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
);
}
else
OCL_PERF_ELSE
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
,
1e-3
);
}
modules/ocl/src/moments.cpp
浏览文件 @
e80f5bed
此差异已折叠。
点击以展开。
modules/ocl/src/opencl/moments.cl
浏览文件 @
e80f5bed
此差异已折叠。
点击以展开。
modules/ocl/test/test_moments.cpp
浏览文件 @
e80f5bed
...
...
@@ -10,18 +10,19 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
std
;
PARAM_TEST_CASE
(
MomentsTest
,
MatType
,
bool
)
PARAM_TEST_CASE
(
MomentsTest
,
MatType
,
bool
,
bool
)
{
int
type
;
cv
::
Mat
mat
1
;
cv
::
Mat
mat
;
bool
test_contours
;
bool
binaryImage
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
test_contours
=
GET_PARAM
(
1
);
cv
::
Size
size
(
10
*
MWIDTH
,
10
*
MHEIGHT
);
mat1
=
randomMat
(
size
,
type
,
5
,
16
,
false
);
cv
::
Size
size
(
10
*
MWIDTH
,
10
*
MHEIGHT
);
mat
=
randomMat
(
size
,
type
,
0
,
256
,
false
);
binaryImage
=
GET_PARAM
(
2
);
}
void
Compare
(
Moments
&
cpu
,
Moments
&
gpu
)
...
...
@@ -29,16 +30,13 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
Mat
gpu_dst
,
cpu_dst
;
HuMoments
(
cpu
,
cpu_dst
);
HuMoments
(
gpu
,
gpu_dst
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
.5
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
1e-3
);
}
};
OCL_TEST_P
(
MomentsTest
,
Mat
)
{
bool
binaryImage
=
0
;
oclMat
src_d
(
mat
);
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
if
(
test_contours
)
...
...
@@ -53,18 +51,16 @@ OCL_TEST_P(MomentsTest, Mat)
for
(
size_t
i
=
0
;
i
<
contours
.
size
();
i
++
)
{
Moments
m
=
moments
(
contours
[
i
],
false
);
Moments
dm
=
ocl
::
ocl_moments
(
contours
[
i
]
,
false
);
Moments
dm
=
ocl
::
ocl_moments
(
contours
[
i
]);
Compare
(
m
,
dm
);
}
}
cv
::
_InputArray
_array
(
mat1
);
cv
::
Moments
CvMom
=
cv
::
moments
(
_array
,
binaryImage
);
cv
::
Moments
oclMom
=
cv
::
ocl
::
ocl_moments
(
_array
,
binaryImage
);
cv
::
Moments
CvMom
=
cv
::
moments
(
mat
,
binaryImage
);
cv
::
Moments
oclMom
=
cv
::
ocl
::
ocl_moments
(
src_d
,
binaryImage
);
Compare
(
CvMom
,
oclMom
);
}
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
MomentsTest
,
Combine
(
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_64FC1
),
Values
(
true
,
fals
e
)));
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
,
CV_64FC1
),
Values
(
false
,
true
),
Values
(
false
,
tru
e
)));
#endif // HAVE_OPENCL
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录