Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d8f749da
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,发现更多精彩内容 >>
提交
d8f749da
编写于
1月 25, 2013
作者:
A
Andrey Kamaev
提交者:
OpenCV Buildbot
1月 25, 2013
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #337 from taka-no-me:ocl_appsdk
上级
dc11acf0
9509dfd1
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
1084 addition
and
1062 deletion
+1084
-1062
CMakeLists.txt
CMakeLists.txt
+2
-2
cmake/OpenCVDetectOpenCL.cmake
cmake/OpenCVDetectOpenCL.cmake
+8
-0
modules/ocl/CMakeLists.txt
modules/ocl/CMakeLists.txt
+2
-0
modules/ocl/include/opencv2/ocl/ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+6
-5
modules/ocl/perf/main.cpp
modules/ocl/perf/main.cpp
+5
-5
modules/ocl/perf/perf_arithm.cpp
modules/ocl/perf/perf_arithm.cpp
+2
-2
modules/ocl/perf/perf_haar.cpp
modules/ocl/perf/perf_haar.cpp
+9
-9
modules/ocl/perf/perf_imgproc.cpp
modules/ocl/perf/perf_imgproc.cpp
+3
-4
modules/ocl/perf/precomp.hpp
modules/ocl/perf/precomp.hpp
+9
-0
modules/ocl/perf/utility.hpp
modules/ocl/perf/utility.hpp
+6
-6
modules/ocl/src/arithm.cpp
modules/ocl/src/arithm.cpp
+32
-28
modules/ocl/src/brute_force_matcher.cpp
modules/ocl/src/brute_force_matcher.cpp
+1
-1
modules/ocl/src/filtering.cpp
modules/ocl/src/filtering.cpp
+23
-22
modules/ocl/src/haar.cpp
modules/ocl/src/haar.cpp
+734
-746
modules/ocl/src/imgproc.cpp
modules/ocl/src/imgproc.cpp
+31
-19
modules/ocl/src/initialization.cpp
modules/ocl/src/initialization.cpp
+2
-12
modules/ocl/src/interpolate_frames.cpp
modules/ocl/src/interpolate_frames.cpp
+1
-1
modules/ocl/src/match_template.cpp
modules/ocl/src/match_template.cpp
+1
-1
modules/ocl/src/matrix_operations.cpp
modules/ocl/src/matrix_operations.cpp
+7
-7
modules/ocl/src/mcwutil.cpp
modules/ocl/src/mcwutil.cpp
+1
-1
modules/ocl/src/precomp.hpp
modules/ocl/src/precomp.hpp
+1
-1
modules/ocl/src/pyrdown.cpp
modules/ocl/src/pyrdown.cpp
+1
-1
modules/ocl/src/pyrlk.cpp
modules/ocl/src/pyrlk.cpp
+68
-68
modules/ocl/src/split_merge.cpp
modules/ocl/src/split_merge.cpp
+93
-93
modules/ocl/src/surf.cpp
modules/ocl/src/surf.cpp
+1
-1
modules/ocl/test/precomp.hpp
modules/ocl/test/precomp.hpp
+9
-0
modules/ocl/test/test_arithm.cpp
modules/ocl/test/test_arithm.cpp
+3
-3
modules/ocl/test/test_blend.cpp
modules/ocl/test/test_blend.cpp
+1
-1
modules/ocl/test/test_color.cpp
modules/ocl/test/test_color.cpp
+2
-2
modules/ocl/test/test_haar.cpp
modules/ocl/test/test_haar.cpp
+9
-9
modules/ocl/test/test_imgproc.cpp
modules/ocl/test/test_imgproc.cpp
+3
-4
modules/ocl/test/test_match_template.cpp
modules/ocl/test/test_match_template.cpp
+2
-2
modules/ocl/test/utility.hpp
modules/ocl/test/utility.hpp
+6
-6
未找到文件。
CMakeLists.txt
浏览文件 @
d8f749da
...
...
@@ -415,10 +415,10 @@ if(WITH_OPENCL)
if
(
OPENCL_FOUND
)
set
(
HAVE_OPENCL 1
)
endif
()
if
(
WITH_OPENCLAMDFFT
)
if
(
WITH_OPENCLAMDFFT
AND CLAMDFFT_INCLUDE_DIR
)
set
(
HAVE_CLAMDFFT 1
)
endif
()
if
(
WITH_OPENCLAMDBLAS
)
if
(
WITH_OPENCLAMDBLAS
AND CLAMDBLAS_INCLUDE_DIR
)
set
(
HAVE_CLAMDBLAS 1
)
endif
()
endif
()
...
...
cmake/OpenCVDetectOpenCL.cmake
浏览文件 @
d8f749da
...
...
@@ -78,9 +78,17 @@ else()
# Try AMD/ATI Stream SDK
if
(
NOT OPENCL_FOUND
)
set
(
ENV_AMDSTREAMSDKROOT $ENV{AMDAPPSDKROOT}
)
set
(
ENV_AMDAPPSDKROOT $ENV{AMDAPPSDKROOT}
)
set
(
ENV_OPENCLROOT $ENV{OPENCLROOT}
)
set
(
ENV_CUDA_PATH $ENV{CUDA_PATH}
)
if
(
ENV_AMDSTREAMSDKROOT
)
set
(
OPENCL_INCLUDE_SEARCH_PATH
${
ENV_AMDAPPSDKROOT
}
/include
)
if
(
CMAKE_SIZEOF_VOID_P EQUAL 4
)
set
(
OPENCL_LIB_SEARCH_PATH
${
OPENCL_LIB_SEARCH_PATH
}
${
ENV_AMDAPPSDKROOT
}
/lib/x86
)
else
()
set
(
OPENCL_LIB_SEARCH_PATH
${
OPENCL_LIB_SEARCH_PATH
}
${
ENV_AMDAPPSDKROOT
}
/lib/x86_64
)
endif
()
elseif
(
ENV_AMDSTREAMSDKROOT
)
set
(
OPENCL_INCLUDE_SEARCH_PATH
${
ENV_AMDSTREAMSDKROOT
}
/include
)
if
(
CMAKE_SIZEOF_VOID_P EQUAL 4
)
set
(
OPENCL_LIB_SEARCH_PATH
${
OPENCL_LIB_SEARCH_PATH
}
${
ENV_AMDSTREAMSDKROOT
}
/lib/x86
)
...
...
modules/ocl/CMakeLists.txt
浏览文件 @
d8f749da
...
...
@@ -39,6 +39,8 @@ if (HAVE_OPENCL)
endif
()
endif
()
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wshadow
)
ocv_set_module_sources
(
HEADERS
${
lib_hdrs
}
SOURCES
${
lib_int_hdrs
}
${
lib_srcs
}
${
kernels_cpp
}
)
ocv_create_module
(
${
ocl_link_libs
}
)
...
...
modules/ocl/include/opencv2/ocl/ocl.hpp
浏览文件 @
d8f749da
...
...
@@ -1738,12 +1738,13 @@ namespace cv
}
}
#if _MSC_VER >= 1200
#pragma warning( push)
#pragma warning( disable: 4267)
#if
defined _MSC_VER &&
_MSC_VER >= 1200
#
pragma warning( push)
#
pragma warning( disable: 4267)
#endif
#include "opencv2/ocl/matrix_operations.hpp"
#if _MSC_VER >= 1200
#pragma warning( pop)
#if
defined _MSC_VER &&
_MSC_VER >= 1200
#
pragma warning( pop)
#endif
#endif
/* __OPENCV_GPU_HPP__ */
modules/ocl/perf/main.cpp
浏览文件 @
d8f749da
...
...
@@ -113,15 +113,15 @@ int main(int argc, char **argv)
print_info
();
int
flag
=
CVCL_DEVICE_TYPE_GPU
;
//
int flag = CVCL_DEVICE_TYPE_GPU;
if
(
type
==
"cpu"
)
//
if(type == "cpu")
{
//
{
flag
=
CVCL_DEVICE_TYPE_CPU
;
//
flag = CVCL_DEVICE_TYPE_CPU;
}
//
}
std
::
vector
<
cv
::
ocl
::
Info
>
oclinfo
;
int
devnums
=
getDevice
(
oclinfo
);
if
(
devnums
<=
device
||
device
<
0
)
...
...
modules/ocl/perf/perf_arithm.cpp
浏览文件 @
d8f749da
...
...
@@ -2597,13 +2597,13 @@ TEST_P(Sum, MAT)
Has_roi
(
k
);
t0
=
(
double
)
cvGetTickCount
();
//cpu start
Scalar
cpures
=
cv
::
sum
(
mat1_roi
);
cv
::
sum
(
mat1_roi
);
t0
=
(
double
)
cvGetTickCount
()
-
t0
;
//cpu end
t1
=
(
double
)
cvGetTickCount
();
//gpu start1
gmat1
=
mat1_roi
;
t2
=
(
double
)
cvGetTickCount
();
//kernel
Scalar
gpures
=
cv
::
ocl
::
sum
(
gmat1
);
cv
::
ocl
::
sum
(
gmat1
);
t2
=
(
double
)
cvGetTickCount
()
-
t2
;
//kernel
t1
=
(
double
)
cvGetTickCount
()
-
t1
;
//gpu end1
if
(
j
==
0
)
...
...
modules/ocl/perf/perf_haar.cpp
浏览文件 @
d8f749da
...
...
@@ -109,15 +109,15 @@ TEST_F(Haar, FaceDetect)
double
t
=
0
;
vector
<
Rect
>
faces
,
oclfaces
;
const
static
Scalar
colors
[]
=
{
CV_RGB
(
0
,
0
,
255
),
CV_RGB
(
0
,
128
,
255
),
CV_RGB
(
0
,
255
,
255
),
CV_RGB
(
0
,
255
,
0
),
CV_RGB
(
255
,
128
,
0
),
CV_RGB
(
255
,
255
,
0
),
CV_RGB
(
255
,
0
,
0
),
CV_RGB
(
255
,
0
,
255
)
}
;
//
const static Scalar colors[] = { CV_RGB(0, 0, 255),
//
CV_RGB(0, 128, 255),
//
CV_RGB(0, 255, 255),
//
CV_RGB(0, 255, 0),
//
CV_RGB(255, 128, 0),
//
CV_RGB(255, 255, 0),
//
CV_RGB(255, 0, 0),
//
CV_RGB(255, 0, 255)
//
} ;
Mat
gray
,
smallImg
(
cvRound
(
img
.
rows
/
scale
),
cvRound
(
img
.
cols
/
scale
),
CV_8UC1
);
MemStorage
storage
(
cvCreateMemStorage
(
0
));
...
...
modules/ocl/perf/perf_imgproc.cpp
浏览文件 @
d8f749da
...
...
@@ -379,7 +379,7 @@ TEST_P(bilateralFilter, Mat)
}
else
{
for
(
in
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
size_
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
{
cout
<<
borderstr
[
i
]
<<
endl
;
#ifndef PRINT_KERNEL_RUN_TIME
...
...
@@ -397,7 +397,7 @@ TEST_P(bilateralFilter, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
+
1
;
j
++
)
{
Has_roi
(
k
);
if
(((
bordertype
[
i
]
!=
cv
::
BORDER_CONSTANT
)
&&
(
bordertype
[
i
]
!=
cv
::
BORDER_REPLICATE
)
)
&&
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
))
if
(((
bordertype
[
i
]
!=
cv
::
BORDER_CONSTANT
)
&&
(
bordertype
[
i
]
!=
cv
::
BORDER_REPLICATE
)
&&
(
mat1_roi
.
cols
<=
radius
)
)
||
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
))
{
continue
;
}
...
...
@@ -482,7 +482,7 @@ TEST_P(CopyMakeBorder, Mat)
}
else
{
for
(
in
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
size_
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
{
#ifndef PRINT_KERNEL_RUN_TIME
double
totalcputick
=
0
;
...
...
@@ -1133,7 +1133,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
srcSize
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
cv
::
Size
dstSize
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
cv
::
Size
map1Size
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
double
min
=
5
,
max
=
16
;
...
...
modules/ocl/perf/precomp.hpp
浏览文件 @
d8f749da
...
...
@@ -38,6 +38,15 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
...
...
modules/ocl/perf/utility.hpp
浏览文件 @
d8f749da
...
...
@@ -84,12 +84,12 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
}
/
/
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
//
{ \
//
ASSERT_EQ(mat1.type(), mat2.type()); \
//
ASSERT_EQ(mat1.size(), mat2.size()); \
//
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
//}
/
*
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}*/
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
{ \
...
...
modules/ocl/src/arithm.cpp
浏览文件 @
d8f749da
...
...
@@ -362,11 +362,11 @@ void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
void
arithmetic_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
arithmetic_run
<
char
>
(
src1
,
src2
,
dst
,
kernelName
,
kernelString
,
(
void
*
)
NULL
);
}
void
arithmetic_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
{
...
...
@@ -476,7 +476,9 @@ void arithmetic_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst,
//CV_Assert(src1.depth() != CV_8S);
if
(
mask
.
data
)
{
CV_Assert
(
mask
.
type
()
==
CV_8U
&&
src1
.
rows
==
mask
.
rows
&&
src1
.
cols
==
mask
.
cols
);
}
Context
*
clCxt
=
src1
.
clCxt
;
int
channels
=
dst
.
oclchannels
();
...
...
@@ -530,7 +532,7 @@ void arithmetic_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst,
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
);
}
void
arithmetic_scalar_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
,
double
scalar
)
static
void
arithmetic_scalar_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
,
double
scalar
)
{
if
(
src
.
clCxt
->
impl
->
double_support
==
0
&&
src
.
type
()
==
CV_64F
)
{
...
...
@@ -590,7 +592,7 @@ void arithmetic_scalar_run(const oclMat &src, oclMat &dst, string kernelName, co
typedef
void
(
*
ArithmeticFuncS
)(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
);
void
arithmetic_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
)
static
void
arithmetic_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
)
{
static
ArithmeticFuncS
tab
[
8
]
=
{
...
...
@@ -608,7 +610,7 @@ void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, cons
cv
::
ocl
::
error
(
"Unsupported arithmetic operation"
,
__FILE__
,
__LINE__
);
func
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
isMatSubScalar
);
}
void
arithmetic_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
{
arithmetic_scalar
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
0
);
}
...
...
@@ -660,7 +662,7 @@ void cv::ocl::absdiff(const oclMat &src1, const Scalar &src2, oclMat &dst)
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////// compare ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
compare_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
compare_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
dst
.
create
(
src1
.
size
(),
CV_8UC1
);
CV_Assert
(
src1
.
oclchannels
()
==
1
);
...
...
@@ -739,7 +741,7 @@ void cv::ocl::compare(const oclMat &src1, const oclMat &src2, oclMat &dst , int
//////////////////////////////////////////////////////////////////////////////
//type = 0 sum,type = 1 absSum,type = 2 sqrSum
void
arithmetic_sum_buffer_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
int
type
=
0
)
static
void
arithmetic_sum_buffer_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
int
type
=
0
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
int
all_cols
=
src
.
step
/
(
vlen
*
src
.
elemSize1
());
...
...
@@ -872,7 +874,7 @@ void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// minMax /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_minMax_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
static
void
arithmetic_minMax_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
int
all_cols
=
src
.
step
/
(
vlen
*
src
.
elemSize1
());
...
...
@@ -909,7 +911,7 @@ void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem &dst, i
}
void
arithmetic_minMax_mask_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
static
void
arithmetic_minMax_mask_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
size_t
gt
[
3
]
=
{
groupnum
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
...
...
@@ -1063,7 +1065,7 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// flip //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_flip_rows_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
static
void
arithmetic_flip_rows_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
{
if
(
src
.
clCxt
->
impl
->
double_support
==
0
&&
src
.
type
()
==
CV_64F
)
{
...
...
@@ -1112,7 +1114,7 @@ void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kernelName)
openCLExecuteKernel
(
clCxt
,
&
arithm_flip
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
void
arithmetic_flip_cols_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
bool
isVertical
)
static
void
arithmetic_flip_cols_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
bool
isVertical
)
{
if
(
src
.
clCxt
->
impl
->
double_support
==
0
&&
src
.
type
()
==
CV_64F
)
{
...
...
@@ -1183,7 +1185,7 @@ void cv::ocl::flip(const oclMat &src, oclMat &dst, int flipCode)
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// LUT //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_lut_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
static
void
arithmetic_lut_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
{
Context
*
clCxt
=
src1
.
clCxt
;
int
channels
=
src1
.
oclchannels
();
...
...
@@ -1284,7 +1286,7 @@ void cv::ocl::LUT(const oclMat &src, const oclMat &lut, oclMat &dst)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// exp log /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_exp_log_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_exp_log_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
dst
.
create
(
src
.
size
(),
src
.
type
());
CV_Assert
(
src
.
cols
==
dst
.
cols
&&
...
...
@@ -1333,7 +1335,7 @@ void cv::ocl::log(const oclMat &src, oclMat &dst)
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// magnitude phase ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_magnitude_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
static
void
arithmetic_magnitude_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
{
...
...
@@ -1381,7 +1383,7 @@ void cv::ocl::magnitude(const oclMat &src1, const oclMat &src2, oclMat &dst)
arithmetic_magnitude_phase_run
(
src1
,
src2
,
dst
,
"arithm_magnitude"
);
}
void
arithmetic_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_phase_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
{
...
...
@@ -1444,7 +1446,7 @@ void cv::ocl::phase(const oclMat &x, const oclMat &y, oclMat &Angle , bool angle
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// cartToPolar ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_cartToPolar_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst_mag
,
oclMat
&
dst_cart
,
static
void
arithmetic_cartToPolar_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst_mag
,
oclMat
&
dst_cart
,
string
kernelName
,
bool
angleInDegrees
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
...
...
@@ -1499,7 +1501,7 @@ void cv::ocl::cartToPolar(const oclMat &x, const oclMat &y, oclMat &mag, oclMat
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// polarToCart ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_ptc_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst1
,
oclMat
&
dst2
,
bool
angleInDegrees
,
static
void
arithmetic_ptc_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst1
,
oclMat
&
dst2
,
bool
angleInDegrees
,
string
kernelName
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
...
...
@@ -1564,7 +1566,7 @@ void cv::ocl::polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// minMaxLoc ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_minMaxLoc_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
static
void
arithmetic_minMaxLoc_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
int
all_cols
=
src
.
step
/
(
vlen
*
src
.
elemSize1
());
...
...
@@ -1588,7 +1590,7 @@ void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , int gro
openCLExecuteKernel
(
src
.
clCxt
,
&
arithm_minMaxLoc
,
"arithm_op_minMaxLoc"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
);
}
void
arithmetic_minMaxLoc_mask_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
static
void
arithmetic_minMaxLoc_mask_run
(
const
oclMat
&
src
,
const
oclMat
&
mask
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
size_t
gt
[
3
]
=
{
groupnum
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
...
...
@@ -1702,7 +1704,7 @@ void cv::ocl::minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
//////////////////////////////////////////////////////////////////////////////
///////////////////////////// countNonZero ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
arithmetic_countNonZero_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
static
void
arithmetic_countNonZero_run
(
const
oclMat
&
src
,
cl_mem
&
dst
,
int
vlen
,
int
groupnum
,
string
kernelName
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
int
all_cols
=
src
.
step
/
(
vlen
*
src
.
elemSize1
());
...
...
@@ -1759,7 +1761,7 @@ int cv::ocl::countNonZero(const oclMat &src)
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////bitwise_op////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
bitwise_run
(
const
oclMat
&
src1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
bitwise_run
(
const
oclMat
&
src1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
dst
.
create
(
src1
.
size
(),
src1
.
type
());
...
...
@@ -1853,11 +1855,11 @@ void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string ker
openCLExecuteKernel
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
void
bitwise_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
bitwise_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
bitwise_run
<
char
>
(
src1
,
src2
,
dst
,
kernelName
,
kernelString
,
(
void
*
)
NULL
);
}
void
bitwise_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
static
void
bitwise_run
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
{
dst
.
create
(
src1
.
size
(),
src1
.
type
());
CV_Assert
(
src1
.
cols
==
src2
.
cols
&&
src2
.
cols
==
dst
.
cols
&&
...
...
@@ -1919,7 +1921,9 @@ void bitwise_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, con
if
(
mask
.
data
)
{
CV_Assert
(
mask
.
type
()
==
CV_8U
&&
src1
.
rows
==
mask
.
rows
&&
src1
.
cols
==
mask
.
cols
);
}
Context
*
clCxt
=
src1
.
clCxt
;
int
channels
=
dst
.
oclchannels
();
...
...
@@ -1977,7 +1981,7 @@ void bitwise_scalar_run(const oclMat &src1, const Scalar &src2, oclMat &dst, con
typedef
void
(
*
BitwiseFuncS
)(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
);
void
bitwise_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
)
static
void
bitwise_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
,
int
isMatSubScalar
)
{
static
BitwiseFuncS
tab
[
8
]
=
{
...
...
@@ -2007,7 +2011,7 @@ void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const o
cv
::
ocl
::
error
(
"Unsupported arithmetic operation"
,
__FILE__
,
__LINE__
);
func
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
isMatSubScalar
);
}
void
bitwise_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
static
void
bitwise_scalar
(
const
oclMat
&
src1
,
const
Scalar
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
,
const
char
**
kernelString
)
{
bitwise_scalar
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
0
);
}
...
...
@@ -2153,7 +2157,7 @@ cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2)
//////////////////////////////////////////////////////////////////////////////
#define TILE_DIM (32)
#define BLOCK_ROWS (256/TILE_DIM)
void
transpose_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
static
void
transpose_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
{
if
(
src
.
clCxt
->
impl
->
double_support
==
0
&&
src
.
type
()
==
CV_64F
)
{
...
...
@@ -2368,7 +2372,7 @@ void cv::ocl::magnitudeSqr(const oclMat &src1, oclMat &dst)
openCLExecuteKernel
(
clCxt
,
&
arithm_magnitudeSqr
,
"magnitudeSqr"
,
globalThreads
,
localThreads
,
args
,
2
,
depth
);
}
void
arithmetic_pow_run
(
const
oclMat
&
src1
,
double
p
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
arithmetic_pow_run
(
const
oclMat
&
src1
,
double
p
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
CV_Assert
(
src1
.
cols
==
dst
.
cols
&&
src1
.
rows
==
dst
.
rows
);
CV_Assert
(
src1
.
type
()
==
dst
.
type
());
...
...
@@ -2417,7 +2421,7 @@ void cv::ocl::pow(const oclMat &x, double p, oclMat &y)
return
;
}
CV_Assert
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
x
.
depth
()
==
CV_32F
||
x
.
depth
()
==
CV_64F
);
CV_Assert
(
(
x
.
type
()
==
y
.
type
()
&&
x
.
size
()
==
y
.
size
()
&&
x
.
depth
()
==
CV_32F
)
||
x
.
depth
()
==
CV_64F
);
y
.
create
(
x
.
size
(),
x
.
type
());
string
kernelName
=
"arithm_pow"
;
...
...
modules/ocl/src/brute_force_matcher.cpp
浏览文件 @
d8f749da
...
...
@@ -821,7 +821,7 @@ void findKnnMatch(int k, const oclMat &trainIdx, const oclMat &distance, const o
}
}
void
findKnnMatchDispatcher
(
int
k
,
const
oclMat
&
trainIdx
,
const
oclMat
&
distance
,
const
oclMat
&
allDist
,
int
distType
)
static
void
findKnnMatchDispatcher
(
int
k
,
const
oclMat
&
trainIdx
,
const
oclMat
&
distance
,
const
oclMat
&
allDist
,
int
distType
)
{
findKnnMatch
<
256
>
(
k
,
trainIdx
,
distance
,
allDist
,
distType
);
}
...
...
modules/ocl/src/filtering.cpp
浏览文件 @
d8f749da
...
...
@@ -332,7 +332,7 @@ public:
**Extend this if necessary later.
**Note that the kernel need to be further refined.
*/
void
GPUErode
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
Size
&
ksize
,
const
Point
anchor
)
static
void
GPUErode
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
Size
&
ksize
,
const
Point
anchor
)
{
//Normalize the result by default
//float alpha = ksize.height * ksize.width;
...
...
@@ -388,7 +388,7 @@ void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, c
}
char
compile_option
[
128
];
sprintf
(
compile_option
,
"-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s"
,
anchor
.
x
,
anchor
.
y
,
localThreads
[
0
],
localThreads
[
1
],
s
);
sprintf
(
compile_option
,
"-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s"
,
anchor
.
x
,
anchor
.
y
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
s
);
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
dst
.
data
));
...
...
@@ -407,7 +407,7 @@ void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, c
//! data type supported: CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4
void
GPUDilate
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
Size
&
ksize
,
const
Point
anchor
)
static
void
GPUDilate
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
Size
&
ksize
,
const
Point
anchor
)
{
//Normalize the result by default
//float alpha = ksize.height * ksize.width;
...
...
@@ -463,7 +463,7 @@ void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize,
}
char
compile_option
[
128
];
sprintf
(
compile_option
,
"-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s"
,
anchor
.
x
,
anchor
.
y
,
localThreads
[
0
],
localThreads
[
1
],
s
);
sprintf
(
compile_option
,
"-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s"
,
anchor
.
x
,
anchor
.
y
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
s
);
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
dst
.
data
));
...
...
@@ -691,7 +691,7 @@ public:
};
}
void
GPUFilter2D
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
static
void
GPUFilter2D
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
mat_kernel
,
Size
&
ksize
,
const
Point
anchor
,
const
int
borderType
)
{
CV_Assert
(
src
.
clCxt
==
dst
.
clCxt
);
...
...
@@ -850,7 +850,7 @@ Ptr<FilterEngine_GPU> cv::ocl::createSeparableFilter_GPU(const Ptr<BaseRowFilter
**support four border types: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_REFLECT_101
*/
void
GPUFilterBox_8u_C1R
(
const
oclMat
&
src
,
oclMat
&
dst
,
static
void
GPUFilterBox_8u_C1R
(
const
oclMat
&
src
,
oclMat
&
dst
,
Size
&
ksize
,
const
Point
anchor
,
const
int
borderType
)
{
//Normalize the result by default
...
...
@@ -912,7 +912,7 @@ void GPUFilterBox_8u_C1R(const oclMat &src, oclMat &dst,
openCLExecuteKernel
(
clCxt
,
&
filtering_boxFilter
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
build_options
);
}
void
GPUFilterBox_8u_C4R
(
const
oclMat
&
src
,
oclMat
&
dst
,
static
void
GPUFilterBox_8u_C4R
(
const
oclMat
&
src
,
oclMat
&
dst
,
Size
&
ksize
,
const
Point
anchor
,
const
int
borderType
)
{
//Normalize the result by default
...
...
@@ -974,7 +974,7 @@ void GPUFilterBox_8u_C4R(const oclMat &src, oclMat &dst,
openCLExecuteKernel
(
clCxt
,
&
filtering_boxFilter
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
build_options
);
}
void
GPUFilterBox_32F_C1R
(
const
oclMat
&
src
,
oclMat
&
dst
,
static
void
GPUFilterBox_32F_C1R
(
const
oclMat
&
src
,
oclMat
&
dst
,
Size
&
ksize
,
const
Point
anchor
,
const
int
borderType
)
{
//Normalize the result by default
...
...
@@ -1037,7 +1037,7 @@ void GPUFilterBox_32F_C1R(const oclMat &src, oclMat &dst,
openCLExecuteKernel
(
clCxt
,
&
filtering_boxFilter
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
build_options
);
}
void
GPUFilterBox_32F_C4R
(
const
oclMat
&
src
,
oclMat
&
dst
,
static
void
GPUFilterBox_32F_C4R
(
const
oclMat
&
src
,
oclMat
&
dst
,
Size
&
ksize
,
const
Point
anchor
,
const
int
borderType
)
{
//Normalize the result by default
...
...
@@ -1218,7 +1218,7 @@ void linearRowFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_kernel
}
char
compile_option
[
128
];
sprintf
(
compile_option
,
"-D RADIUSX=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
);
sprintf
(
compile_option
,
"-D RADIUSX=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s"
,
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
);
size_t
globalThreads
[
3
];
globalThreads
[
1
]
=
(
dst
.
rows
+
localThreads
[
1
]
-
1
)
/
localThreads
[
1
]
*
localThreads
[
1
];
...
...
@@ -1251,12 +1251,12 @@ void linearRowFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_kernel
CV_Assert
(
src
.
oclchannels
()
==
dst
.
oclchannels
());
CV_Assert
(
ksize
==
(
anchor
<<
1
)
+
1
);
int
src_pix_per_row
,
dst_pix_per_row
;
int
src_offset_x
,
src_offset_y
,
dst_offset_in_pixel
;
int
src_offset_x
,
src_offset_y
;
//
, dst_offset_in_pixel;
src_pix_per_row
=
src
.
step
/
src
.
elemSize
();
src_offset_x
=
(
src
.
offset
%
src
.
step
)
/
src
.
elemSize
();
src_offset_y
=
src
.
offset
/
src
.
step
;
dst_pix_per_row
=
dst
.
step
/
dst
.
elemSize
();
dst_offset_in_pixel
=
dst
.
offset
/
dst
.
elemSize
();
//
dst_offset_in_pixel = dst.offset / dst.elemSize();
int
ridusy
=
(
dst
.
rows
-
src
.
rows
)
>>
1
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
&
src
.
data
));
...
...
@@ -1363,18 +1363,18 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker
case
1
:
globalThreads
[
0
]
=
(
dst
.
cols
+
localThreads
[
0
]
-
1
)
/
localThreads
[
0
]
*
localThreads
[
0
];
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float"
,
"uchar"
,
"convert_uchar_sat"
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float"
,
"uchar"
,
"convert_uchar_sat"
);
break
;
case
2
:
globalThreads
[
0
]
=
((
dst
.
cols
+
1
)
/
2
+
localThreads
[
0
]
-
1
)
/
localThreads
[
0
]
*
localThreads
[
0
];
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float2"
,
"uchar2"
,
"convert_uchar2_sat"
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float2"
,
"uchar2"
,
"convert_uchar2_sat"
);
break
;
case
3
:
case
4
:
globalThreads
[
0
]
=
(
dst
.
cols
+
localThreads
[
0
]
-
1
)
/
localThreads
[
0
]
*
localThreads
[
0
];
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"uchar4"
,
"convert_uchar4_sat"
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"uchar4"
,
"convert_uchar4_sat"
);
break
;
}
}
...
...
@@ -1386,21 +1386,21 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker
{
case
CV_32SC1
:
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float"
,
"int"
,
"convert_int_sat"
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float"
,
"int"
,
"convert_int_sat"
);
break
;
case
CV_32SC3
:
case
CV_32SC4
:
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"int4"
,
"convert_int4_sat"
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"int4"
,
"convert_int4_sat"
);
break
;
case
CV_32FC1
:
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float"
,
"float"
,
""
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float"
,
"float"
,
""
);
break
;
case
CV_32FC3
:
case
CV_32FC4
:
sprintf
(
compile_option
,
"-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s"
,
anchor
,
localThreads
[
0
],
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"float4"
,
""
);
anchor
,
(
int
)
localThreads
[
0
],
(
int
)
localThreads
[
1
],
channels
,
btype
,
"float4"
,
"float4"
,
""
);
break
;
}
}
...
...
@@ -1411,10 +1411,11 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker
CV_Assert
(
src
.
oclchannels
()
==
dst
.
oclchannels
());
CV_Assert
(
ksize
==
(
anchor
<<
1
)
+
1
);
int
src_pix_per_row
,
dst_pix_per_row
;
int
src_offset_x
,
src_offset_y
,
dst_offset_in_pixel
;
//int src_offset_x, src_offset_y;
int
dst_offset_in_pixel
;
src_pix_per_row
=
src
.
step
/
src
.
elemSize
();
src_offset_x
=
(
src
.
offset
%
src
.
step
)
/
src
.
elemSize
();
src_offset_y
=
src
.
offset
/
src
.
step
;
//
src_offset_x = (src.offset % src.step) / src.elemSize();
//
src_offset_y = src.offset / src.step;
dst_pix_per_row
=
dst
.
step
/
dst
.
elemSize
();
dst_offset_in_pixel
=
dst
.
offset
/
dst
.
elemSize
();
...
...
modules/ocl/src/haar.cpp
浏览文件 @
d8f749da
此差异已折叠。
点击以展开。
modules/ocl/src/imgproc.cpp
浏览文件 @
d8f749da
...
...
@@ -171,7 +171,7 @@ namespace cv
typedef
void
(
*
gpuThresh_t
)(
const
oclMat
&
src
,
oclMat
&
dst
,
double
thresh
,
double
maxVal
,
int
type
);
void
threshold_8u
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
thresh
,
double
maxVal
,
int
type
)
static
void
threshold_8u
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
thresh
,
double
maxVal
,
int
type
)
{
CV_Assert
(
(
src
.
cols
==
dst
.
cols
)
&&
(
src
.
rows
==
dst
.
rows
)
);
Context
*
clCxt
=
src
.
clCxt
;
...
...
@@ -202,7 +202,7 @@ namespace cv
openCLExecuteKernel
(
clCxt
,
&
imgproc_threshold
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
src
.
depth
());
}
void
threshold_32f
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
thresh
,
double
maxVal
,
int
type
)
static
void
threshold_32f
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
thresh
,
double
maxVal
,
int
type
)
{
CV_Assert
(
(
src
.
cols
==
dst
.
cols
)
&&
(
src
.
rows
==
dst
.
rows
)
);
Context
*
clCxt
=
src
.
clCxt
;
...
...
@@ -388,7 +388,7 @@ namespace cv
////////////////////////////////////////////////////////////////////////////////////////////
// resize
void
resize_gpu
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
fx
,
double
fy
,
int
interpolation
)
static
void
resize_gpu
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
fx
,
double
fy
,
int
interpolation
)
{
CV_Assert
(
(
src
.
channels
()
==
dst
.
channels
())
);
Context
*
clCxt
=
src
.
clCxt
;
...
...
@@ -593,7 +593,7 @@ namespace cv
int
dstOffset
=
dst
.
offset
/
dst
.
elemSize
();
int
__bordertype
[]
=
{
cv
::
BORDER_CONSTANT
,
cv
::
BORDER_REPLICATE
,
BORDER_REFLECT
,
BORDER_WRAP
,
BORDER_REFLECT_101
};
const
char
*
borderstr
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
,
"BORDER_REFLECT"
,
"BORDER_WRAP"
,
"BORDER_REFLECT_101"
};
in
t
bordertype_index
;
size_
t
bordertype_index
;
for
(
bordertype_index
=
0
;
bordertype_index
<
sizeof
(
__bordertype
)
/
sizeof
(
int
);
bordertype_index
++
)
{
if
(
__bordertype
[
bordertype_index
]
==
bordertype
)
...
...
@@ -826,9 +826,9 @@ namespace cv
{
#define Sd(y,x) (Sd[y*3+x])
#define Dd(y,x) (Dd[y*3+x])
#define det3(m) (m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) - \
m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) + \
m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0)))
#define det3(m)
(m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) - \
m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) + \
m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0)))
double
*
Sd
=
M
;
double
*
Dd
=
M
;
double
d
=
det3
(
Sd
);
...
...
@@ -1018,12 +1018,19 @@ namespace cv
int
warpInd
=
(
flags
&
WARP_INVERSE_MAP
)
>>
4
;
F
coeffs
[
2
][
3
];
Mat
coeffsMat
(
2
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
double
coeffsM
[
2
*
3
];
Mat
coeffsMat
(
2
,
3
,
CV_64F
,
(
void
*
)
coeffsM
);
M
.
convertTo
(
coeffsMat
,
coeffsMat
.
type
());
if
(
!
warpInd
)
{
convert_coeffs
(
(
F
*
)(
&
coeffs
[
0
][
0
])
);
convert_coeffs
(
coeffsM
);
}
for
(
int
i
=
0
;
i
<
2
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
coeffs
[
i
][
j
]
=
coeffsM
[
i
*
3
+
j
];
warpAffine_gpu
(
src
,
dst
,
coeffs
,
interpolation
);
}
...
...
@@ -1041,13 +1048,19 @@ namespace cv
int
warpInd
=
(
flags
&
WARP_INVERSE_MAP
)
>>
4
;
double
coeffs
[
3
][
3
];
Mat
coeffsMat
(
3
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
double
coeffsM
[
3
*
3
];
Mat
coeffsMat
(
3
,
3
,
CV_64F
,
(
void
*
)
coeffsM
);
M
.
convertTo
(
coeffsMat
,
coeffsMat
.
type
());
if
(
!
warpInd
)
{
invert
(
(
double
*
)(
&
coeffs
[
0
][
0
])
);
invert
(
coeffsM
);
}
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
coeffs
[
i
][
j
]
=
coeffsM
[
i
*
3
+
j
];
warpPerspective_gpu
(
src
,
dst
,
coeffs
,
interpolation
);
}
...
...
@@ -1144,7 +1157,7 @@ namespace cv
}
/////////////////////// corner //////////////////////////////
void
extractCovData
(
const
oclMat
&
src
,
oclMat
&
Dx
,
oclMat
&
Dy
,
static
void
extractCovData
(
const
oclMat
&
src
,
oclMat
&
Dx
,
oclMat
&
Dy
,
int
blockSize
,
int
ksize
,
int
borderType
)
{
CV_Assert
(
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_32FC1
);
...
...
@@ -1174,7 +1187,7 @@ namespace cv
CV_Assert
(
Dx
.
offset
==
0
&&
Dy
.
offset
==
0
);
}
void
corner_ocl
(
const
char
*
src_str
,
string
kernelName
,
int
block_size
,
float
k
,
oclMat
&
Dx
,
oclMat
&
Dy
,
static
void
corner_ocl
(
const
char
*
src_str
,
string
kernelName
,
int
block_size
,
float
k
,
oclMat
&
Dx
,
oclMat
&
Dy
,
oclMat
&
dst
,
int
border_type
)
{
char
borderType
[
30
];
...
...
@@ -1258,7 +1271,7 @@ namespace cv
corner_ocl
(
imgproc_calcMinEigenVal
,
"calcMinEigenVal"
,
blockSize
,
0
,
Dx
,
Dy
,
dst
,
borderType
);
}
/////////////////////////////////// MeanShiftfiltering ///////////////////////////////////////////////
void
meanShiftFiltering_gpu
(
const
oclMat
&
src
,
oclMat
dst
,
int
sp
,
int
sr
,
int
maxIter
,
float
eps
)
static
void
meanShiftFiltering_gpu
(
const
oclMat
&
src
,
oclMat
dst
,
int
sp
,
int
sr
,
int
maxIter
,
float
eps
)
{
CV_Assert
(
(
src
.
cols
==
dst
.
cols
)
&&
(
src
.
rows
==
dst
.
rows
)
);
CV_Assert
(
!
(
dst
.
step
&
0x3
)
);
...
...
@@ -1321,7 +1334,7 @@ namespace cv
}
void
meanShiftProc_gpu
(
const
oclMat
&
src
,
oclMat
dstr
,
oclMat
dstsp
,
int
sp
,
int
sr
,
int
maxIter
,
float
eps
)
static
void
meanShiftProc_gpu
(
const
oclMat
&
src
,
oclMat
dstr
,
oclMat
dstsp
,
int
sp
,
int
sr
,
int
maxIter
,
float
eps
)
{
//sanity checks
CV_Assert
(
(
src
.
cols
==
dstr
.
cols
)
&&
(
src
.
rows
==
dstr
.
rows
)
&&
...
...
@@ -1398,7 +1411,7 @@ namespace cv
const
int
HISTOGRAM256_BIN_COUNT
=
256
;
}
///////////////////////////////calcHist/////////////////////////////////////////////////////////////////
void
calc_sub_hist
(
const
oclMat
&
mat_src
,
const
oclMat
&
mat_sub_hist
)
static
void
calc_sub_hist
(
const
oclMat
&
mat_src
,
const
oclMat
&
mat_sub_hist
)
{
using
namespace
histograms
;
...
...
@@ -1477,7 +1490,7 @@ namespace cv
openCLExecuteKernel
(
clCxt
,
&
imgproc_histogram
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
}
void
merge_sub_hist
(
const
oclMat
&
sub_hist
,
oclMat
&
mat_hist
)
static
void
merge_sub_hist
(
const
oclMat
&
sub_hist
,
oclMat
&
mat_hist
)
{
using
namespace
histograms
;
...
...
@@ -1535,7 +1548,6 @@ namespace cv
{
int
cn
=
src
.
channels
();
int
i
,
j
,
maxk
,
radius
;
Size
size
=
src
.
size
();
CV_Assert
(
(
src
.
channels
()
==
1
||
src
.
channels
()
==
3
)
&&
src
.
type
()
==
dst
.
type
()
&&
src
.
size
()
==
dst
.
size
()
&&
...
...
@@ -1632,7 +1644,7 @@ inline int divUp(int total, int grain)
{
return
(
total
+
grain
-
1
)
/
grain
;
}
void
convolve_run
(
const
oclMat
&
src
,
const
oclMat
&
temp1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
static
void
convolve_run
(
const
oclMat
&
src
,
const
oclMat
&
temp1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
)
{
CV_Assert
(
src
.
depth
()
==
CV_32FC1
);
CV_Assert
(
temp1
.
depth
()
==
CV_32F
);
...
...
modules/ocl/src/initialization.cpp
浏览文件 @
d8f749da
...
...
@@ -237,23 +237,13 @@ namespace cv
int
getDevice
(
std
::
vector
<
Info
>
&
oclinfo
,
int
devicetype
)
{
cl_device_type
_devicetype
;
switch
(
devicetype
)
{
case
CVCL_DEVICE_TYPE_DEFAULT
:
_devicetype
=
CL_DEVICE_TYPE_DEFAULT
;
break
;
case
CVCL_DEVICE_TYPE_CPU
:
_devicetype
=
CL_DEVICE_TYPE_CPU
;
break
;
case
CVCL_DEVICE_TYPE_GPU
:
_devicetype
=
CL_DEVICE_TYPE_GPU
;
break
;
case
CVCL_DEVICE_TYPE_ACCELERATOR
:
_devicetype
=
CL_DEVICE_TYPE_ACCELERATOR
;
break
;
case
CVCL_DEVICE_TYPE_ALL
:
_devicetype
=
CL_DEVICE_TYPE_ALL
;
break
;
default:
CV_Error
(
CV_GpuApiCallError
,
"Unkown device type"
);
...
...
@@ -336,7 +326,7 @@ namespace cv
size_t
extends_size
;
openCLSafeCall
(
clGetDeviceInfo
(
oclinfo
.
impl
->
devices
[
devnum
],
CL_DEVICE_EXTENSIONS
,
EXT_LEN
,
(
void
*
)
extends_set
,
&
extends_size
));
CV_Assert
(
extends_size
<
EXT_LEN
);
CV_Assert
(
extends_size
<
(
size_t
)
EXT_LEN
);
extends_set
[
EXT_LEN
-
1
]
=
0
;
memset
(
oclinfo
.
impl
->
extra_options
,
0
,
512
);
oclinfo
.
impl
->
double_support
=
0
;
...
...
@@ -592,7 +582,7 @@ namespace cv
size_t
binarySize
=
ftell
(
fp
);
fseek
(
fp
,
0
,
SEEK_SET
);
char
*
binary
=
new
char
[
binarySize
];
fread
(
binary
,
binarySize
,
1
,
fp
);
CV_Assert
(
1
==
fread
(
binary
,
binarySize
,
1
,
fp
)
);
fclose
(
fp
);
cl_int
status
=
0
;
program
=
clCreateProgramWithBinary
(
clCxt
->
impl
->
clContext
,
...
...
modules/ocl/src/interpolate_frames.cpp
浏览文件 @
d8f749da
...
...
@@ -282,7 +282,7 @@ void interpolate::bindImgTex(const oclMat &img, cl_mem &texture)
openCLFree
(
texture
);
}
#if CL_VERSION_1_2
#if
def
CL_VERSION_1_2
cl_image_desc
desc
;
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
desc
.
image_width
=
img
.
step
/
img
.
elemSize
();
...
...
modules/ocl/src/match_template.cpp
浏览文件 @
d8f749da
...
...
@@ -99,7 +99,7 @@ namespace cv
// Evaluates optimal template's area threshold. If
// template's area is less than the threshold, we use naive match
// template version, otherwise FFT-based (if available)
int
getTemplateThreshold
(
int
method
,
int
depth
)
static
int
getTemplateThreshold
(
int
method
,
int
depth
)
{
switch
(
method
)
{
...
...
modules/ocl/src/matrix_operations.cpp
浏览文件 @
d8f749da
...
...
@@ -126,7 +126,7 @@ namespace cv
////////////////////////////////////////////////////////////////////////
// convert_C3C4
void
convert_C3C4
(
const
cl_mem
&
src
,
oclMat
&
dst
)
static
void
convert_C3C4
(
const
cl_mem
&
src
,
oclMat
&
dst
)
{
int
dstStep_in_pixel
=
dst
.
step1
()
/
dst
.
oclchannels
();
int
pixel_end
=
dst
.
wholecols
*
dst
.
wholerows
-
1
;
...
...
@@ -174,7 +174,7 @@ void convert_C3C4(const cl_mem &src, oclMat &dst)
}
////////////////////////////////////////////////////////////////////////
// convert_C4C3
void
convert_C4C3
(
const
oclMat
&
src
,
cl_mem
&
dst
)
static
void
convert_C4C3
(
const
oclMat
&
src
,
cl_mem
&
dst
)
{
int
srcStep_in_pixel
=
src
.
step1
()
/
src
.
oclchannels
();
int
pixel_end
=
src
.
wholecols
*
src
.
wholerows
-
1
;
...
...
@@ -336,7 +336,7 @@ inline int divUp(int total, int grain)
///////////////////////////////////////////////////////////////////////////
////////////////////////////////// CopyTo /////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
copy_to_with_mask
(
const
oclMat
&
src
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
)
static
void
copy_to_with_mask
(
const
oclMat
&
src
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
)
{
CV_DbgAssert
(
dst
.
rows
==
mask
.
rows
&&
dst
.
cols
==
mask
.
cols
&&
src
.
rows
==
dst
.
rows
&&
src
.
cols
==
dst
.
cols
...
...
@@ -401,7 +401,7 @@ void cv::ocl::oclMat::copyTo( oclMat &mat, const oclMat &mask) const
///////////////////////////////////////////////////////////////////////////
//////////////////////////////// ConvertTo ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
convert_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
alpha
,
double
beta
)
static
void
convert_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
alpha
,
double
beta
)
{
string
kernelName
=
"convert_to_S"
;
stringstream
idxStr
;
...
...
@@ -472,7 +472,7 @@ oclMat &cv::ocl::oclMat::operator = (const Scalar &s)
setTo
(
s
);
return
*
this
;
}
void
set_to_withoutmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
string
kernelName
)
static
void
set_to_withoutmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
string
kernelName
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
...
@@ -642,7 +642,7 @@ void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, string kern
default:
CV_Error
(
CV_StsUnsupportedFormat
,
"unknown depth"
);
}
#if CL_VERSION_1_2
#if
def
CL_VERSION_1_2
if
(
dst
.
offset
==
0
&&
dst
.
cols
==
dst
.
wholecols
)
{
clEnqueueFillBuffer
(
dst
.
clCxt
->
impl
->
clCmdQueue
,
(
cl_mem
)
dst
.
data
,
args
[
0
].
second
,
args
[
0
].
first
,
0
,
dst
.
step
*
dst
.
rows
,
0
,
NULL
,
NULL
);
...
...
@@ -668,7 +668,7 @@ void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, string kern
#endif
}
void
set_to_withmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
const
oclMat
&
mask
,
string
kernelName
)
static
void
set_to_withmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
const
oclMat
&
mask
,
string
kernelName
)
{
CV_DbgAssert
(
dst
.
rows
==
mask
.
rows
&&
dst
.
cols
==
mask
.
cols
);
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
...
modules/ocl/src/mcwutil.cpp
浏览文件 @
d8f749da
...
...
@@ -62,7 +62,7 @@ namespace cv
}
// provide additional methods for the user to interact with the command queue after a task is fired
void
openCLExecuteKernel_2
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
static
void
openCLExecuteKernel_2
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
char
*
build_options
,
FLUSH_MODE
finish_mode
)
{
...
...
modules/ocl/src/precomp.hpp
浏览文件 @
d8f749da
...
...
@@ -46,7 +46,7 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#if _MSC_VER >= 1200
#if
defined _MSC_VER &&
_MSC_VER >= 1200
#pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 )
#endif
...
...
modules/ocl/src/pyrdown.cpp
浏览文件 @
d8f749da
...
...
@@ -66,7 +66,7 @@ namespace cv
//////////////////////////////////////////////////////////////////////////////
/////////////////////// add subtract multiply divide /////////////////////////
//////////////////////////////////////////////////////////////////////////////
void
pyrdown_run
(
const
oclMat
&
src
,
const
oclMat
&
dst
)
static
void
pyrdown_run
(
const
oclMat
&
src
,
const
oclMat
&
dst
)
{
CV_Assert
(
src
.
type
()
==
dst
.
type
());
...
...
modules/ocl/src/pyrlk.cpp
浏览文件 @
d8f749da
...
...
@@ -115,7 +115,7 @@ inline int divUp(int total, int grain)
///////////////////////////////////////////////////////////////////////////
//////////////////////////////// ConvertTo ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
convert_run_cus
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
alpha
,
double
beta
)
static
void
convert_run_cus
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
alpha
,
double
beta
)
{
string
kernelName
=
"convert_to_S"
;
stringstream
idxStr
;
...
...
@@ -186,7 +186,7 @@ void convertTo( const oclMat &src, oclMat &dst, int rtype, double alpha, double
// setTo(s);
// return *this;
//}
void
set_to_withoutmask_run_cus
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
string
kernelName
)
static
void
set_to_withoutmask_run_cus
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
string
kernelName
)
{
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
...
...
@@ -356,7 +356,7 @@ void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, string
default:
CV_Error
(
CV_StsUnsupportedFormat
,
"unknown depth"
);
}
#if CL_VERSION_1_2
#if
def
CL_VERSION_1_2
if
(
dst
.
offset
==
0
&&
dst
.
cols
==
dst
.
wholecols
)
{
clEnqueueFillBuffer
(
dst
.
clCxt
->
impl
->
clCmdQueue
,
(
cl_mem
)
dst
.
data
,
args
[
0
].
second
,
args
[
0
].
first
,
0
,
dst
.
step
*
dst
.
rows
,
0
,
NULL
,
NULL
);
...
...
@@ -382,7 +382,7 @@ void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, string
#endif
}
oclMat
&
setTo
(
oclMat
&
src
,
const
Scalar
&
scalar
)
static
oclMat
&
setTo
(
oclMat
&
src
,
const
Scalar
&
scalar
)
{
CV_Assert
(
src
.
depth
()
>=
0
&&
src
.
depth
()
<=
6
);
CV_DbgAssert
(
!
src
.
empty
());
...
...
@@ -402,48 +402,48 @@ oclMat &setTo(oclMat &src, const Scalar &scalar)
///////////////////////////////////////////////////////////////////////////
////////////////////////////////// CopyTo /////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
copy_to_with_mask_cus
(
const
oclMat
&
src
,
oclMat
&
dst
,
const
oclMat
&
mask
,
string
kernelName
)
{
CV_DbgAssert
(
dst
.
rows
==
mask
.
rows
&&
dst
.
cols
==
mask
.
cols
&&
src
.
rows
==
dst
.
rows
&&
src
.
cols
==
dst
.
cols
&&
mask
.
type
()
==
CV_8UC1
);
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
std
::
string
string_types
[
4
][
7
]
=
{{
"uchar"
,
"char"
,
"ushort"
,
"short"
,
"int"
,
"float"
,
"double"
},
{
"uchar2"
,
"char2"
,
"ushort2"
,
"short2"
,
"int2"
,
"float2"
,
"double2"
},
{
"uchar3"
,
"char3"
,
"ushort3"
,
"short3"
,
"int3"
,
"float3"
,
"double3"
},
{
"uchar4"
,
"char4"
,
"ushort4"
,
"short4"
,
"int4"
,
"float4"
,
"double4"
}
};
char
compile_option
[
32
];
sprintf
(
compile_option
,
"-D GENTYPE=%s"
,
string_types
[
dst
.
oclchannels
()
-
1
][
dst
.
depth
()].
c_str
());
size_t
localThreads
[
3
]
=
{
16
,
16
,
1
};
size_t
globalThreads
[
3
];
globalThreads
[
0
]
=
divUp
(
dst
.
cols
,
localThreads
[
0
])
*
localThreads
[
0
];
globalThreads
[
1
]
=
divUp
(
dst
.
rows
,
localThreads
[
1
])
*
localThreads
[
1
];
globalThreads
[
2
]
=
1
;
int
dststep_in_pixel
=
dst
.
step
/
dst
.
elemSize
(),
dstoffset_in_pixel
=
dst
.
offset
/
dst
.
elemSize
();
int
srcstep_in_pixel
=
src
.
step
/
src
.
elemSize
(),
srcoffset_in_pixel
=
src
.
offset
/
src
.
elemSize
();
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
mask
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
srcstep_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
srcoffset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dststep_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dstoffset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
mask
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
mask
.
offset
));
openCLExecuteKernel2
(
dst
.
clCxt
,
&
operator_copyToM
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
compile_option
,
CLFLUSH
);
}
void
copyTo
(
const
oclMat
&
src
,
oclMat
&
m
)
// static
void copy_to_with_mask_cus(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName)
//
{
//
CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols &&
//
src.rows == dst.rows && src.cols == dst.cols
//
&& mask.type() == CV_8UC1);
//
vector<pair<size_t , const void *> > args;
//
std::string string_types[4][7] = {{"uchar", "char", "ushort", "short", "int", "float", "double"},
//
{"uchar2", "char2", "ushort2", "short2", "int2", "float2", "double2"},
//
{"uchar3", "char3", "ushort3", "short3", "int3", "float3", "double3"},
//
{"uchar4", "char4", "ushort4", "short4", "int4", "float4", "double4"}
//
};
//
char compile_option[32];
//
sprintf(compile_option, "-D GENTYPE=%s", string_types[dst.oclchannels() - 1][dst.depth()].c_str());
//
size_t localThreads[3] = {16, 16, 1};
//
size_t globalThreads[3];
//
globalThreads[0] = divUp(dst.cols, localThreads[0]) * localThreads[0];
//
globalThreads[1] = divUp(dst.rows, localThreads[1]) * localThreads[1];
//
globalThreads[2] = 1;
//
int dststep_in_pixel = dst.step / dst.elemSize(), dstoffset_in_pixel = dst.offset / dst.elemSize();
//
int srcstep_in_pixel = src.step / src.elemSize(), srcoffset_in_pixel = src.offset / src.elemSize();
//
args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data ));
//
args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data ));
//
args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step ));
//
args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset ));
//
openCLExecuteKernel2(dst.clCxt , &operator_copyToM, kernelName, globalThreads,
//
localThreads, args, -1, -1, compile_option, CLFLUSH);
//
}
static
void
copyTo
(
const
oclMat
&
src
,
oclMat
&
m
)
{
CV_DbgAssert
(
!
src
.
empty
());
m
.
create
(
src
.
size
(),
src
.
type
());
...
...
@@ -451,20 +451,20 @@ void copyTo(const oclMat &src, oclMat &m )
src
.
data
,
src
.
step
,
src
.
cols
*
src
.
elemSize
(),
src
.
rows
,
src
.
offset
);
}
void
copyTo
(
const
oclMat
&
src
,
oclMat
&
mat
,
const
oclMat
&
mask
)
{
if
(
mask
.
empty
())
{
copyTo
(
src
,
mat
);
}
else
{
mat
.
create
(
src
.
size
(),
src
.
type
());
copy_to_with_mask_cus
(
src
,
mat
,
mask
,
"copy_to_with_mask"
);
}
}
void
arithmetic_run
(
const
oclMat
&
src1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
,
void
*
_scalar
)
// static
void copyTo(const oclMat &src, oclMat &mat, const oclMat &mask)
//
{
//
if (mask.empty())
//
{
//
copyTo(src, mat);
//
}
//
else
//
{
//
mat.create(src.size(), src.type());
//
copy_to_with_mask_cus(src, mat, mask, "copy_to_with_mask");
//
}
//
}
static
void
arithmetic_run
(
const
oclMat
&
src1
,
oclMat
&
dst
,
string
kernelName
,
const
char
**
kernelString
,
void
*
_scalar
)
{
if
(
src1
.
clCxt
->
impl
->
double_support
==
0
&&
src1
.
type
()
==
CV_64F
)
{
...
...
@@ -529,12 +529,12 @@ void arithmetic_run(const oclMat &src1, oclMat &dst, string kernelName, const ch
openCLExecuteKernel2
(
clCxt
,
kernelString
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
src1
.
depth
(),
CLFLUSH
);
}
void
multiply_cus
(
const
oclMat
&
src1
,
oclMat
&
dst
,
float
scalar
)
static
void
multiply_cus
(
const
oclMat
&
src1
,
oclMat
&
dst
,
float
scalar
)
{
arithmetic_run
(
src1
,
dst
,
"arithm_muls"
,
&
arithm_mul
,
(
void
*
)(
&
scalar
));
}
void
pyrdown_run_cus
(
const
oclMat
&
src
,
const
oclMat
&
dst
)
static
void
pyrdown_run_cus
(
const
oclMat
&
src
,
const
oclMat
&
dst
)
{
CV_Assert
(
src
.
type
()
==
dst
.
type
());
...
...
@@ -559,7 +559,7 @@ void pyrdown_run_cus(const oclMat &src, const oclMat &dst)
openCLExecuteKernel2
(
clCxt
,
&
pyr_down
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
src
.
depth
(),
CLFLUSH
);
}
void
pyrDown_cus
(
const
oclMat
&
src
,
oclMat
&
dst
)
static
void
pyrDown_cus
(
const
oclMat
&
src
,
oclMat
&
dst
)
{
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
...
...
@@ -673,7 +673,7 @@ void pyrDown_cus(const oclMat &src, oclMat &dst)
// //}
//}
cl_mem
bindTexture
(
const
oclMat
&
mat
,
int
depth
,
int
channels
)
static
cl_mem
bindTexture
(
const
oclMat
&
mat
,
int
depth
,
int
channels
)
{
cl_mem
texture
;
cl_image_format
format
;
...
...
@@ -698,7 +698,7 @@ cl_mem bindTexture(const oclMat &mat, int depth, int channels)
{
format
.
image_channel_order
=
CL_RGBA
;
}
#if CL_VERSION_1_2
#if
def
CL_VERSION_1_2
cl_image_desc
desc
;
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
desc
.
image_width
=
mat
.
step
/
mat
.
elemSize
();
...
...
@@ -730,12 +730,12 @@ cl_mem bindTexture(const oclMat &mat, int depth, int channels)
return
texture
;
}
void
releaseTexture
(
cl_mem
texture
)
static
void
releaseTexture
(
cl_mem
texture
)
{
openCLFree
(
texture
);
}
void
lkSparse_run
(
oclMat
&
I
,
oclMat
&
J
,
static
void
lkSparse_run
(
oclMat
&
I
,
oclMat
&
J
,
const
oclMat
&
prevPts
,
oclMat
&
nextPts
,
oclMat
&
status
,
oclMat
&
err
,
bool
/*GET_MIN_EIGENVALS*/
,
int
ptcount
,
int
level
,
/*dim3 block, */
dim3
patch
,
Size
winSize
,
int
iters
)
{
...
...
@@ -915,7 +915,7 @@ void cv::ocl::PyrLKOpticalFlow::sparse(const oclMat &prevImg, const oclMat &next
delete
err
;
}
void
lkDense_run
(
oclMat
&
I
,
oclMat
&
J
,
oclMat
&
u
,
oclMat
&
v
,
static
void
lkDense_run
(
oclMat
&
I
,
oclMat
&
J
,
oclMat
&
u
,
oclMat
&
v
,
oclMat
&
prevU
,
oclMat
&
prevV
,
oclMat
*
err
,
Size
winSize
,
int
iters
)
{
Context
*
clCxt
=
I
.
clCxt
;
...
...
modules/ocl/src/split_merge.cpp
浏览文件 @
d8f749da
...
...
@@ -111,52 +111,52 @@ namespace cv
////////////////////////////////////////////////////////////////////////////
////////////////////merge//////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
void
merge_vector_run_no_roi
(
const
oclMat
*
mat_src
,
size_t
n
,
oclMat
&
mat_dst
)
{
Context
*
clCxt
=
mat_dst
.
clCxt
;
int
channels
=
mat_dst
.
oclchannels
();
int
depth
=
mat_dst
.
depth
();
string
kernelName
=
"merge_vector"
;
int
indexes
[
4
][
7
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
4
,
4
,
2
,
2
,
1
,
1
,
1
},
{
4
,
4
,
2
,
2
,
1
,
1
,
1
},
{
4
,
4
,
2
,
2
,
1
,
1
,
1
}
};
size_t
index
=
indexes
[
channels
-
1
][
mat_dst
.
depth
()];
int
cols
=
divUp
(
mat_dst
.
cols
,
index
);
size_t
localThreads
[
3
]
=
{
64
,
4
,
1
};
size_t
globalThreads
[
3
]
=
{
divUp
(
cols
,
localThreads
[
0
])
*
localThreads
[
0
],
divUp
(
mat_dst
.
rows
,
localThreads
[
1
])
*
localThreads
[
1
],
1
};
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_src
[
0
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
[
0
].
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_src
[
1
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
[
1
].
step
));
if
(
n
>=
3
)
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_src
[
2
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
[
2
].
step
));
}
if
(
n
>=
4
)
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_src
[
3
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
[
3
].
step
));
}
openCLExecuteKernel
(
clCxt
,
&
merge_mat
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
);
}
void
merge_vector_run
(
const
oclMat
*
mat_src
,
size_t
n
,
oclMat
&
mat_dst
)
// static
void merge_vector_run_no_roi(const oclMat *mat_src, size_t n, oclMat &mat_dst)
//
{
//
Context *clCxt = mat_dst.clCxt;
//
int channels = mat_dst.oclchannels();
//
int depth = mat_dst.depth();
//
string kernelName = "merge_vector";
//
int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
//
{4, 4, 2, 2, 1, 1, 1},
//
{4, 4, 2, 2 , 1, 1, 1},
//
{4, 4, 2, 2, 1, 1, 1}
//
};
//
size_t index = indexes[channels - 1][mat_dst.depth()];
//
int cols = divUp(mat_dst.cols, index);
//
size_t localThreads[3] = { 64, 4, 1 };
//
size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
//
divUp(mat_dst.rows, localThreads[1]) *localThreads[1],
//
1
//
};
//
vector<pair<size_t , const void *> > args;
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step));
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step));
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step));
//
if(n >= 3)
//
{
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step));
//
}
//
if(n >= 4)
//
{
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step));
//
}
//
openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth);
//
}
static
void
merge_vector_run
(
const
oclMat
*
mat_src
,
size_t
n
,
oclMat
&
mat_dst
)
{
if
(
mat_dst
.
clCxt
->
impl
->
double_support
==
0
&&
mat_dst
.
type
()
==
CV_64F
)
{
...
...
@@ -228,7 +228,7 @@ namespace cv
openCLExecuteKernel
(
clCxt
,
&
merge_mat
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
);
}
void
merge
(
const
oclMat
*
mat_src
,
size_t
n
,
oclMat
&
mat_dst
)
static
void
merge
(
const
oclMat
*
mat_src
,
size_t
n
,
oclMat
&
mat_dst
)
{
CV_Assert
(
mat_src
);
CV_Assert
(
n
>
0
);
...
...
@@ -260,51 +260,51 @@ namespace cv
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////split/////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
void
split_vector_run_no_roi
(
const
oclMat
&
mat_src
,
oclMat
*
mat_dst
)
{
Context
*
clCxt
=
mat_src
.
clCxt
;
int
channels
=
mat_src
.
oclchannels
();
int
depth
=
mat_src
.
depth
();
string
kernelName
=
"split_vector"
;
int
indexes
[
4
][
7
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
8
,
8
,
8
,
8
,
4
,
4
,
2
},
{
8
,
8
,
8
,
8
,
4
,
4
,
4
},
{
4
,
4
,
2
,
2
,
1
,
1
,
1
}
};
size_t
index
=
indexes
[
channels
-
1
][
mat_dst
[
0
].
depth
()];
int
cols
=
divUp
(
mat_src
.
cols
,
index
);
size_t
localThreads
[
3
]
=
{
64
,
4
,
1
};
size_t
globalThreads
[
3
]
=
{
divUp
(
cols
,
localThreads
[
0
])
*
localThreads
[
0
],
divUp
(
mat_src
.
rows
,
localThreads
[
1
])
*
localThreads
[
1
],
1
};
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_src
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_dst
[
0
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
[
0
].
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_dst
[
1
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
[
1
].
step
));
if
(
channels
>=
3
)
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_dst
[
2
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
[
2
].
step
));
}
if
(
channels
>=
4
)
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_dst
[
3
].
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
mat_dst
[
3
].
step
));
}
openCLExecuteKernel
(
clCxt
,
&
split_mat
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
);
}
void
split_vector_run
(
const
oclMat
&
mat_src
,
oclMat
*
mat_dst
)
// static
void split_vector_run_no_roi(const oclMat &mat_src, oclMat *mat_dst)
//
{
//
Context *clCxt = mat_src.clCxt;
//
int channels = mat_src.oclchannels();
//
int depth = mat_src.depth();
//
string kernelName = "split_vector";
//
int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
//
{8, 8, 8, 8, 4, 4, 2},
//
{8, 8, 8, 8 , 4, 4, 4},
//
{4, 4, 2, 2, 1, 1, 1}
//
};
//
size_t index = indexes[channels - 1][mat_dst[0].depth()];
//
int cols = divUp(mat_src.cols, index);
//
size_t localThreads[3] = { 64, 4, 1 };
//
size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
//
divUp(mat_src.rows, localThreads[1]) *localThreads[1],
//
1
//
};
//
vector<pair<size_t , const void *> > args;
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].step));
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].step));
//
if(channels >= 3)
//
{
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].step));
//
}
//
if(channels >= 4)
//
{
//
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data));
//
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].step));
//
}
//
openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth);
//
}
static
void
split_vector_run
(
const
oclMat
&
mat_src
,
oclMat
*
mat_dst
)
{
if
(
mat_src
.
clCxt
->
impl
->
double_support
==
0
&&
mat_src
.
type
()
==
CV_64F
)
...
...
@@ -374,7 +374,7 @@ namespace cv
openCLExecuteKernel
(
clCxt
,
&
split_mat
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
);
}
void
split
(
const
oclMat
&
mat_src
,
oclMat
*
mat_dst
)
static
void
split
(
const
oclMat
&
mat_src
,
oclMat
*
mat_dst
)
{
CV_Assert
(
mat_dst
);
...
...
modules/ocl/src/surf.cpp
浏览文件 @
d8f749da
...
...
@@ -536,7 +536,7 @@ void SURF_OCL_Invoker::bindImgTex(const oclMat &img, cl_mem &texture)
openCLFree
(
texture
);
}
#if CL_VERSION_1_2
#if
def
CL_VERSION_1_2
cl_image_desc
desc
;
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
desc
.
image_width
=
img
.
step
/
img
.
elemSize
();
...
...
modules/ocl/test/precomp.hpp
浏览文件 @
d8f749da
...
...
@@ -38,6 +38,15 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
...
...
modules/ocl/test/test_arithm.cpp
浏览文件 @
d8f749da
...
...
@@ -1449,8 +1449,8 @@ TEST_P(MagnitudeSqr, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
// random_roi();
int64
start
,
end
;
start
=
cv
::
getTickCount
();
//
int64 start, end;
//
start = cv::getTickCount();
for
(
int
i
=
0
;
i
<
mat1
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat1
.
cols
;
++
j
)
{
...
...
@@ -1465,7 +1465,7 @@ TEST_P(MagnitudeSqr, Mat)
// ((float *)(dst.data))[i*dst.step/4 +j]= val1 * val1 +val2 * val2;
}
end
=
cv
::
getTickCount
();
//
end = cv::getTickCount();
...
...
modules/ocl/test/test_blend.cpp
浏览文件 @
d8f749da
...
...
@@ -74,7 +74,7 @@ TEST_P(Blend, Accuracy)
else
blendLinearGold
<
float
>
(
img1
,
img2
,
weights1
,
weights2
,
result_gold
);
EXPECT_MAT_NEAR
(
result_gold
,
result
,
CV_MAT_DEPTH
(
type
)
==
CV_8U
?
1
:
1e-5
f
,
NULL
)
EXPECT_MAT_NEAR
(
result_gold
,
result
,
CV_MAT_DEPTH
(
type
)
==
CV_8U
?
1
.
f
:
1e-5
f
,
0
);
}
INSTANTIATE_TEST_CASE_P
(
GPU_ImgProc
,
Blend
,
Combine
(
...
...
modules/ocl/test/test_color.cpp
浏览文件 @
d8f749da
...
...
@@ -181,13 +181,13 @@ INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor, testing::Combine(
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
CvtColor_YUV420
,
testing
::
Combine
(
testing
::
Values
(
cv
::
Size
(
128
,
45
),
cv
::
Size
(
46
,
132
),
cv
::
Size
(
1024
,
1023
)),
testing
::
Values
(
CV_YUV2RGBA_NV12
,
CV_YUV2BGRA_NV12
,
CV_YUV2RGB_NV12
,
CV_YUV2BGR_NV12
)
testing
::
Values
(
(
int
)
CV_YUV2RGBA_NV12
,
(
int
)
CV_YUV2BGRA_NV12
,
(
int
)
CV_YUV2RGB_NV12
,
(
int
)
CV_YUV2BGR_NV12
)
));
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
CvtColor_Gray2RGB
,
testing
::
Combine
(
DIFFERENT_SIZES
,
testing
::
Values
(
MatDepth
(
CV_8U
),
MatDepth
(
CV_16U
),
MatDepth
(
CV_32F
)),
testing
::
Values
(
CV_GRAY2BGR
,
CV_GRAY2BGRA
,
CV_GRAY2RGB
,
CV_GRAY2RGBA
)
testing
::
Values
(
(
int
)
CV_GRAY2BGR
,
(
int
)
CV_GRAY2BGRA
,
(
int
)
CV_GRAY2RGB
,
(
int
)
CV_GRAY2RGBA
)
));
}
#endif
modules/ocl/test/test_haar.cpp
浏览文件 @
d8f749da
...
...
@@ -109,15 +109,15 @@ TEST_F(Haar, FaceDetect)
//double t = 0;
vector
<
Rect
>
faces
,
oclfaces
;
const
static
Scalar
colors
[]
=
{
CV_RGB
(
0
,
0
,
255
),
CV_RGB
(
0
,
128
,
255
),
CV_RGB
(
0
,
255
,
255
),
CV_RGB
(
0
,
255
,
0
),
CV_RGB
(
255
,
128
,
0
),
CV_RGB
(
255
,
255
,
0
),
CV_RGB
(
255
,
0
,
0
),
CV_RGB
(
255
,
0
,
255
)
}
;
//
const static Scalar colors[] = { CV_RGB(0, 0, 255),
//
CV_RGB(0, 128, 255),
//
CV_RGB(0, 255, 255),
//
CV_RGB(0, 255, 0),
//
CV_RGB(255, 128, 0),
//
CV_RGB(255, 255, 0),
//
CV_RGB(255, 0, 0),
//
CV_RGB(255, 0, 255)
//
} ;
Mat
gray
,
smallImg
(
cvRound
(
img
.
rows
/
scale
),
cvRound
(
img
.
cols
/
scale
),
CV_8UC1
);
MemStorage
storage
(
cvCreateMemStorage
(
0
));
...
...
modules/ocl/test/test_imgproc.cpp
浏览文件 @
d8f749da
...
...
@@ -498,11 +498,11 @@ TEST_P(bilateralFilter, Mat)
}
else
{
for
(
in
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
size_
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
if
(((
bordertype
[
i
]
!=
cv
::
BORDER_CONSTANT
)
&&
(
bordertype
[
i
]
!=
cv
::
BORDER_REPLICATE
)
)
&&
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
))
if
(((
bordertype
[
i
]
!=
cv
::
BORDER_CONSTANT
)
&&
(
bordertype
[
i
]
!=
cv
::
BORDER_REPLICATE
)
&&
(
mat1_roi
.
cols
<=
radius
)
)
||
(
mat1_roi
.
cols
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
)
||
(
mat1_roi
.
rows
<=
radius
))
{
continue
;
}
...
...
@@ -563,7 +563,7 @@ TEST_P(CopyMakeBorder, Mat)
}
else
{
for
(
in
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
size_
t
i
=
0
;
i
<
sizeof
(
bordertype
)
/
sizeof
(
int
);
i
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
...
...
@@ -911,7 +911,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
srcSize
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
cv
::
Size
dstSize
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
cv
::
Size
map1Size
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
double
min
=
5
,
max
=
16
;
...
...
modules/ocl/test/test_match_template.cpp
浏览文件 @
d8f749da
...
...
@@ -100,7 +100,7 @@ TEST_P(MatchTemplate8U, Accuracy)
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
,
sss
);
#if PERF_TEST
#if
def
PERF_TEST
{
P_TEST_FULL
(
{},
{
cv
::
ocl
::
matchTemplate
(
ocl_image
,
ocl_templ
,
dst
,
method
);},
{});
P_TEST_FULL
(
{},
{
cv
::
matchTemplate
(
image
,
templ
,
dst_gold
,
method
);},
{});
...
...
@@ -145,7 +145,7 @@ TEST_P(MatchTemplate32F, Accuracy)
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
,
sss
);
#if PERF_TEST
#if
def
PERF_TEST
{
std
::
cout
<<
"Method: "
<<
TEMPLATE_METHOD_NAMES
[
method
]
<<
std
::
endl
;
std
::
cout
<<
"Image Size: ("
<<
size
.
width
<<
", "
<<
size
.
height
<<
")"
<<
std
::
endl
;
...
...
modules/ocl/test/utility.hpp
浏览文件 @
d8f749da
...
...
@@ -76,12 +76,12 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
}
/
/
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
//
{ \
//
ASSERT_EQ(mat1.type(), mat2.type()); \
//
ASSERT_EQ(mat1.size(), mat2.size()); \
//
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
//}
/
*
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}*/
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
{ \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录