Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
90d62cac
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,发现更多精彩内容 >>
提交
90d62cac
编写于
11月 25, 2013
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed cv::cvtColor
上级
16a3067a
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
151 addition
and
168 deletion
+151
-168
modules/imgproc/src/color.cpp
modules/imgproc/src/color.cpp
+3
-5
modules/imgproc/src/opencl/cvtcolor.cl
modules/imgproc/src/opencl/cvtcolor.cl
+17
-17
modules/imgproc/test/ocl/test_color.cpp
modules/imgproc/test/ocl/test_color.cpp
+131
-146
未找到文件。
modules/imgproc/src/color.cpp
浏览文件 @
90d62cac
...
...
@@ -2691,7 +2691,7 @@ struct mRGBA2RGBA
static
bool
ocl_cvtColor
(
InputArray
_src
,
OutputArray
_dst
,
int
code
,
int
dcn
)
{
bool
ok
=
tru
e
;
bool
ok
=
fals
e
;
UMat
src
=
_src
.
getUMat
(),
dst
;
Size
sz
=
src
.
size
(),
dstSz
=
sz
;
int
scn
=
src
.
channels
(),
depth
=
src
.
depth
(),
bidx
;
...
...
@@ -2729,7 +2729,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
CV_Assert
(
scn
==
1
);
dcn
=
code
==
COLOR_GRAY2BGRA
?
4
:
3
;
k
.
create
(
"Gray2RGB"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
format
(
"-D depth=%d -D scn=1 -D dcn=%d"
,
depth
,
dcn
));
format
(
"-D depth=%d -D
bidx=0 -D
scn=1 -D dcn=%d"
,
depth
,
dcn
));
break
;
}
case
COLOR_BGR2YUV
:
...
...
@@ -2763,9 +2763,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
bidx
=
code
==
COLOR_YUV2BGRA_NV12
||
code
==
COLOR_YUV2BGR_NV12
?
0
:
2
;
dstSz
=
Size
(
sz
.
width
,
sz
.
height
*
2
/
3
);
globalsize
[
0
]
=
dstSz
.
height
/
2
;
globalsize
[
1
]
=
dstSz
.
width
/
2
;
k
.
create
(
"YUV2RGBA_NV12"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
k
.
create
(
"YUV2RGB_NV12"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
format
(
"-D depth=0 -D scn=1 -D dcn=%d -D bidx=%d"
,
dcn
,
bidx
));
break
;
}
...
...
modules/imgproc/src/opencl/cvtcolor.cl
浏览文件 @
90d62cac
...
...
@@ -208,19 +208,19 @@ __constant int ITUR_BT_601_CVG = 852492;
__constant
int
ITUR_BT_601_CVR
=
1673527
;
__constant
int
ITUR_BT_601_SHIFT
=
20
;
__kernel
void
YUV2RGB
A
_NV12
(
__global
const
uchar*
srcptr,
int
srcstep,
int
srcoffset,
__kernel
void
YUV2RGB_NV12
(
__global
const
uchar*
srcptr,
int
srcstep,
int
srcoffset,
__global
uchar*
dstptr,
int
dststep,
int
dstoffset,
int
rows,
int
cols
)
{
const
int
x
=
get_global_id
(
0
)
; // max_x = width / 2
const
int
y
=
get_global_id
(
1
)
; // max_y = height/ 2
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
/
2
&&
x
<
cols
/
2
)
{
__global
const
uchar*
ysrc
=
(
__global
const
uchar*
)(
srcptr
+
mad24
(
y
<<
1
,
srcstep,
(
x
<<
1
)
+
srcoffset
)
)
;
__global
const
uchar*
usrc
=
(
__global
const
uchar*
)(
srcptr
+
mad24
(
rows
+
y,
srcstep,
(
x
<<
1
)
+
srcoffset
)
)
;
__global
uchar*
dst1
=
(
__global
uchar*
)(
dstptr
+
mad24
(
y
<<
1
,
dststep,
x*
(
dcn*2
)
+
dstoffset
)
)
;
__global
uchar*
dst2
=
(
__global
uchar*
)(
dstptr
+
mad24
((
y
<<
1
)
+
1
,
dststep,
x*
(
dcn*2
)
+
dstoffset
)
)
;
__global
const
uchar*
ysrc
=
srcptr
+
mad24
(
y
<<
1
,
srcstep,
(
x
<<
1
)
+
srcoffset
)
;
__global
const
uchar*
usrc
=
srcptr
+
mad24
(
rows
+
y,
srcstep,
(
x
<<
1
)
+
srcoffset
)
;
__global
uchar*
dst1
=
dstptr
+
mad24
(
y
<<
1
,
dststep,
x
*
(
dcn<<1
)
+
dstoffset
)
;
__global
uchar*
dst2
=
dstptr
+
mad24
((
y
<<
1
)
+
1
,
dststep,
x
*
(
dcn<<1
)
+
dstoffset
)
;
int
Y1
=
ysrc[0]
;
int
Y2
=
ysrc[1]
;
...
...
@@ -243,7 +243,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
#
endif
Y2
=
max
(
0
,
Y2
-
16
)
*
ITUR_BT_601_CY
;
dst1[
(
dcn
+
2
)
-
bidx]
=
convert_uchar_sat
((
Y2
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[
dcn
+
2
-
bidx]
=
convert_uchar_sat
((
Y2
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
1]
=
convert_uchar_sat
((
Y2
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
bidx]
=
convert_uchar_sat
((
Y2
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
#
if
dcn
==
4
...
...
@@ -259,7 +259,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
#
endif
Y4
=
max
(
0
,
Y4
-
16
)
*
ITUR_BT_601_CY
;
dst2[
(
dcn
+
2
)
-
bidx]
=
convert_uchar_sat
((
Y4
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[
dcn
+
2
-
bidx]
=
convert_uchar_sat
((
Y4
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
1]
=
convert_uchar_sat
((
Y4
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
bidx]
=
convert_uchar_sat
((
Y4
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
#
if
dcn
==
4
...
...
@@ -268,7 +268,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
}
}
/////////////////////////////////////
RGB
<->
YUV
//////////////////////////////////////
/////////////////////////////////////
RGB
->
YCrCb
//////////////////////////////////////
__constant
float
c_RGB2YCrCbCoeffs_f[5]
=
{0.299f,
0.587f,
0.114f,
0.713f,
0.564f}
;
__constant
int
c_RGB2YCrCbCoeffs_i[5]
=
{R2Y,
G2Y,
B2Y,
11682
,
9241}
;
...
...
@@ -288,15 +288,15 @@ __kernel void RGB2YCrCb(__global const uchar* srcptr, int srcstep, int srcoffset
#
ifdef
DEPTH_5
__constant
float
*
coeffs
=
c_RGB2YCrCbCoeffs_f
;
const
DATA_TYPE
Y
=
b
*
coeffs[0]
+
g
*
coeffs[1]
+
r
*
coeffs[2
]
;
const
DATA_TYPE
Cr
=
(
r
-
Y
)
*
coeffs[3]
+
HALF_MAX
;
const
DATA_TYPE
Cb
=
(
b
-
Y
)
*
coeffs[4]
+
HALF_MAX
;
DATA_TYPE
Y
=
b
*
coeffs[2]
+
g
*
coeffs[1]
+
r
*
coeffs[0
]
;
DATA_TYPE
Cr
=
(
r
-
Y
)
*
coeffs[3]
+
HALF_MAX
;
DATA_TYPE
Cb
=
(
b
-
Y
)
*
coeffs[4]
+
HALF_MAX
;
#
else
__constant
int
*
coeffs
=
c_RGB2YCrCbCoeffs_i
;
const
int
delta
=
HALF_MAX
*
(
1
<<
yuv_shift
)
;
const
int
Y
=
CV_DESCALE
(
b
*
coeffs[0]
+
g
*
coeffs[1]
+
r
*
coeffs[2
],
yuv_shift
)
;
const
int
Cr
=
CV_DESCALE
((
r
-
Y
)
*
coeffs[3]
+
delta,
yuv_shift
)
;
const
int
Cb
=
CV_DESCALE
((
b
-
Y
)
*
coeffs[4]
+
delta,
yuv_shift
)
;
int
delta
=
HALF_MAX
*
(
1
<<
yuv_shift
)
;
int
Y
=
CV_DESCALE
(
b
*
coeffs[2]
+
g
*
coeffs[1]
+
r
*
coeffs[0
],
yuv_shift
)
;
int
Cr
=
CV_DESCALE
((
r
-
Y
)
*
coeffs[3]
+
delta,
yuv_shift
)
;
int
Cb
=
CV_DESCALE
((
b
-
Y
)
*
coeffs[4]
+
delta,
yuv_shift
)
;
#
endif
dst[0]
=
SAT_CAST
(
Y
)
;
...
...
modules/imgproc/test/ocl/test_color.cpp
浏览文件 @
90d62cac
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录