Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
d538c42d
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,发现更多精彩内容 >>
提交
d538c42d
编写于
5月 10, 2018
作者:
L
Liangliang Zhang
提交者:
Jiaming Tao
5月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Perception: used proto for traffic light recognizer. Added test for proto loading.
上级
f5680df8
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
134 addition
and
124 deletion
+134
-124
modules/perception/common/perception_gflags.cc
modules/perception/common/perception_gflags.cc
+4
-0
modules/perception/common/perception_gflags.h
modules/perception/common/perception_gflags.h
+1
-0
modules/perception/conf/config_manager.config
modules/perception/conf/config_manager.config
+0
-1
modules/perception/model/traffic_light/recognizer.config
modules/perception/model/traffic_light/recognizer.config
+0
-48
modules/perception/model/traffic_light/recognizer_config.pb.txt
...s/perception/model/traffic_light/recognizer_config.pb.txt
+19
-0
modules/perception/proto/traffic_light/BUILD
modules/perception/proto/traffic_light/BUILD
+14
-0
modules/perception/proto/traffic_light/recognizer_config.proto
...es/perception/proto/traffic_light/recognizer_config.proto
+19
-0
modules/perception/traffic_light/recognizer/BUILD
modules/perception/traffic_light/recognizer/BUILD
+19
-1
modules/perception/traffic_light/recognizer/unity_recognize.cc
...es/perception/traffic_light/recognizer/unity_recognize.cc
+24
-70
modules/perception/traffic_light/recognizer/unity_recognize.h
...les/perception/traffic_light/recognizer/unity_recognize.h
+3
-4
modules/perception/traffic_light/recognizer/unity_recognize_test.cc
...rception/traffic_light/recognizer/unity_recognize_test.cc
+31
-0
未找到文件。
modules/perception/common/perception_gflags.cc
浏览文件 @
d538c42d
...
...
@@ -182,3 +182,7 @@ DEFINE_string(traffic_light_multi_camera_projection_config,
"modules/perception/model/traffic_light/"
"multi_camera_projection_config.pb.txt"
,
"traffic light multi camera projection config filename."
);
DEFINE_string
(
traffic_light_recognizer_config
,
"modules/perception/model/traffic_light/"
"recognizer_config.pb.txt"
,
"traffic light recognizer config filename."
);
modules/perception/common/perception_gflags.h
浏览文件 @
d538c42d
...
...
@@ -125,5 +125,6 @@ DECLARE_string(cnn_segmentation_config);
DECLARE_string
(
hdmap_roi_filter_config
);
DECLARE_string
(
low_object_filter_config
);
DECLARE_string
(
traffic_light_multi_camera_projection_config
);
DECLARE_string
(
traffic_light_recognizer_config
);
#endif // MODULES_PERCEPTION_COMMON_PERCEPTION_GFLAGS_H_
modules/perception/conf/config_manager.config
浏览文件 @
d538c42d
model_config_path
:
"model/traffic_light/recognizer.config"
model_config_path
:
"model/traffic_light/rectifier.config"
model_config_path
:
"model/traffic_light/reviser.config"
model_config_path
:
"model/traffic_light/preprocessor.config"
...
...
modules/perception/model/traffic_light/recognizer.config
已删除
100644 → 0
浏览文件 @
f5680df8
model_configs
{
name
:
"UnityRecognize"
version
:
"1.0.0"
string_params
{
name
:
"classify_model"
value
:
"model/traffic_light/rcg_all/2017-11-17/vertical/baidu_iter_250000.caffemodel"
}
string_params
{
name
:
"classify_net"
value
:
"model/traffic_light/rcg_all/2017-11-17/vertical/deploy.prototxt"
}
float_params
{
name
:
"classify_threshold"
value
:
0
.
5
}
integer_params
{
name
:
"classify_resize_width"
value
:
32
}
integer_params
{
name
:
"classify_resize_height"
value
:
96
}
}
model_configs
{
name
:
"UnityRecognizeNight"
version
:
"1.0.0"
string_params
{
name
:
"classify_model"
value
:
"model/traffic_light/rcg_all/2017-09-15/quadrate/baidu_iter_200000.caffemodel"
}
string_params
{
name
:
"classify_net"
value
:
"model/traffic_light/rcg_all/2017-09-15/quadrate/deploy.prototxt"
}
float_params
{
name
:
"classify_threshold"
value
:
0
.
5
}
integer_params
{
name
:
"classify_resize_width"
value
:
64
}
integer_params
{
name
:
"classify_resize_height"
value
:
64
}
}
modules/perception/model/traffic_light/recognizer_config.pb.txt
0 → 100644
浏览文件 @
d538c42d
recognizer_config {
name: "UnityRecognize"
version: "1.0.0"
classify_model: "modules/perception/model/traffic_light/rcg_all/2017-11-17/vertical/baidu_iter_250000.caffemodel"
classify_net: "modules/perception/model/traffic_light/rcg_all/2017-11-17/vertical/deploy.prototxt"
classify_threshold: 0.5
classify_resize_width: 32
classify_resize_height: 96
}
recognizer_config {
name: "UnityRecognizeNight"
version: "1.0.0"
classify_model: "modules/perception/model/traffic_light/rcg_all/2017-09-15/quadrate/baidu_iter_200000.caffemodel"
classify_net: "modules/perception/model/traffic_light/rcg_all/2017-09-15/quadrate/deploy.prototxt"
classify_threshold: 0.5
classify_resize_width: 64
classify_resize_height: 64
}
modules/perception/proto/traffic_light/BUILD
浏览文件 @
d538c42d
...
...
@@ -13,3 +13,17 @@ proto_library(
"multi_camera_projection_config.proto"
,
],
)
cc_proto_library
(
name
=
"recognizer_config_lib_proto"
,
deps
=
[
":recognizer_config_lib"
,
],
)
proto_library
(
name
=
"recognizer_config_lib"
,
srcs
=
[
"recognizer_config.proto"
,
],
)
modules/perception/proto/traffic_light/recognizer_config.proto
0 → 100644
浏览文件 @
d538c42d
syntax
=
"proto2"
;
package
apollo
.
perception.traffic_light.recognizer_config
;
message
RecognizerConfig
{
optional
string
name
=
1
;
optional
string
version
=
2
;
optional
string
classify_model
=
3
;
optional
string
classify_net
=
4
;
optional
float
classify_threshold
=
5
;
optional
int32
classify_resize_width
=
6
;
optional
int32
classify_resize_height
=
7
;
}
message
ModelConfigs
{
repeated
RecognizerConfig
recognizer_config
=
1
;
}
modules/perception/traffic_light/recognizer/BUILD
浏览文件 @
d538c42d
...
...
@@ -17,11 +17,29 @@ cc_library(
"//modules/common/proto:error_code_proto"
,
"//modules/common/proto:header_proto"
,
"//modules/map/proto:map_proto"
,
"//modules/perception/lib/config_manager"
,
"//modules/perception/proto:perception_proto"
,
"//modules/perception/proto/traffic_light:recognizer_config_lib_proto"
,
"//modules/perception/traffic_light/base"
,
"//modules/perception/traffic_light/interface"
,
],
)
cc_test
(
name
=
"unity_recognize_test"
,
size
=
"small"
,
srcs
=
[
"unity_recognize_test.cc"
,
],
data
=
[
"//modules/perception:perception_data"
,
"//modules/perception:perception_model"
,
"//modules/perception/conf:perception_config"
,
],
deps
=
[
"perception_traffic_light_recognizer"
,
"//modules/perception/lib/base"
,
"@gtest//:main"
,
],
)
cpplint
()
modules/perception/traffic_light/recognizer/unity_recognize.cc
浏览文件 @
d538c42d
...
...
@@ -17,90 +17,44 @@
#include "modules/perception/traffic_light/recognizer/unity_recognize.h"
#include "modules/common/util/file.h"
#include "modules/perception/common/perception_gflags.h"
#include "modules/perception/traffic_light/recognizer/classify.h"
namespace
apollo
{
namespace
perception
{
namespace
traffic_light
{
using
apollo
::
common
::
util
::
Get
AbsolutePath
;
using
apollo
::
common
::
util
::
Get
ProtoFromFile
;
bool
UnityRecognize
::
Init
()
{
ConfigManager
*
config_manager
=
ConfigManager
::
instance
();
if
(
config_manager
==
nullptr
)
{
AERROR
<<
"failed to get ConfigManager instance."
;
if
(
!
GetProtoFromFile
(
FLAGS_traffic_light_recognizer_config
,
&
config_
))
{
AERROR
<<
"Cannot get config proto from file: "
<<
FLAGS_traffic_light_recognizer_config
;
return
false
;
}
const
ModelConfig
*
model_config_night
=
config_manager
->
GetModelConfig
(
name
()
+
"Night"
);
if
(
model_config_night
==
nullptr
)
{
AERROR
<<
"not found model config: "
<<
name
()
+
"Night"
;
if
(
config_
.
recognizer_config_size
()
!=
2
)
{
AERROR
<<
"RecognizeConfig size should be 2."
;
return
false
;
}
if
(
!
InitModel
(
config_manager
,
model_config_night
,
&
classify_night_
))
{
AERROR
<<
"init night model failed"
;
return
false
;
}
const
ModelConfig
*
model_config_day
=
config_manager
->
GetModelConfig
(
name
());
if
(
model_config_day
==
nullptr
)
{
AERROR
<<
"not found model config: "
<<
name
();
return
false
;
}
if
(
!
InitModel
(
config_manager
,
model_config_day
,
&
classify_day_
))
{
AERROR
<<
"init day model failed"
;
return
false
;
}
return
true
;
}
bool
UnityRecognize
::
InitModel
(
const
ConfigManager
*
config_manager
,
const
ModelConfig
*
model_config
,
std
::
shared_ptr
<
IRefine
>
*
classify
)
{
std
::
string
classify_model
;
std
::
string
classify_net
;
if
(
!
model_config
->
GetValue
(
"classify_model"
,
&
classify_model
))
{
AERROR
<<
"classify_model not found."
<<
name
();
return
false
;
}
classify_model
=
GetAbsolutePath
(
config_manager
->
WorkRoot
(),
classify_model
);
if
(
!
model_config
->
GetValue
(
"classify_net"
,
&
classify_net
))
{
AERROR
<<
"classify_net not found."
<<
name
();
return
false
;
}
classify_net
=
GetAbsolutePath
(
config_manager
->
WorkRoot
(),
classify_net
);
float
classify_threshold
=
0.0
;
int
classify_resize_width
=
0
;
int
classify_resize_height
=
0
;
if
(
!
model_config
->
GetValue
(
"classify_threshold"
,
&
classify_threshold
))
{
AERROR
<<
"classify_threshold not found."
<<
name
();
return
false
;
}
if
(
!
model_config
->
GetValue
(
"classify_resize_width"
,
&
classify_resize_width
))
{
AERROR
<<
"classify_resize_width not found."
<<
name
();
return
false
;
}
if
(
!
model_config
->
GetValue
(
"classify_resize_height"
,
&
classify_resize_height
))
{
AERROR
<<
"classify_resize_height not found."
<<
name
();
return
false
;
}
if
(
!
model_config
->
GetValue
(
"classify_threshold"
,
&
classify_threshold
))
{
AERROR
<<
"classify_threshold not found."
<<
name
();
return
false
;
for
(
const
auto
&
recognizer_config
:
config_
.
recognizer_config
())
{
if
(
recognizer_config
.
name
()
==
"UnityRecognizeNight"
)
{
classify_night_
=
std
::
make_shared
<
ClassifyBySimple
>
(
recognizer_config
.
classify_net
(),
recognizer_config
.
classify_model
(),
recognizer_config
.
classify_threshold
(),
static_cast
<
unsigned
int
>
(
recognizer_config
.
classify_resize_width
()),
static_cast
<
unsigned
int
>
(
recognizer_config
.
classify_resize_height
()));
}
if
(
recognizer_config
.
name
()
==
"UnityRecognize"
)
{
classify_day_
=
std
::
make_shared
<
ClassifyBySimple
>
(
recognizer_config
.
classify_net
(),
recognizer_config
.
classify_model
(),
recognizer_config
.
classify_threshold
(),
static_cast
<
unsigned
int
>
(
recognizer_config
.
classify_resize_width
()),
static_cast
<
unsigned
int
>
(
recognizer_config
.
classify_resize_height
()));
}
}
classify
->
reset
(
new
ClassifyBySimple
(
classify_net
,
classify_model
,
classify_threshold
,
(
unsigned
int
)
classify_resize_width
,
(
unsigned
int
)
classify_resize_height
));
return
true
;
}
...
...
modules/perception/traffic_light/recognizer/unity_recognize.h
浏览文件 @
d538c42d
...
...
@@ -20,7 +20,8 @@
#include <string>
#include <vector>
#include "modules/perception/lib/config_manager/config_manager.h"
#include "modules/perception/proto/traffic_light/recognizer_config.pb.h"
#include "modules/perception/traffic_light/interface/base_recognizer.h"
#include "modules/perception/traffic_light/interface/green_interface.h"
...
...
@@ -54,9 +55,7 @@ class UnityRecognize : public BaseRecognizer {
std
::
shared_ptr
<
IRefine
>
classify_day_
;
std
::
shared_ptr
<
IRefine
>
classify_night_
;
bool
InitModel
(
const
ConfigManager
*
config_manager
,
const
ModelConfig
*
model_config
,
std
::
shared_ptr
<
IRefine
>
*
classify
);
traffic_light
::
recognizer_config
::
ModelConfigs
config_
;
};
REGISTER_RECOGNIZER
(
UnityRecognize
);
...
...
modules/perception/traffic_light/recognizer/unity_recognize_test.cc
0 → 100644
浏览文件 @
d538c42d
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/perception/traffic_light/recognizer/unity_recognize.h"
#include "gtest/gtest.h"
namespace
apollo
{
namespace
perception
{
namespace
traffic_light
{
TEST
(
UnityRecognizeTest
,
load_proto
)
{
UnityRecognize
ur
;
EXPECT_TRUE
(
ur
.
Init
());
}
}
// namespace traffic_light
}
// namespace perception
}
// namespace apollo
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录