Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
fd427c24
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fd427c24
编写于
2月 06, 2018
作者:
G
ghdawn
提交者:
Jiangtao Hu
2月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perception: add platform independent yuv2rgb
上级
189c1858
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
61 addition
and
9 deletion
+61
-9
modules/dreamview/backend/handlers/image.cc
modules/dreamview/backend/handlers/image.cc
+2
-2
modules/perception/traffic_light/base/image.cc
modules/perception/traffic_light/base/image.cc
+1
-1
modules/perception/traffic_light/util/color_space.cc
modules/perception/traffic_light/util/color_space.cc
+52
-1
modules/perception/traffic_light/util/color_space.h
modules/perception/traffic_light/util/color_space.h
+6
-5
未找到文件。
modules/dreamview/backend/handlers/image.cc
浏览文件 @
fd427c24
...
...
@@ -41,7 +41,7 @@ void ImageHandler::OnImage(const sensor_msgs::Image &image) {
unsigned
char
*
yuv
=
(
unsigned
char
*
)
&
(
image
.
data
[
0
]);
auto
mat
=
cv
::
Mat
(
image
.
height
,
image
.
width
,
CV_8UC3
);
apollo
::
perception
::
traffic_light
::
Yuyv2rgb
Avx
(
yuv
,
mat
.
data
,
apollo
::
perception
::
traffic_light
::
Yuyv2rgb
(
yuv
,
mat
.
data
,
image
.
height
*
image
.
width
);
cv
::
cvtColor
(
mat
,
mat
,
CV_RGB2BGR
);
...
...
modules/perception/traffic_light/base/image.cc
浏览文件 @
fd427c24
...
...
@@ -61,7 +61,7 @@ bool Image::GenerateMat() {
if
(
image_data_
->
encoding
.
compare
(
"yuyv"
)
==
0
)
{
unsigned
char
*
yuv
=
(
unsigned
char
*
)
&
(
image_data_
->
data
[
0
]);
mat_
=
cv
::
Mat
(
image_data_
->
height
,
image_data_
->
width
,
CV_8UC3
);
Yuyv2rgb
Avx
(
yuv
,
mat_
.
data
,
image_data_
->
height
*
image_data_
->
width
);
Yuyv2rgb
(
yuv
,
mat_
.
data
,
image_data_
->
height
*
image_data_
->
width
);
cv
::
cvtColor
(
mat_
,
mat_
,
CV_RGB2BGR
);
}
...
...
modules/perception/traffic_light/util/color_space.cc
浏览文件 @
fd427c24
...
...
@@ -44,6 +44,7 @@ namespace apollo {
namespace
perception
{
namespace
traffic_light
{
#ifdef __USE_AVX__
template
<
bool
align
>
SIMD_INLINE
void
YuvSeperateAvx2
(
uint8_t
*
y
,
__m256i
*
y0
,
__m256i
*
y1
,
__m256i
*
u0
,
__m256i
*
v0
)
{
...
...
@@ -121,7 +122,7 @@ void Yuv2rgbAvx2(uint8_t *yuv, uint8_t *rgb) {
rgb
+
3
*
sizeof
(
__m256i
));
}
void
Yuyv2rgb
Avx
(
unsigned
char
*
YUV
,
unsigned
char
*
RGB
,
int
NumPixels
)
{
void
Yuyv2rgb
(
unsigned
char
*
YUV
,
unsigned
char
*
RGB
,
int
NumPixels
)
{
assert
(
NumPixels
==
(
1920
*
1080
));
bool
align
=
Aligned
(
YUV
)
&
Aligned
(
RGB
);
uint8_t
*
yuv_offset
=
YUV
;
...
...
@@ -140,6 +141,56 @@ void Yuyv2rgbAvx(unsigned char *YUV, unsigned char *RGB, int NumPixels) {
}
}
}
#else
unsigned
char
CLIPVALUE
(
int
val
)
{
// Old method (if)
val
=
val
<
0
?
0
:
val
;
return
val
>
255
?
255
:
val
;
// New method (array)
//return uchar_clipping_table[val + clipping_table_offset];
}
void
YUV2RGB
(
const
unsigned
char
y
,
const
unsigned
char
u
,
const
unsigned
char
v
,
unsigned
char
*
r
,
unsigned
char
*
g
,
unsigned
char
*
b
)
{
const
int
y2
=
(
int
)
y
;
const
int
u2
=
(
int
)
u
-
128
;
const
int
v2
=
(
int
)
v
-
128
;
double
r2
=
y2
+
(
1.4065
*
v2
);
double
g2
=
y2
-
(
0.3455
*
u2
)
-
(
0.7169
*
v2
);
double
b2
=
y2
+
(
2.041
*
u2
);
*
r
=
CLIPVALUE
(
r2
);
*
g
=
CLIPVALUE
(
g2
);
*
b
=
CLIPVALUE
(
b2
);
}
void
Yuyv2rgb
(
unsigned
char
*
YUV
,
unsigned
char
*
RGB
,
int
NumPixels
){
int
i
,
j
;
unsigned
char
y0
,
y1
,
u
,
v
;
unsigned
char
r
,
g
,
b
;
for
(
i
=
0
,
j
=
0
;
i
<
(
NumPixels
<<
1
);
i
+=
4
,
j
+=
6
)
{
u
=
(
unsigned
char
)
YUV
[
i
+
0
];
y0
=
(
unsigned
char
)
YUV
[
i
+
1
];
v
=
(
unsigned
char
)
YUV
[
i
+
2
];
y1
=
(
unsigned
char
)
YUV
[
i
+
3
];
YUV2RGB
(
y0
,
u
,
v
,
&
r
,
&
g
,
&
b
);
RGB
[
j
+
0
]
=
r
;
RGB
[
j
+
1
]
=
g
;
RGB
[
j
+
2
]
=
b
;
YUV2RGB
(
y1
,
u
,
v
,
&
r
,
&
g
,
&
b
);
RGB
[
j
+
3
]
=
r
;
RGB
[
j
+
4
]
=
g
;
RGB
[
j
+
5
]
=
b
;
}
}
#endif
}
// namespace traffic_light
}
// namespace perception
...
...
modules/perception/traffic_light/util/color_space.h
浏览文件 @
fd427c24
...
...
@@ -35,16 +35,17 @@
#ifndef USB_CAM_INCLUDE_USB_CAM_UTILITY_H_
#define USB_CAM_INCLUDE_USB_CAM_UTILITY_H_
#ifdef __x86_64__
#define __USE_AVX__
#include <immintrin.h>
#include <x86intrin.h>
#include <cstdint>
#endif
namespace
apollo
{
namespace
perception
{
namespace
traffic_light
{
void
Yuyv2rgbAvx
(
unsigned
char
*
YUV
,
unsigned
char
*
RGB
,
int
NumPixels
);
void
Yuyv2rgb
(
unsigned
char
*
YUV
,
unsigned
char
*
RGB
,
int
NumPixels
);
#ifdef __USE_AVX__
#define SIMD_INLINE inline __attribute__((always_inline))
...
...
@@ -533,7 +534,7 @@ template <bool align>
SIMD_INLINE
__m256i
LoadPermuted
(
const
__m256i
*
p
)
{
return
_mm256_permute4x64_epi64
(
Load
<
align
>
(
p
),
0xD8
);
}
#endif
}
// namespace traffic_light
}
// namespace perception
}
// namespace apollo
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录