Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
d36d181b
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,体验更适合开发者的 AI 搜索 >>
提交
d36d181b
编写于
10月 19, 2018
作者:
D
dangyuedong
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Framework: fix cyber_monitor potential issue; Modules: fix visualizer camera image format issue
上级
038f5dde
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
607 addition
and
452 deletion
+607
-452
cybertron/logger/log_file_object.cc
cybertron/logger/log_file_object.cc
+1
-1
cybertron/tools/cvt/monitor/cybertron_channel_message.h
cybertron/tools/cvt/monitor/cybertron_channel_message.h
+12
-2
cybertron/tools/cvt/monitor/cybertron_topology_message.cc
cybertron/tools/cvt/monitor/cybertron_topology_message.cc
+54
-44
cybertron/tools/cvt/monitor/cybertron_topology_message.h
cybertron/tools/cvt/monitor/cybertron_topology_message.h
+2
-1
cybertron/tools/cvt/monitor/main.cc
cybertron/tools/cvt/monitor/main.cc
+16
-3
modules/tools/visualizer/channel_reader.h
modules/tools/visualizer/channel_reader.h
+11
-17
modules/tools/visualizer/grid.cc
modules/tools/visualizer/grid.cc
+1
-1
modules/tools/visualizer/grid.h
modules/tools/visualizer/grid.h
+3
-3
modules/tools/visualizer/main.cc
modules/tools/visualizer/main.cc
+10
-3
modules/tools/visualizer/main_window.cc
modules/tools/visualizer/main_window.cc
+364
-309
modules/tools/visualizer/main_window.h
modules/tools/visualizer/main_window.h
+14
-3
modules/tools/visualizer/plane.cc
modules/tools/visualizer/plane.cc
+32
-28
modules/tools/visualizer/pointcloud.cc
modules/tools/visualizer/pointcloud.cc
+1
-1
modules/tools/visualizer/radarpoints.cc
modules/tools/visualizer/radarpoints.cc
+3
-3
modules/tools/visualizer/radarpoints.h
modules/tools/visualizer/radarpoints.h
+3
-3
modules/tools/visualizer/renderable_object.h
modules/tools/visualizer/renderable_object.h
+2
-2
modules/tools/visualizer/scene_viewer.cc
modules/tools/visualizer/scene_viewer.cc
+11
-11
modules/tools/visualizer/texture.cc
modules/tools/visualizer/texture.cc
+58
-8
modules/tools/visualizer/uis/main_window.ui
modules/tools/visualizer/uis/main_window.ui
+7
-7
modules/tools/visualizer/video_image_viewer.cc
modules/tools/visualizer/video_image_viewer.cc
+2
-2
未找到文件。
cybertron/logger/log_file_object.cc
浏览文件 @
d36d181b
...
...
@@ -180,7 +180,7 @@ bool LogFileObject::CreateLogfile(const std::string& time_pid_string) {
// entire log directory gets relocated the link is still valid.
const
char
*
linkdest
=
slash
?
(
slash
+
1
)
:
filename
;
// silently ignore failures
if
(
!
symlink
(
linkdest
,
linkpath
.
c_str
()))
{
if
(
symlink
(
linkdest
,
linkpath
.
c_str
()))
{
AERROR
<<
"symlink failed."
;
}
}
...
...
cybertron/tools/cvt/monitor/cybertron_channel_message.h
浏览文件 @
d36d181b
...
...
@@ -131,10 +131,10 @@ class ChannelMessage : public GeneralMessageBase {
const
std
::
string
&
NodeName
(
void
)
const
{
return
channel_node_
->
Name
();
}
void
add_reader
(
const
std
::
string
&
reader
)
{
readers_
.
push_back
(
reader
);
}
void
add_reader
(
const
std
::
string
&
reader
)
{
DoAdd
(
readers_
,
reader
);
}
void
del_reader
(
const
std
::
string
&
reader
)
{
DoDelete
(
readers_
,
reader
);
}
void
add_writer
(
const
std
::
string
&
writer
)
{
writers_
.
push_back
(
writer
);
}
void
add_writer
(
const
std
::
string
&
writer
)
{
DoAdd
(
writers_
,
writer
);
}
void
del_writer
(
const
std
::
string
&
writer
)
{
DoDelete
(
writers_
,
writer
);
if
(
!
writers_
.
size
())
{
...
...
@@ -152,6 +152,16 @@ class ChannelMessage : public GeneralMessageBase {
}
}
static
void
DoAdd
(
std
::
vector
<
std
::
string
>&
vec
,
const
std
::
string
&
str
)
{
for
(
auto
iter
=
vec
.
begin
();
iter
!=
vec
.
end
();
++
iter
)
{
if
(
*
iter
==
str
)
{
return
;
}
}
vec
.
emplace_back
(
str
);
}
void
set_has_message_come
(
bool
b
)
{
has_message_come_
=
b
;
}
bool
is_enabled_
;
...
...
cybertron/tools/cvt/monitor/cybertron_topology_message.cc
浏览文件 @
d36d181b
...
...
@@ -20,6 +20,7 @@
#include "./screen.h"
#include "cybertron/message/message_traits.h"
#include "cybertron/proto/topology_change.pb.h"
#include "cybertron/proto/role_attributes.pb.h"
#include <ncurses.h>
#include <iomanip>
...
...
@@ -71,9 +72,33 @@ RenderableMessage* CybertronTopologyMessage::Child(int lineNo) const {
void
CybertronTopologyMessage
::
TopologyChanged
(
const
apollo
::
cybertron
::
proto
::
ChangeMsg
&
changeMsg
)
{
const
std
::
string
&
nodeName
=
changeMsg
.
role_attr
().
node_name
();
const
std
::
string
&
channelName
=
changeMsg
.
role_attr
().
channel_name
();
const
std
::
string
&
msgTypeName
=
changeMsg
.
role_attr
().
message_type
();
if
(
::
apollo
::
cybertron
::
proto
::
OperateType
::
OPT_JOIN
==
changeMsg
.
operate_type
())
{
bool
isWriter
=
true
;
if
(
::
apollo
::
cybertron
::
proto
::
RoleType
::
ROLE_READER
==
changeMsg
.
role_type
())
isWriter
=
false
;
AddReaderWriter
(
changeMsg
.
role_attr
(),
isWriter
);
}
else
{
auto
iter
=
all_channels_map_
.
find
(
changeMsg
.
role_attr
().
channel_name
());
if
(
iter
!=
all_channels_map_
.
cend
()
&&
!
ChannelMessage
::
isErrorCode
(
iter
->
second
))
{
const
std
::
string
&
nodeName
=
changeMsg
.
role_attr
().
node_name
();
if
(
::
apollo
::
cybertron
::
proto
::
RoleType
::
ROLE_WRITER
==
changeMsg
.
role_type
())
{
changeMsg
.
role_attr
();
iter
->
second
->
del_writer
(
nodeName
);
}
else
{
iter
->
second
->
del_reader
(
nodeName
);
}
}
}
}
void
CybertronTopologyMessage
::
AddReaderWriter
(
const
apollo
::
cybertron
::
proto
::
RoleAttributes
&
role
,
bool
isWriter
)
{
const
std
::
string
&
channelName
=
role
.
channel_name
();
if
(
!
specified_channel_
.
empty
()
&&
specified_channel_
!=
channelName
)
{
return
;
...
...
@@ -83,54 +108,39 @@ void CybertronTopologyMessage::TopologyChanged(
col1_width_
=
channelName
.
length
();
}
if
(
::
apollo
::
cybertron
::
proto
::
OperateType
::
OPT_JOIN
==
changeMsg
.
operate_type
())
{
if
(
ChannelMsgFactory
::
Instance
()
->
isFromHere
(
nodeName
))
{
return
;
}
ChannelMessage
*
channelMsg
=
nullptr
;
auto
iter
=
all_channels_map_
.
find
(
channelName
);
if
(
iter
==
all_channels_map_
.
cend
())
{
channelMsg
=
ChannelMsgFactory
::
Instance
()
->
CreateChannelMessage
(
msgTypeName
,
channelName
);
if
(
!
ChannelMessage
::
isErrorCode
(
channelMsg
))
{
channelMsg
->
set_parent
(
this
);
channelMsg
->
set_message_type
(
msgTypeName
);
channelMsg
->
add_reader
(
channelMsg
->
NodeName
());
}
const
std
::
string
&
nodeName
=
role
.
node_name
();
if
(
ChannelMsgFactory
::
Instance
()
->
isFromHere
(
nodeName
))
{
return
;
}
all_channels_map_
[
channelName
]
=
channelMsg
;
}
else
{
channelMsg
=
iter
->
second
;
}
ChannelMessage
*
channelMsg
=
nullptr
;
const
std
::
string
&
msgTypeName
=
role
.
message_type
();
auto
iter
=
all_channels_map_
.
find
(
channelName
);
if
(
iter
==
all_channels_map_
.
cend
())
{
channelMsg
=
ChannelMsgFactory
::
Instance
()
->
CreateChannelMessage
(
msgTypeName
,
channelName
);
if
(
!
ChannelMessage
::
isErrorCode
(
channelMsg
))
{
if
(
::
apollo
::
cybertron
::
proto
::
RoleType
::
ROLE_WRITER
==
changeMsg
.
role_type
())
{
if
(
msgTypeName
!=
apollo
::
cybertron
::
message
::
MessageType
<
apollo
::
cybertron
::
message
::
RawMessage
>
())
{
channelMsg
->
set_message_type
(
msgTypeName
);
}
channelMsg
->
add_writer
(
nodeName
);
}
else
{
channelMsg
->
add_reader
(
nodeName
);
}
channelMsg
->
set_parent
(
this
);
channelMsg
->
set_message_type
(
msgTypeName
);
channelMsg
->
add_reader
(
channelMsg
->
NodeName
());
}
all_channels_map_
[
channelName
]
=
channelMsg
;
}
else
{
auto
iter
=
all_channels_map_
.
find
(
channelName
);
channelMsg
=
iter
->
second
;
}
if
(
iter
!=
all_channels_map_
.
cend
()
&&
!
ChannelMessage
::
isErrorCode
(
iter
->
second
))
{
if
(
::
apollo
::
cybertron
::
proto
::
RoleType
::
ROLE_WRITER
==
changeMsg
.
role_type
())
{
iter
->
second
->
del_writer
(
nodeName
);
}
else
{
iter
->
second
->
del_reader
(
nodeName
);
if
(
!
ChannelMessage
::
isErrorCode
(
channelMsg
))
{
if
(
isWriter
)
{
if
(
msgTypeName
!=
apollo
::
cybertron
::
message
::
MessageType
<
apollo
::
cybertron
::
message
::
RawMessage
>
())
{
channelMsg
->
set_message_type
(
msgTypeName
);
}
channelMsg
->
add_writer
(
nodeName
);
}
else
{
channelMsg
->
add_reader
(
nodeName
);
}
}
}
...
...
cybertron/tools/cvt/monitor/cybertron_topology_message.h
浏览文件 @
d36d181b
...
...
@@ -25,6 +25,7 @@ namespace apollo {
namespace
cybertron
{
namespace
proto
{
class
ChangeMsg
;
class
RoleAttributes
;
}
// proto
}
// cybertron
}
// apollo
...
...
@@ -41,7 +42,7 @@ class CybertronTopologyMessage : public RenderableMessage {
RenderableMessage
*
Child
(
int
index
)
const
override
;
void
TopologyChanged
(
const
apollo
::
cybertron
::
proto
::
ChangeMsg
&
change_msg
);
void
AddReaderWriter
(
const
apollo
::
cybertron
::
proto
::
RoleAttributes
&
role
,
bool
isWriter
);
private:
CybertronTopologyMessage
(
const
CybertronTopologyMessage
&
)
=
delete
;
CybertronTopologyMessage
&
operator
=
(
const
CybertronTopologyMessage
&
)
=
delete
;
...
...
cybertron/tools/cvt/monitor/main.cc
浏览文件 @
d36d181b
...
...
@@ -99,9 +99,22 @@ int main(int argc, char *argv[]) {
topologyMsg
.
TopologyChanged
(
change_msg
);
};
apollo
::
cybertron
::
service_discovery
::
TopologyManager
::
Instance
()
->
channel_manager
()
->
AddChangeListener
(
topologyCallback
);
auto
channelManager
=
apollo
::
cybertron
::
service_discovery
::
TopologyManager
::
Instance
()
->
channel_manager
();
channelManager
->
AddChangeListener
(
topologyCallback
);
std
::
vector
<
apollo
::
cybertron
::
proto
::
RoleAttributes
>
roleVec
;
channelManager
->
GetWriters
(
&
roleVec
);
for
(
auto
&
role
:
roleVec
)
{
topologyMsg
.
AddReaderWriter
(
role
,
true
);
}
roleVec
.
clear
();
channelManager
->
GetReaders
(
&
roleVec
);
for
(
auto
&
role
:
roleVec
)
{
topologyMsg
.
AddReaderWriter
(
role
,
false
);
}
Screen
*
s
=
Screen
::
Instance
();
...
...
modules/tools/visualizer/channel_reader.h
浏览文件 @
d36d181b
...
...
@@ -18,7 +18,6 @@
#include "cybertron/cybertron.h"
#include <QThread>
#include <functional>
#include <memory>
#include <string>
...
...
@@ -29,10 +28,9 @@ template <typename T>
using
CyberChannelCallback
=
std
::
function
<
void
(
const
std
::
shared_ptr
<
T
>&
)
>
;
template
<
typename
T
>
class
CyberChannReader
:
public
QThread
{
class
CyberChannReader
{
public:
explicit
CyberChannReader
(
QObject
*
parent
=
nullptr
)
:
QThread
(
parent
),
channel_callback_
(
nullptr
),
channel_node_
(
nullptr
)
{}
CyberChannReader
(
void
)
:
channel_callback_
(
nullptr
),
channel_node_
(
nullptr
)
{}
~
CyberChannReader
()
{
CloseChannel
();
}
...
...
@@ -47,9 +45,10 @@ class CyberChannReader : public QThread {
}
bool
InstallCallbackAndOpen
(
CyberChannelCallback
<
T
>
channelCallback
,
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
return
InstallCallback
(
channelCallback
)
&&
OpenChannel
(
channelName
,
nodeName
);
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
return
InstallCallback
(
channelCallback
)
&&
OpenChannel
(
channelName
,
nodeName
);
}
bool
InstallCallback
(
CyberChannelCallback
<
T
>
channelCallback
)
{
...
...
@@ -62,8 +61,9 @@ class CyberChannReader : public QThread {
}
}
bool
OpenChannel
(
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
if
(
channelName
.
empty
()
||
nodeName
.
empty
()){
bool
OpenChannel
(
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
if
(
channelName
.
empty
()
||
nodeName
.
empty
())
{
std
::
cerr
<<
"Channel Name or Node Name must be not empty"
<<
std
::
endl
;
return
false
;
}
...
...
@@ -78,15 +78,9 @@ class CyberChannReader : public QThread {
const
std
::
string
&
NodeName
(
void
)
const
{
return
channel_node_
->
Name
();
}
void
start
(
Priority
priority
=
InheritPriority
)
{
if
(
channel_reader_
!=
nullptr
)
QThread
::
start
(
priority
);
}
protected:
void
run
()
override
{
apollo
::
cybertron
::
WaitForShutdown
();
}
private:
bool
CreateChannel
(
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
bool
CreateChannel
(
const
std
::
string
&
channelName
,
const
std
::
string
&
nodeName
)
{
if
(
channel_node_
==
nullptr
)
{
channel_node_
=
apollo
::
cybertron
::
CreateNode
(
nodeName
);
if
(
channel_node_
==
nullptr
)
{
...
...
modules/tools/visualizer/grid.cc
浏览文件 @
d36d181b
...
...
@@ -22,7 +22,7 @@ Grid::Grid(int cellCountBySide)
grid_color_
(
128
,
128
,
128
)
{}
bool
Grid
::
FillVertexBuffer
(
GLfloat
*
pBuffer
)
{
float
x
=
CellCount
(
)
/
2.0
f
;
float
x
=
static_cast
<
float
>
(
CellCount
()
)
/
2.0
f
;
float
z
;
for
(
z
=
-
x
;
z
<=
x
;
++
z
)
{
...
...
modules/tools/visualizer/grid.h
浏览文件 @
d36d181b
...
...
@@ -27,9 +27,9 @@ class Grid : public RenderableObject {
GLenum
GetPrimitiveType
(
void
)
const
{
return
GL_LINES
;
}
void
SetupExtraUniforms
(
void
)
{
QVector3D
color
;
color
.
setX
(
grid_color_
.
redF
(
));
color
.
setY
(
grid_color_
.
greenF
(
));
color
.
setZ
(
grid_color_
.
blueF
(
));
color
.
setX
(
static_cast
<
float
>
(
grid_color_
.
redF
()
));
color
.
setY
(
static_cast
<
float
>
(
grid_color_
.
greenF
()
));
color
.
setZ
(
static_cast
<
float
>
(
grid_color_
.
blueF
()
));
shader_program_
->
setUniformValue
(
"color"
,
color
);
}
...
...
modules/tools/visualizer/main.cc
浏览文件 @
d36d181b
...
...
@@ -44,9 +44,16 @@ int main(int argc, char* argv[]) {
w
.
TopologyChanged
(
change_msg
);
};
apollo
::
cybertron
::
service_discovery
::
TopologyManager
::
Instance
()
->
channel_manager
()
->
AddChangeListener
(
topologyCallback
);
auto
channelManager
=
apollo
::
cybertron
::
service_discovery
::
TopologyManager
::
Instance
()
->
channel_manager
();
channelManager
->
AddChangeListener
(
topologyCallback
);
std
::
vector
<
apollo
::
cybertron
::
proto
::
RoleAttributes
>
role_attr_vec
;
channelManager
->
GetWriters
(
&
role_attr_vec
);
for
(
auto
&
role_attr
:
role_attr_vec
)
{
w
.
FindNewWriter
(
role_attr
);
}
w
.
show
();
return
a
.
exec
();
...
...
modules/tools/visualizer/main_window.cc
浏览文件 @
d36d181b
此差异已折叠。
点击以展开。
modules/tools/visualizer/main_window.h
浏览文件 @
d36d181b
...
...
@@ -16,6 +16,9 @@
#pragma once
#include <map>
#include <string>
#include <QMainWindow>
#include <QMenu>
#include <QMutex>
...
...
@@ -51,6 +54,7 @@ class MainWindow : public QMainWindow {
~
MainWindow
();
void
TopologyChanged
(
const
apollo
::
cybertron
::
proto
::
ChangeMsg
&
change_msg
);
void
FindNewWriter
(
const
apollo
::
cybertron
::
proto
::
RoleAttributes
&
role
);
protected:
void
resizeEvent
(
QResizeEvent
*
)
override
;
...
...
@@ -98,6 +102,9 @@ class MainWindow : public QMainWindow {
void
ImageReaderCallback
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
Image
>&
imgData
,
VideoImgProxy
*
proxy
);
void
ImageReaderCallback
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
CompressedImage
>&
imgData
,
VideoImgProxy
*
proxy
);
void
InsertAllChannelNames
(
void
);
VideoImgProxy
*
AddVideoImgViewer
(
void
);
...
...
@@ -106,9 +113,10 @@ class MainWindow : public QMainWindow {
void
calculateWH
(
void
);
RadarData
*
createRadarData
(
void
);
void
DoOpenRadarChannel
(
bool
b
,
RadarData
*
radarProxy
);
void
RadarRenderCallback
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
RadarObstacles
>&
rawData
,
RadarData
*
radar
);
void
DoOpenRadarChannel
(
bool
b
,
RadarData
*
radarProxy
);
void
RadarRenderCallback
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
RadarObstacles
>&
rawData
,
RadarData
*
radar
);
Ui
::
MainWindow
*
ui_
;
MessageDialog
*
msg_dialog_
;
...
...
@@ -138,4 +146,7 @@ class MainWindow : public QMainWindow {
QList
<
RadarData
*>
radarData_list_
;
QList
<
RadarData
*>
closed_radarData_list_
;
std
::
map
<
std
::
string
,
std
::
string
>
_channelName2TypeMap
;
};
modules/tools/visualizer/plane.cc
浏览文件 @
d36d181b
...
...
@@ -62,39 +62,43 @@ bool Plane::FillVertexBuffer(GLfloat* pBuffer) {
void
Plane
::
SetupAllAttrPointer
(
void
)
{
glEnableVertexAttribArray
(
0
);
glVertexAttribPointer
(
0
,
2
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
GLfloat
)
*
vertex_element_count
(),
0
);
glVertexAttribPointer
(
0
,
2
,
GL_FLOAT
,
GL_FALSE
,
static_cast
<
int
>
(
sizeof
(
GLfloat
))
*
vertex_element_count
(),
0
);
glEnableVertexAttribArray
(
1
);
glVertexAttribPointer
(
1
,
2
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
GLfloat
)
*
vertex_element_count
(),
reinterpret_cast
<
void
*>
(
sizeof
(
GLfloat
)
*
2
));
glVertexAttribPointer
(
1
,
2
,
GL_FLOAT
,
GL_FALSE
,
static_cast
<
int
>
(
sizeof
(
GLfloat
))
*
vertex_element_count
(),
reinterpret_cast
<
void
*>
(
sizeof
(
GLfloat
)
*
2
));
}
void
Plane
::
Draw
(
void
)
{
if
(
texture_
->
isSizeChanged
())
{
glGenTextures
(
1
,
&
texture_id_
);
glBindTexture
(
GL_TEXTURE_2D
,
texture_id_
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_BORDER
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_BORDER
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA8
,
texture_
->
width
(),
texture_
->
height
(),
0
,
texture_
->
texture_format
(),
GL_UNSIGNED_BYTE
,
texture_
->
data
());
glBindTexture
(
GL_TEXTURE_2D
,
0
);
texture_
->
removeDirty
();
}
else
if
(
texture_
->
isDirty
())
{
glBindTexture
(
GL_TEXTURE_2D
,
texture_id_
);
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
texture_
->
width
(),
texture_
->
height
(),
texture_
->
texture_format
(),
GL_UNSIGNED_BYTE
,
texture_
->
data
());
glBindTexture
(
GL_TEXTURE_2D
,
0
);
texture_
->
removeDirty
();
if
(
texture_
->
data
())
{
if
(
texture_
->
isSizeChanged
())
{
glGenTextures
(
1
,
&
texture_id_
);
glBindTexture
(
GL_TEXTURE_2D
,
texture_id_
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_BORDER
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_BORDER
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA8
,
texture_
->
width
(),
texture_
->
height
(),
0
,
texture_
->
texture_format
(),
GL_UNSIGNED_BYTE
,
texture_
->
data
());
glBindTexture
(
GL_TEXTURE_2D
,
0
);
texture_
->
removeDirty
();
}
else
if
(
texture_
->
isDirty
())
{
glBindTexture
(
GL_TEXTURE_2D
,
texture_id_
);
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
texture_
->
width
(),
texture_
->
height
(),
texture_
->
texture_format
(),
GL_UNSIGNED_BYTE
,
texture_
->
data
());
glBindTexture
(
GL_TEXTURE_2D
,
0
);
texture_
->
removeDirty
();
}
}
glActiveTexture
(
GL_TEXTURE0
);
...
...
modules/tools/visualizer/pointcloud.cc
浏览文件 @
d36d181b
...
...
@@ -58,7 +58,7 @@ bool PointCloud::FillData(
tmp
[
0
]
=
point
.
x
();
tmp
[
1
]
=
point
.
z
();
tmp
[
2
]
=
-
point
.
y
();
tmp
[
3
]
=
point
.
intensity
(
);
tmp
[
3
]
=
static_cast
<
float
>
(
point
.
intensity
()
);
}
return
true
;
}
...
...
modules/tools/visualizer/radarpoints.cc
浏览文件 @
d36d181b
...
...
@@ -42,9 +42,9 @@ bool RadarPoints::FillData(
const
apollo
::
common
::
Point2D
&
position
=
iter
->
second
.
absolute_position
();
ptr
[
0
]
=
position
.
x
(
);
ptr
[
1
]
=
position
.
y
(
);
ptr
[
2
]
=
std
::
pow
(
10
,
iter
->
second
.
rcs
()
/
20.0
);
ptr
[
0
]
=
static_cast
<
float
>
(
position
.
x
()
);
ptr
[
1
]
=
static_cast
<
float
>
(
position
.
y
()
);
ptr
[
2
]
=
std
::
pow
(
10
.0
f
,
static_cast
<
float
>
(
iter
->
second
.
rcs
()
/
20.0
)
);
}
// end for
ret
=
true
;
...
...
modules/tools/visualizer/radarpoints.h
浏览文件 @
d36d181b
...
...
@@ -60,9 +60,9 @@ public:
}
void
set_color
(
const
QColor
&
color
)
{
color_
.
setX
(
color
.
redF
(
));
color_
.
setY
(
color
.
greenF
(
));
color_
.
setZ
(
color
.
blueF
(
));
color_
.
setX
(
static_cast
<
float
>
(
color
.
redF
()
));
color_
.
setY
(
static_cast
<
float
>
(
color
.
greenF
()
));
color_
.
setZ
(
static_cast
<
float
>
(
color
.
blueF
()
));
}
bool
FillData
(
...
...
modules/tools/visualizer/renderable_object.h
浏览文件 @
d36d181b
...
...
@@ -48,7 +48,7 @@ class RenderableObject : protected QOpenGLFunctions {
}
int
VertexBufferSize
(
void
)
const
{
return
vertex_count
()
*
vertex_element_count
()
*
s
izeof
(
GLfloat
);
return
vertex_count
()
*
vertex_element_count
()
*
s
tatic_cast
<
int
>
(
sizeof
(
GLfloat
)
);
}
void
set_shader_program
(
...
...
@@ -74,7 +74,7 @@ class RenderableObject : protected QOpenGLFunctions {
virtual
void
SetupAllAttrPointer
(
void
)
{
glEnableVertexAttribArray
(
0
);
glVertexAttribPointer
(
0
,
vertex_element_count
(),
GL_FLOAT
,
GL_FALSE
,
s
izeof
(
GLfloat
)
*
vertex_element_count
(),
0
);
s
tatic_cast
<
int
>
(
sizeof
(
GLfloat
)
)
*
vertex_element_count
(),
0
);
}
bool
is_init_
;
...
...
modules/tools/visualizer/scene_viewer.cc
浏览文件 @
d36d181b
...
...
@@ -250,8 +250,8 @@ void SceneViewer::UpdateCameraYaw(double yawInDegrees) {
yawInDegrees
+=
360.0
;
}
free_camera_
.
set_yaw
(
yawInDegrees
);
target_camera_
.
set_yaw
(
yawInDegrees
);
free_camera_
.
set_yaw
(
static_cast
<
float
>
(
yawInDegrees
)
);
target_camera_
.
set_yaw
(
static_cast
<
float
>
(
yawInDegrees
)
);
UpdateCameraWorld
();
}
...
...
@@ -263,8 +263,8 @@ void SceneViewer::UpdateCameraPitch(double pitchInDegrees) {
pitchInDegrees
=
-
90.0
;
}
free_camera_
.
set_pitch
(
pitchInDegrees
);
target_camera_
.
set_pitch
(
pitchInDegrees
);
free_camera_
.
set_pitch
(
static_cast
<
float
>
(
pitchInDegrees
)
);
target_camera_
.
set_pitch
(
static_cast
<
float
>
(
pitchInDegrees
)
);
UpdateCameraWorld
();
}
void
SceneViewer
::
UpdateCameraRoll
(
double
rollInDegrees
)
{
...
...
@@ -275,8 +275,8 @@ void SceneViewer::UpdateCameraRoll(double rollInDegrees) {
rollInDegrees
+=
360.0
;
}
free_camera_
.
set_roll
(
rollInDegrees
);
free_camera_
.
set_roll
(
rollInDegrees
);
free_camera_
.
set_roll
(
static_cast
<
float
>
(
rollInDegrees
)
);
free_camera_
.
set_roll
(
static_cast
<
float
>
(
rollInDegrees
)
);
UpdateCameraWorld
();
}
...
...
@@ -316,7 +316,7 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) {
left_key_last_pos_
=
QCursor
::
pos
();
}
else
if
(
event
->
button
()
==
Qt
::
RightButton
)
{
right_key_is_moved_
=
false
;
right_key_last_y_
=
QCursor
::
pos
().
y
(
);
right_key_last_y_
=
static_cast
<
float
>
(
QCursor
::
pos
().
y
()
);
}
QOpenGLWidget
::
mousePressEvent
(
event
);
...
...
@@ -328,8 +328,8 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *mouseEvent) {
QPoint
dd
=
tmp
-
left_key_last_pos_
;
left_key_last_pos_
=
tmp
;
float
x
=
dd
.
x
(
)
*
sensitivity
();
float
y
=
dd
.
y
(
)
*
sensitivity
();
float
x
=
static_cast
<
float
>
(
dd
.
x
()
)
*
sensitivity
();
float
y
=
static_cast
<
float
>
(
dd
.
y
()
)
*
sensitivity
();
if
(
IsFreeCamera
())
{
free_camera_
.
Starfe
(
-
x
);
...
...
@@ -365,7 +365,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *mouseEvent) {
right_key_is_moved_
=
true
;
if
(
IsFreeCamera
())
{
{
float
tmp
=
QCursor
::
pos
().
y
(
);
float
tmp
=
static_cast
<
float
>
(
QCursor
::
pos
().
y
()
);
float
dd
=
right_key_last_y_
-
tmp
;
right_key_last_y_
=
tmp
;
...
...
@@ -385,7 +385,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *mouseEvent) {
}
void
SceneViewer
::
wheelEvent
(
QWheelEvent
*
event
)
{
float
delta
=
event
->
angleDelta
().
y
(
);
float
delta
=
static_cast
<
float
>
(
event
->
angleDelta
().
y
()
);
delta
*=
sensitivity
();
target_camera_
.
set_distance
(
target_camera_
.
distance
()
+
delta
);
...
...
modules/tools/visualizer/texture.cc
浏览文件 @
d36d181b
...
...
@@ -26,7 +26,9 @@ Texture::Texture()
data_size_
(
0
),
data_
(
nullptr
)
{}
bool
Texture
::
UpdateData
(
const
QImage
&
img
)
{
bool
Texture
::
UpdateData
(
const
QImage
&
img
)
{
std
::
cout
<<
"Image: ImageSize = "
<<
img
.
byteCount
()
<<
", data_size_ = "
<<
data_size_
;
if
(
data_size_
<
img
.
byteCount
())
{
if
(
!
data_
)
{
delete
[]
data_
;
...
...
@@ -41,17 +43,26 @@ bool Texture::UpdateData(const QImage &img) {
is_size_changed_
=
true
;
}
image_height_
=
img
.
height
();
image_width_
=
img
.
width
();
memcpy
(
data_
,
img
.
bits
(),
img
.
byteCount
());
is_dirty_
=
true
;
image_height_
=
img
.
height
();
image_width_
=
img
.
width
();
std
::
cout
<<
", imgWidth = "
<<
image_width_
<<
", imgHeight = "
<<
image_height_
<<
", w * h * sizeof(GL_RGB) = "
<<
image_width_
*
image_height_
*
sizeof
(
GL_RGB
)
<<
",format = "
<<
img
.
pixelFormat
().
colorModel
()
<<
std
::
endl
;
texture_format_
=
GL_RGBA
;
return
true
;
}
bool
Texture
::
UpdateData
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
Image
>&
imgData
){
std
::
size_t
imgSize
=
imgData
->
data
().
size
();
bool
Texture
::
UpdateData
(
const
std
::
shared_ptr
<
const
apollo
::
drivers
::
Image
>&
imgData
)
{
std
::
size_t
imgSize
=
imgData
->
width
()
*
imgData
->
height
()
*
3
;
if
(
static_cast
<
std
::
size_t
>
(
data_size_
)
<
imgSize
)
{
if
(
!
data_
)
{
delete
[]
data_
;
...
...
@@ -62,15 +73,54 @@ bool Texture::UpdateData(const std::shared_ptr<const apollo::drivers::Image>& im
data_size_
=
0
;
return
false
;
}
data_size_
=
imgSize
;
data_size_
=
static_cast
<
GLsizei
>
(
imgSize
)
;
is_size_changed_
=
true
;
}
memcpy
(
data_
,
imgData
->
data
().
c_str
(),
imgSize
);
if
(
imgData
->
encoding
()
==
std
::
string
(
"yuyv"
)){
const
GLubyte
*
src
=
reinterpret_cast
<
const
GLubyte
*>
(
imgData
->
data
().
c_str
());
auto
clamp
=
[](
int
v
)
->
GLubyte
{
int
ret
=
v
;
if
(
v
<
0
)
{
ret
=
0
;
}
if
(
v
>
255
)
{
ret
=
255
;
}
return
static_cast
<
GLubyte
>
(
ret
);
};
GLubyte
*
dst
=
data_
;
for
(
std
::
size_t
i
=
0
;
i
<
imgData
->
data
().
size
();
i
+=
4
){
int
y
=
298
*
(
src
[
i
]
-
16
);
int
u
=
src
[
i
+
1
]
-
128
;
int
u1
=
516
*
u
;
int
v
=
src
[
i
+
3
]
-
128
;
int
v1
=
208
*
v
;
u
*=
100
;
v
*=
409
;
*
dst
++
=
clamp
((
y
+
v
+
128
)
>>
8
);
*
dst
++
=
clamp
((
y
-
u
-
v1
+
128
)
>>
8
);
*
dst
++
=
clamp
((
y
+
u1
+
128
)
>>
8
);
y
=
298
*
(
src
[
i
+
2
]
-
16
);
*
dst
++
=
clamp
((
y
+
v
+
128
)
>>
8
);
*
dst
++
=
clamp
((
y
-
u
-
v1
+
128
)
>>
8
);
*
dst
++
=
clamp
((
y
+
u1
+
128
)
>>
8
);
}
}
else
if
(
imgData
->
encoding
()
==
std
::
string
(
"rgb8"
)){
memcpy
(
data_
,
imgData
->
data
().
c_str
(),
imgSize
);
}
else
{
memset
(
data_
,
0
,
imgSize
);
std
::
cerr
<<
"Cannot support this format ("
<<
imgData
->
encoding
()
<<
") image"
<<
std
::
endl
;
}
is_dirty_
=
true
;
image_width_
=
imgData
->
width
();
image_height_
=
imgData
->
height
();
image_width_
=
imgData
->
width
();
texture_format_
=
GL_RGB
;
return
true
;
...
...
modules/tools/visualizer/uis/main_window.ui
浏览文件 @
d36d181b
...
...
@@ -169,8 +169,8 @@
<addaction
name=
"actionOpenImage"
/>
<addaction
name=
"actionOpenImages"
/>
<addaction
name=
"actionDelImage"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionRadar"
/>
<!--
<addaction name="separator"/>
<addaction name="actionRadar"/>
-->
</widget>
<widget
class=
"QMenu"
name=
"menuActions"
>
<property
name=
"title"
>
...
...
@@ -323,11 +323,11 @@
<string>
F9
</string>
</property>
</action>
<action
name=
"actionRadar"
>
<!--
<action name="actionRadar">
<property name="text">
<string>Radar</string>
</property>
</action>
</action>
-->
</widget>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<customwidgets>
...
...
@@ -479,7 +479,7 @@
</hint>
</hints>
</connection>
<connection>
<
!-- <
connection>
<sender>actionRadar</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
...
...
@@ -494,7 +494,7 @@
<y>376</y>
</hint>
</hints>
</connection>
</connection>
-->
</connections>
<slots>
<slot>
ActionOpenImage()
</slot>
...
...
@@ -503,6 +503,6 @@
<slot>
ActionAddGrid()
</slot>
<slot>
ActionOpenImages()
</slot>
<slot>
CloseVideoImgViewer(bool)
</slot>
<slot>
ActionOpenRadarChannel()
</slot
>
<!-- <slot>ActionOpenRadarChannel()</slot> --
>
</slots>
</ui>
modules/tools/visualizer/video_image_viewer.cc
浏览文件 @
d36d181b
...
...
@@ -82,7 +82,7 @@ void VideoImgViewer::initializeGL() {
ortho_camera_
.
set_near_plane_width
(
GLfloat
(
width
()));
ortho_camera_
.
set_near_plane_height
(
GLfloat
(
height
()));
ortho_camera_
.
set_fov
(
height
(
));
ortho_camera_
.
set_fov
(
static_cast
<
float
>
(
height
()
));
ortho_camera_
.
set_camera_mode
(
AbstractCamera
::
CameraMode
::
OrthoMode
);
ortho_camera_
.
set_position
(
0.0
f
,
0.0
f
,
0.0
f
);
...
...
@@ -103,7 +103,7 @@ void VideoImgViewer::resizeGL(int width, int height) {
glViewport
(
0
,
0
,
(
GLsizei
)
width
,
(
GLsizei
)
height
);
if
(
is_init_
)
{
ortho_camera_
.
set_fov
(
height
);
ortho_camera_
.
set_fov
(
static_cast
<
float
>
(
height
)
);
ortho_camera_
.
set_near_plane_width
(
GLfloat
(
width
));
ortho_camera_
.
set_near_plane_height
(
GLfloat
(
height
));
ortho_camera_
.
UpdateProjection
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录