Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
dcce9d70
O
Opencv
项目概览
Greenplum
/
Opencv
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
dcce9d70
编写于
12月 01, 2013
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added cv::warpAffine to T-API
上级
55af7857
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
189 addition
and
685 deletion
+189
-685
modules/core/src/ocl.cpp
modules/core/src/ocl.cpp
+1
-2
modules/imgproc/src/imgwarp.cpp
modules/imgproc/src/imgwarp.cpp
+89
-57
modules/imgproc/src/opencl/warp_affine.cl
modules/imgproc/src/opencl/warp_affine.cl
+99
-626
未找到文件。
modules/core/src/ocl.cpp
浏览文件 @
dcce9d70
...
...
@@ -2041,7 +2041,6 @@ struct Kernel::Impl
cl_int
retval
=
0
;
handle
=
ph
!=
0
?
clCreateKernel
(
ph
,
kname
,
&
retval
)
:
0
;
printf
(
"kernel creation error code: %d
\n
"
,
retval
);
for
(
int
i
=
0
;
i
<
MAX_ARRS
;
i
++
)
u
[
i
]
=
0
;
haveTempDstUMats
=
false
;
...
...
@@ -2219,7 +2218,7 @@ int Kernel::set(int i, const KernelArg& arg)
else
if
(
arg
.
m
->
dims
<=
2
)
{
UMat2D
u2d
(
*
arg
.
m
);
clSetKernelArg
(
p
->
handle
,
(
cl_uint
)
i
,
sizeof
(
h
),
&
h
)
)
;
clSetKernelArg
(
p
->
handle
,
(
cl_uint
)
i
,
sizeof
(
h
),
&
h
);
clSetKernelArg
(
p
->
handle
,
(
cl_uint
)(
i
+
1
),
sizeof
(
u2d
.
step
),
&
u2d
.
step
);
clSetKernelArg
(
p
->
handle
,
(
cl_uint
)(
i
+
2
),
sizeof
(
u2d
.
offset
),
&
u2d
.
offset
);
i
+=
3
;
...
...
modules/imgproc/src/imgwarp.cpp
浏览文件 @
dcce9d70
...
...
@@ -3789,6 +3789,87 @@ private:
};
#endif
enum
{
OCL_OP_PERSPECTIVE
=
1
,
OCL_OP_AFFINE
=
0
};
static
bool
ocl_warpTransform
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_M0
,
Size
dsize
,
int
flags
,
int
borderType
,
const
Scalar
&
borderValue
,
int
op_type
)
{
CV_Assert
(
op_type
==
OCL_OP_AFFINE
||
op_type
==
OCL_OP_PERSPECTIVE
);
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
),
wdepth
=
depth
;
double
doubleSupport
=
ocl
::
Device
::
getDefault
().
doubleFPConfig
()
>
0
;
int
interpolation
=
flags
&
INTER_MAX
;
if
(
interpolation
==
INTER_AREA
)
interpolation
=
INTER_LINEAR
;
if
(
!
(
borderType
==
cv
::
BORDER_CONSTANT
&&
(
interpolation
==
cv
::
INTER_NEAREST
||
interpolation
==
cv
::
INTER_LINEAR
||
interpolation
==
cv
::
INTER_CUBIC
))
||
(
!
doubleSupport
&&
depth
==
CV_64F
)
||
cn
>
4
||
cn
==
3
)
return
false
;
UMat
src
=
_src
.
getUMat
(),
M0
;
_dst
.
create
(
dsize
.
area
()
==
0
?
src
.
size
()
:
dsize
,
src
.
type
()
);
UMat
dst
=
_dst
.
getUMat
();
double
M
[
9
];
int
matRows
=
(
op_type
==
OCL_OP_AFFINE
?
2
:
3
);
Mat
matM
(
matRows
,
3
,
CV_64F
,
M
),
M1
=
_M0
.
getMat
();
CV_Assert
(
(
M1
.
type
()
==
CV_32F
||
M1
.
type
()
==
CV_64F
)
&&
M1
.
rows
==
matRows
&&
M1
.
cols
==
3
);
M1
.
convertTo
(
matM
,
matM
.
type
());
if
(
!
(
flags
&
WARP_INVERSE_MAP
)
)
{
if
(
op_type
==
OCL_OP_PERSPECTIVE
)
invert
(
matM
,
matM
);
else
{
double
D
=
M
[
0
]
*
M
[
4
]
-
M
[
1
]
*
M
[
3
];
D
=
D
!=
0
?
1.
/
D
:
0
;
double
A11
=
M
[
4
]
*
D
,
A22
=
M
[
0
]
*
D
;
M
[
0
]
=
A11
;
M
[
1
]
*=
-
D
;
M
[
3
]
*=
-
D
;
M
[
4
]
=
A22
;
double
b1
=
-
M
[
0
]
*
M
[
2
]
-
M
[
1
]
*
M
[
5
];
double
b2
=
-
M
[
3
]
*
M
[
2
]
-
M
[
4
]
*
M
[
5
];
M
[
2
]
=
b1
;
M
[
5
]
=
b2
;
}
}
matM
.
convertTo
(
M0
,
doubleSupport
?
CV_64F
:
CV_32F
);
const
char
*
const
interpolationMap
[
3
]
=
{
"NEAREST"
,
"LINEAR"
,
"CUBIC"
};
ocl
::
ProgramSource2
program
=
op_type
==
OCL_OP_AFFINE
?
ocl
::
imgproc
::
warp_affine_oclsrc
:
ocl
::
imgproc
::
warp_perspective_oclsrc
;
const
char
*
const
kernelName
=
op_type
==
OCL_OP_AFFINE
?
"warpAffine"
:
"warpPerspective"
;
ocl
::
Kernel
k
;
if
(
interpolation
==
INTER_NEAREST
)
{
k
.
create
(
kernelName
,
program
,
format
(
"-D INTER_NEAREST -D T=%s%s"
,
ocl
::
typeToStr
(
type
),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
}
else
{
char
cvt
[
2
][
50
];
wdepth
=
std
::
max
(
CV_32S
,
depth
);
k
.
create
(
kernelName
,
program
,
format
(
"-D INTER_%s -D T=%s -D WT=%s -D depth=%d -D convertToWT=%s -D convertToT=%s%s"
,
interpolationMap
[
interpolation
],
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
wdepth
,
cn
)),
depth
,
ocl
::
convertTypeStr
(
depth
,
wdepth
,
cn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
wdepth
,
depth
,
cn
,
cvt
[
1
]),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
}
k
.
args
(
ocl
::
KernelArg
::
ReadOnly
(
src
),
ocl
::
KernelArg
::
WriteOnly
(
dst
),
ocl
::
KernelArg
::
PtrOnly
(
M0
),
ocl
::
KernelArg
::
Constant
(
Mat
(
1
,
1
,
CV_MAKE_TYPE
(
wdepth
,
cn
),
borderValue
)));
size_t
globalThreads
[
2
]
=
{
dst
.
cols
,
dst
.
rows
};
return
k
.
run
(
2
,
globalThreads
,
NULL
,
false
);
}
}
...
...
@@ -3796,6 +3877,11 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
InputArray
_M0
,
Size
dsize
,
int
flags
,
int
borderType
,
const
Scalar
&
borderValue
)
{
if
(
ocl
::
useOpenCL
()
&&
_dst
.
isUMat
()
&&
ocl_warpTransform
(
_src
,
_dst
,
_M0
,
dsize
,
flags
,
borderType
,
borderValue
,
OCL_OP_AFFINE
))
return
;
Mat
src
=
_src
.
getMat
(),
M0
=
_M0
.
getMat
();
_dst
.
create
(
dsize
.
area
()
==
0
?
src
.
size
()
:
dsize
,
src
.
type
()
);
Mat
dst
=
_dst
.
getMat
();
...
...
@@ -4030,62 +4116,6 @@ private:
};
#endif
static
bool
ocl_warpPerspective
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_M0
,
Size
dsize
,
int
flags
,
int
borderType
,
const
Scalar
&
borderValue
)
{
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
),
wdepth
=
depth
;
double
doubleSupport
=
ocl
::
Device
::
getDefault
().
doubleFPConfig
()
>
0
;
int
interpolation
=
flags
&
INTER_MAX
;
if
(
interpolation
==
INTER_AREA
)
interpolation
=
INTER_LINEAR
;
if
(
!
(
borderType
==
cv
::
BORDER_CONSTANT
&&
(
interpolation
==
cv
::
INTER_NEAREST
||
interpolation
==
cv
::
INTER_LINEAR
||
interpolation
==
cv
::
INTER_CUBIC
))
||
(
!
doubleSupport
&&
depth
==
CV_64F
)
||
cn
>
4
||
cn
==
3
)
return
false
;
UMat
src
=
_src
.
getUMat
(),
M0
;
_dst
.
create
(
dsize
.
area
()
==
0
?
src
.
size
()
:
dsize
,
src
.
type
()
);
UMat
dst
=
_dst
.
getUMat
();
double
M
[
9
];
Mat
matM
(
3
,
3
,
doubleSupport
?
CV_64F
:
CV_32F
,
M
),
M1
=
_M0
.
getMat
();
CV_Assert
(
(
M1
.
type
()
==
CV_32F
||
M1
.
type
()
==
CV_64F
)
&&
M1
.
rows
==
3
&&
M1
.
cols
==
3
);
M1
.
convertTo
(
matM
,
matM
.
type
());
if
(
!
(
flags
&
WARP_INVERSE_MAP
)
)
invert
(
matM
,
matM
);
matM
.
copyTo
(
M0
);
const
char
*
const
interpolationMap
[
3
]
=
{
"NEAREST"
,
"LINEAR"
,
"CUBIC"
};
ocl
::
Kernel
k
;
if
(
interpolation
==
INTER_NEAREST
)
{
k
.
create
(
"warpPerspective"
,
ocl
::
imgproc
::
warp_perspective_oclsrc
,
format
(
"-D INTER_NEAREST -D T=%s%s"
,
ocl
::
typeToStr
(
type
),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
}
else
{
char
cvt
[
2
][
50
];
wdepth
=
std
::
max
(
CV_32S
,
depth
);
k
.
create
(
"warpPerspective"
,
ocl
::
imgproc
::
warp_perspective_oclsrc
,
format
(
"-D INTER_%s -D T=%s -D WT=%s -D depth=%d -D convertToWT=%s -D convertToT=%s%s"
,
interpolationMap
[
interpolation
],
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
CV_MAKE_TYPE
(
wdepth
,
cn
)),
depth
,
ocl
::
convertTypeStr
(
depth
,
wdepth
,
cn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
wdepth
,
depth
,
cn
,
cvt
[
1
]),
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
}
k
.
args
(
ocl
::
KernelArg
::
ReadOnly
(
src
),
ocl
::
KernelArg
::
WriteOnly
(
dst
),
ocl
::
KernelArg
::
PtrOnly
(
M0
),
ocl
::
KernelArg
::
Constant
(
Mat
(
1
,
1
,
CV_MAKE_TYPE
(
wdepth
,
cn
),
borderValue
)));
size_t
globalThreads
[
2
]
=
{
dst
.
cols
,
dst
.
rows
};
return
k
.
run
(
2
,
globalThreads
,
NULL
,
false
);
}
}
void
cv
::
warpPerspective
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_M0
,
...
...
@@ -4093,7 +4123,9 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
{
CV_Assert
(
_src
.
total
()
>
0
);
if
(
ocl
::
useOpenCL
()
&&
_dst
.
isUMat
()
&&
ocl_warpPerspective
(
_src
,
_dst
,
_M0
,
dsize
,
flags
,
borderType
,
borderValue
))
if
(
ocl
::
useOpenCL
()
&&
_dst
.
isUMat
()
&&
ocl_warpTransform
(
_src
,
_dst
,
_M0
,
dsize
,
flags
,
borderType
,
borderValue
,
OCL_OP_PERSPECTIVE
))
return
;
Mat
src
=
_src
.
getMat
(),
M0
=
_M0
.
getMat
();
...
...
modules/imgproc/src/opencl/warp_affine.cl
浏览文件 @
dcce9d70
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录