Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
1f421fce
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
1f421fce
编写于
11月 11, 2013
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added RGB5x5 <-> RGB conversion
上级
3cc9502c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
151 addition
and
2 deletion
+151
-2
modules/ocl/src/color.cpp
modules/ocl/src/color.cpp
+65
-2
modules/ocl/src/opencl/cvt_color.cl
modules/ocl/src/opencl/cvt_color.cl
+58
-0
modules/ocl/test/test_color.cpp
modules/ocl/test/test_color.cpp
+28
-0
未找到文件。
modules/ocl/src/color.cpp
浏览文件 @
1f421fce
...
...
@@ -122,6 +122,50 @@ static void RGB_caller(const oclMat &src, oclMat &dst, bool reverse)
openCLExecuteKernel
(
src
.
clCxt
,
&
cvt_color
,
"RGB"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
.
c_str
());
}
static
void
RGB5x52RGB_caller
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
bidx
,
int
greenbits
)
{
std
::
string
build_options
=
format
(
"-D DEPTH_%d -D greenbits=%d -D dcn=%d"
,
src
.
depth
(),
greenbits
,
dst
.
channels
());
int
src_offset
=
src
.
offset
>>
1
,
src_step
=
src
.
step
>>
1
;
int
dst_offset
=
(
int
)
dst
.
offset
,
dst_step
=
(
int
)
dst
.
step
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src_step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst_step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
bidx
));
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_int
)
,
(
void
*
)
&
src_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst_offset
));
size_t
gt
[
3
]
=
{
dst
.
cols
,
dst
.
rows
,
1
},
lt
[
3
]
=
{
16
,
16
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
cvt_color
,
"RGB5x52RGB"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
.
c_str
());
}
static
void
RGB2RGB5x5_caller
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
bidx
,
int
greenbits
)
{
std
::
string
build_options
=
format
(
"-D DEPTH_%d -D greenbits=%d -D scn=%d"
,
src
.
depth
(),
greenbits
,
src
.
channels
());
int
src_offset
=
(
int
)
src
.
offset
,
src_step
=
(
int
)
src
.
step
;
int
dst_offset
=
dst
.
offset
>>
1
,
dst_step
=
dst
.
step
>>
1
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src_step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst_step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
bidx
));
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_int
)
,
(
void
*
)
&
src_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst_offset
));
size_t
gt
[
3
]
=
{
dst
.
cols
,
dst
.
rows
,
1
},
lt
[
3
]
=
{
16
,
16
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
cvt_color
,
"RGB2RGB5x5"
,
gt
,
lt
,
args
,
-
1
,
-
1
,
build_options
.
c_str
());
}
static
void
cvtColor_caller
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
code
,
int
dcn
)
{
Size
sz
=
src
.
size
();
...
...
@@ -141,12 +185,31 @@ static void cvtColor_caller(const oclMat &src, oclMat &dst, int code, int dcn)
RGB_caller
(
src
,
dst
,
reverse
);
break
;
}
/*
case
CV_BGR2BGR565
:
case
CV_BGR2BGR555
:
case
CV_RGB2BGR565
:
case
CV_RGB2BGR555
:
case
CV_BGRA2BGR565
:
case
CV_BGRA2BGR555
:
case
CV_RGBA2BGR565
:
case
CV_RGBA2BGR555
:
{
CV_Assert
((
scn
==
3
||
scn
==
4
)
&&
depth
==
CV_8U
);
bidx
=
code
==
CV_BGR2BGR565
||
code
==
CV_BGR2BGR555
||
code
==
CV_BGRA2BGR565
||
code
==
CV_BGRA2BGR555
?
0
:
2
;
int
greenbits
=
code
==
CV_BGR2BGR565
||
code
==
CV_RGB2BGR565
||
code
==
CV_BGRA2BGR565
||
code
==
CV_RGBA2BGR565
?
6
:
5
;
dst
.
create
(
sz
,
CV_8UC2
);
RGB2RGB5x5_caller
(
src
,
dst
,
bidx
,
greenbits
);
break
;
}
case
CV_BGR5652BGR
:
case
CV_BGR5552BGR
:
case
CV_BGR5652RGB
:
case
CV_BGR5552RGB
:
case
CV_BGR5652BGRA
:
case
CV_BGR5552BGRA
:
case
CV_BGR5652RGBA
:
case
CV_BGR5552RGBA
:
*/
{
dcn
=
code
==
CV_BGR5652BGRA
||
code
==
CV_BGR5552BGRA
||
code
==
CV_BGR5652RGBA
||
code
==
CV_BGR5552RGBA
?
4
:
3
;
CV_Assert
((
dcn
==
3
||
dcn
==
4
)
&&
scn
==
2
&&
depth
==
CV_8U
);
bidx
=
code
==
CV_BGR5652BGR
||
code
==
CV_BGR5552BGR
||
code
==
CV_BGR5652BGRA
||
code
==
CV_BGR5552BGRA
?
0
:
2
;
int
greenbits
=
code
==
CV_BGR5652BGR
||
code
==
CV_BGR5652RGB
||
code
==
CV_BGR5652BGRA
||
code
==
CV_BGR5652RGBA
?
6
:
5
;
dst
.
create
(
sz
,
CV_MAKETYPE
(
depth
,
dcn
));
RGB5x52RGB_caller
(
src
,
dst
,
bidx
,
greenbits
);
break
;
}
case
CV_RGB2GRAY
:
case
CV_BGR2GRAY
:
case
CV_RGBA2GRAY
:
case
CV_BGRA2GRAY
:
{
...
...
modules/ocl/src/opencl/cvt_color.cl
浏览文件 @
1f421fce
...
...
@@ -437,3 +437,61 @@ __kernel void RGB(int cols, int rows, int src_step, int dst_step,
#
endif
}
}
/////////////////////////////////////
RGB5x5
<->
RGB
//////////////////////////////////////
__kernel
void
RGB5x52RGB
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
int
bidx,
__global
const
ushort
*
src,
__global
uchar
*
dst,
int
src_offset,
int
dst_offset
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
&&
x
<
cols
)
{
int
src_idx
=
mad24
(
y,
src_step,
src_offset
+
x
)
;
int
dst_idx
=
mad24
(
y,
dst_step,
dst_offset
+
(
x
<<
2
))
;
ushort
t
=
src[src_idx]
;
#
if
greenbits
==
6
dst[dst_idx
+
bidx]
=
(
uchar
)(
t
<<
3
)
;
dst[dst_idx
+
1]
=
(
uchar
)((
t
>>
3
)
&
~3
)
;
dst[dst_idx
+
(
bidx^2
)
]
=
(
uchar
)((
t
>>
8
)
&
~7
)
;
#
else
dst[dst_idx
+
bidx]
=
(
uchar
)(
t
<<
3
)
;
dst[dst_idx
+
1]
=
(
uchar
)((
t
>>
2
)
&
~7
)
;
dst[dst_idx
+
(
bidx^2
)
]
=
(
uchar
)((
t
>>
7
)
&
~7
)
;
#
endif
#
if
dcn
==
4
#
if
greenbits
==
6
dst[dst_idx
+
3]
=
255
;
#
else
dst[dst_idx
+
3]
=
t
&
0x8000
?
255
:
0
;
#
endif
#
endif
}
}
__kernel
void
RGB2RGB5x5
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
int
bidx,
__global
const
uchar
*
src,
__global
ushort
*
dst,
int
src_offset,
int
dst_offset
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
&&
x
<
cols
)
{
int
src_idx
=
mad24
(
y,
src_step,
src_offset
+
(
x
<<
2
))
;
int
dst_idx
=
mad24
(
y,
dst_step,
dst_offset
+
x
)
;
#
if
greenbits
==
6
dst[dst_idx]
=
(
ushort
)((
src[src_idx
+
bidx]
>>
3
)
|((src[src_idx + 1]&~3) << 3)|
((
src[src_idx
+
(
bidx^2
)
]&~7
)
<<
8
))
;
#
elif
scn
==
3
dst[dst_idx]
=
(
ushort
)((
src[src_idx
+
bidx]
>>
3
)
|((src[src_idx + 1]&~7) << 2)|
((
src[src_idx
+
(
bidx^2
)
]&~7
)
<<
7
))
;
#
else
dst[dst_idx]
=
(
ushort
)((
src[src_idx
+
bidx]
>>
3
)
|((src[src_idx + 1]&~7) << 2)|
((
src[src_idx
+
(
bidx^2
)
]&~7
)
<<
7
)
|
(
src[src_idx
+
3]
?
0x8000
:
0
))
;
#
endif
}
}
modules/ocl/test/test_color.cpp
浏览文件 @
1f421fce
...
...
@@ -181,6 +181,30 @@ OCL_TEST_P(CvtColor, XYZ2BGR) { doTest(3, 3, CVTCODE(XYZ2BGR)); }
OCL_TEST_P
(
CvtColor
,
XYZ2RGBA
)
{
doTest
(
3
,
4
,
CVTCODE
(
XYZ2RGB
));
}
OCL_TEST_P
(
CvtColor
,
XYZ2BGRA
)
{
doTest
(
3
,
4
,
CVTCODE
(
XYZ2BGR
));
}
// RGB5x5 <-> RGB
typedef
CvtColor
CvtColor8u
;
OCL_TEST_P
(
CvtColor8u
,
BGR5652BGR
)
{
doTest
(
2
,
3
,
CVTCODE
(
BGR5652BGR
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5652RGB
)
{
doTest
(
2
,
3
,
CVTCODE
(
BGR5652RGB
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5652BGRA
)
{
doTest
(
2
,
4
,
CVTCODE
(
BGR5652BGRA
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5652RGBA
)
{
doTest
(
2
,
4
,
CVTCODE
(
BGR5652RGBA
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5552BGR
)
{
doTest
(
2
,
3
,
CVTCODE
(
BGR5552BGR
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5552RGB
)
{
doTest
(
2
,
3
,
CVTCODE
(
BGR5552RGB
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5552BGRA
)
{
doTest
(
2
,
4
,
CVTCODE
(
BGR5552BGRA
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR5552RGBA
)
{
doTest
(
2
,
4
,
CVTCODE
(
BGR5552RGBA
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR2BGR565
)
{
doTest
(
3
,
2
,
CVTCODE
(
BGR2BGR565
));
}
OCL_TEST_P
(
CvtColor8u
,
RGB2BGR565
)
{
doTest
(
3
,
2
,
CVTCODE
(
RGB2BGR565
));
}
OCL_TEST_P
(
CvtColor8u
,
BGRA2BGR565
)
{
doTest
(
4
,
2
,
CVTCODE
(
BGRA2BGR565
));
}
OCL_TEST_P
(
CvtColor8u
,
RGBA2BGR565
)
{
doTest
(
4
,
2
,
CVTCODE
(
RGBA2BGR565
));
}
OCL_TEST_P
(
CvtColor8u
,
BGR2BGR555
)
{
doTest
(
3
,
2
,
CVTCODE
(
BGR2BGR555
));
}
OCL_TEST_P
(
CvtColor8u
,
RGB2BGR555
)
{
doTest
(
3
,
2
,
CVTCODE
(
RGB2BGR555
));
}
OCL_TEST_P
(
CvtColor8u
,
BGRA2BGR555
)
{
doTest
(
4
,
2
,
CVTCODE
(
BGRA2BGR555
));
}
OCL_TEST_P
(
CvtColor8u
,
RGBA2BGR555
)
{
doTest
(
4
,
2
,
CVTCODE
(
RGBA2BGR555
));
}
// YUV -> RGBA_NV12
struct
CvtColor_YUV420
:
...
...
@@ -210,6 +234,10 @@ OCL_TEST_P(CvtColor_YUV420, YUV2BGRA_NV12) { doTest(1, 4, CV_YUV2BGRA_NV12); }
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2RGB_NV12
)
{
doTest
(
1
,
3
,
CV_YUV2RGB_NV12
);
}
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2BGR_NV12
)
{
doTest
(
1
,
3
,
CV_YUV2BGR_NV12
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
CvtColor8u
,
testing
::
Combine
(
testing
::
Values
(
MatDepth
(
CV_8U
)),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
CvtColor
,
testing
::
Combine
(
testing
::
Values
(
MatDepth
(
CV_8U
),
MatDepth
(
CV_16U
),
MatDepth
(
CV_32F
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录