Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
1f08d8cb
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,发现更多精彩内容 >>
提交
1f08d8cb
编写于
10月 24, 2014
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3367 from akarsakov:ocl_image2d
上级
1fbad26f
237cb931
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
107 addition
and
1 deletion
+107
-1
modules/core/src/ocl.cpp
modules/core/src/ocl.cpp
+11
-1
modules/core/test/ocl/test_image2d.cpp
modules/core/test/ocl/test_image2d.cpp
+96
-0
未找到文件。
modules/core/src/ocl.cpp
浏览文件 @
1f08d8cb
...
...
@@ -4629,6 +4629,9 @@ struct Image2D::Impl
static
bool
isFormatSupported
(
cl_image_format
format
)
{
if
(
!
haveOpenCL
())
CV_Error
(
Error
::
OpenCLApiCallError
,
"OpenCL runtime not found!"
);
cl_context
context
=
(
cl_context
)
Context
::
getDefault
().
ptr
();
// Figure out how many formats are supported by this context.
cl_uint
numFormats
=
0
;
...
...
@@ -4652,6 +4655,10 @@ struct Image2D::Impl
void
init
(
const
UMat
&
src
,
bool
norm
,
bool
alias
)
{
if
(
!
haveOpenCL
())
CV_Error
(
Error
::
OpenCLApiCallError
,
"OpenCL runtime not found!"
);
CV_Assert
(
!
src
.
empty
());
CV_Assert
(
ocl
::
Device
::
getDefault
().
imageSupport
());
int
err
,
depth
=
src
.
depth
(),
cn
=
src
.
channels
();
...
...
@@ -4661,6 +4668,9 @@ struct Image2D::Impl
if
(
!
isFormatSupported
(
format
))
CV_Error
(
Error
::
OpenCLApiCallError
,
"Image format is not supported"
);
if
(
alias
&&
!
src
.
handle
(
ACCESS_RW
))
CV_Error
(
Error
::
OpenCLApiCallError
,
"Incorrect UMat, handle is null"
);
cl_context
context
=
(
cl_context
)
Context
::
getDefault
().
ptr
();
cl_command_queue
queue
=
(
cl_command_queue
)
Queue
::
getDefault
().
ptr
();
...
...
@@ -4745,7 +4755,7 @@ bool Image2D::canCreateAlias(const UMat &m)
{
bool
ret
=
false
;
const
Device
&
d
=
ocl
::
Device
::
getDefault
();
if
(
d
.
imageFromBufferSupport
())
if
(
d
.
imageFromBufferSupport
()
&&
!
m
.
empty
()
)
{
// This is the required pitch alignment in pixels
uint
pitchAlign
=
d
.
imagePitchAlignment
();
...
...
modules/core/test/ocl/test_image2d.cpp
0 → 100644
浏览文件 @
1f08d8cb
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
namespace
cvtest
{
namespace
ocl
{
TEST
(
Image2D
,
createAliasEmptyUMat
)
{
if
(
cv
::
ocl
::
haveOpenCL
())
{
UMat
um
;
EXPECT_FALSE
(
cv
::
ocl
::
Image2D
::
canCreateAlias
(
um
));
}
else
std
::
cout
<<
"OpenCL runtime not found. Test skipped."
<<
std
::
endl
;
}
TEST
(
Image2D
,
createImage2DWithEmptyUMat
)
{
if
(
cv
::
ocl
::
haveOpenCL
())
{
UMat
um
;
EXPECT_ANY_THROW
(
cv
::
ocl
::
Image2D
image
(
um
));
}
else
std
::
cout
<<
"OpenCL runtime not found. Test skipped."
<<
std
::
endl
;
}
TEST
(
Image2D
,
createAlias
)
{
if
(
cv
::
ocl
::
haveOpenCL
())
{
const
cv
::
ocl
::
Device
&
d
=
cv
::
ocl
::
Device
::
getDefault
();
int
minor
=
d
.
deviceVersionMinor
(),
major
=
d
.
deviceVersionMajor
();
// aliases is OpenCL 1.2 extension
if
(
1
<
major
||
(
1
==
major
&&
2
<=
minor
))
{
UMat
um
(
128
,
128
,
CV_8UC1
);
bool
isFormatSupported
=
false
,
canCreateAlias
=
false
;
EXPECT_NO_THROW
(
isFormatSupported
=
cv
::
ocl
::
Image2D
::
isFormatSupported
(
CV_8U
,
1
,
false
));
EXPECT_NO_THROW
(
canCreateAlias
=
cv
::
ocl
::
Image2D
::
canCreateAlias
(
um
));
if
(
isFormatSupported
&&
canCreateAlias
)
{
EXPECT_NO_THROW
(
cv
::
ocl
::
Image2D
image
(
um
,
false
,
true
));
}
else
std
::
cout
<<
"Impossible to create alias for selected image. Test skipped."
<<
std
::
endl
;
}
}
else
std
::
cout
<<
"OpenCL runtime not found. Test skipped"
<<
std
::
endl
;
}
TEST
(
Image2D
,
turnOffOpenCL
)
{
if
(
cv
::
ocl
::
haveOpenCL
())
{
// save the current state
bool
useOCL
=
cv
::
ocl
::
useOpenCL
();
bool
isFormatSupported
=
false
;
cv
::
ocl
::
setUseOpenCL
(
true
);
UMat
um
(
128
,
128
,
CV_8UC1
);
cv
::
ocl
::
setUseOpenCL
(
false
);
EXPECT_NO_THROW
(
isFormatSupported
=
cv
::
ocl
::
Image2D
::
isFormatSupported
(
CV_8U
,
1
,
true
));
if
(
isFormatSupported
)
{
EXPECT_NO_THROW
(
cv
::
ocl
::
Image2D
image
(
um
));
}
else
std
::
cout
<<
"CV_8UC1 is not supported for OpenCL images. Test skipped."
<<
std
::
endl
;
// reset state to the previous one
cv
::
ocl
::
setUseOpenCL
(
useOCL
);
}
else
std
::
cout
<<
"OpenCL runtime not found. Test skipped."
<<
std
::
endl
;
}
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录