Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
126f06e9
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,发现更多精彩内容 >>
提交
126f06e9
编写于
8月 31, 2020
作者:
K
kechxu
提交者:
Kecheng Xu
8月 31, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
audio: add degree into audio detection output
上级
10bac81c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
9 deletion
+17
-9
modules/audio/common/message_process.cc
modules/audio/common/message_process.cc
+3
-1
modules/audio/inference/BUILD
modules/audio/inference/BUILD
+1
-0
modules/audio/inference/direction_detection.cc
modules/audio/inference/direction_detection.cc
+8
-5
modules/audio/inference/direction_detection.h
modules/audio/inference/direction_detection.h
+4
-3
modules/audio/proto/audio.proto
modules/audio/proto/audio.proto
+1
-0
未找到文件。
modules/audio/common/message_process.cc
浏览文件 @
126f06e9
...
...
@@ -30,12 +30,14 @@ void MessageProcess::OnMicrophone(
SirenDetection
*
siren_detection
,
AudioDetection
*
audio_detection
)
{
audio_info
->
Insert
(
audio_data
);
*
(
audio_detection
->
mutable_position
())
=
auto
direction_result
=
direction_detection
->
EstimateSoundSource
(
audio_info
->
GetSignals
(
audio_data
.
microphone_config
().
chunk
()),
respeaker_extrinsics_file
,
audio_data
.
microphone_config
().
sample_rate
(),
audio_data
.
microphone_config
().
mic_distance
());
*
(
audio_detection
->
mutable_position
())
=
direction_result
.
first
;
audio_detection
->
set_source_degree
(
direction_result
.
second
);
bool
is_siren
=
siren_detection
->
Evaluate
(
audio_info
->
GetSignals
(
72000
));
audio_detection
->
set_is_siren
(
is_siren
);
...
...
modules/audio/inference/BUILD
浏览文件 @
126f06e9
...
...
@@ -19,6 +19,7 @@ cc_library(
hdrs
=
[
"direction_detection.h"
],
deps
=
[
"//cyber"
,
"//modules/common/math:math_utils"
,
"//modules/common/proto:geometry_cc_proto"
,
"//third_party:libtorch"
,
"@com_github_jbeder_yaml_cpp//:yaml-cpp"
,
...
...
modules/audio/inference/direction_detection.cc
浏览文件 @
126f06e9
...
...
@@ -17,17 +17,20 @@
#include "modules/audio/inference/direction_detection.h"
#include "yaml-cpp/yaml.h"
#include "modules/common/math/math_utils.h"
namespace
apollo
{
namespace
audio
{
using
torch
::
indexing
::
None
;
using
torch
::
indexing
::
Slice
;
using
apollo
::
common
::
math
::
NormalizeAngle
;
DirectionDetection
::
DirectionDetection
()
{}
DirectionDetection
::~
DirectionDetection
()
{}
Point3D
DirectionDetection
::
EstimateSoundSource
(
std
::
pair
<
Point3D
,
double
>
DirectionDetection
::
EstimateSoundSource
(
std
::
vector
<
std
::
vector
<
double
>>&&
channels_vec
,
const
std
::
string
&
respeaker_extrinsic_file
,
const
int
sample_rate
,
const
double
mic_distance
)
{
...
...
@@ -35,7 +38,7 @@ Point3D DirectionDetection::EstimateSoundSource(
respeaker2imu_ptr_
.
reset
(
new
Eigen
::
Matrix4d
);
LoadExtrinsics
(
respeaker_extrinsic_file
,
respeaker2imu_ptr_
.
get
());
}
const
double
degree
=
double
degree
=
EstimateDirection
(
move
(
channels_vec
),
sample_rate
,
mic_distance
);
Eigen
::
Vector4d
source_position
(
kDistance
*
sin
(
degree
),
kDistance
*
cos
(
degree
),
0
,
1
);
...
...
@@ -45,8 +48,8 @@ Point3D DirectionDetection::EstimateSoundSource(
source_position_p3d
.
set_x
(
source_position
[
0
]);
source_position_p3d
.
set_y
(
source_position
[
1
]);
source_position_p3d
.
set_z
(
source_position
[
2
]);
return
source_position_p3d
;
degree
=
NormalizeAngle
(
degree
);
return
{
source_position_p3d
,
degree
}
;
}
double
DirectionDetection
::
EstimateDirection
(
...
...
@@ -76,7 +79,7 @@ double DirectionDetection::EstimateDirection(
}
best_guess
=
(
-
best_guess
+
480
)
%
360
;
return
static_cast
<
double
>
(
best_guess
)
/
9
0
*
M_PI
;
return
static_cast
<
double
>
(
best_guess
)
/
18
0
*
M_PI
;
}
bool
DirectionDetection
::
LoadExtrinsics
(
const
std
::
string
&
yaml_file
,
...
...
modules/audio/inference/direction_detection.h
浏览文件 @
126f06e9
...
...
@@ -47,9 +47,10 @@ class DirectionDetection {
DirectionDetection
();
~
DirectionDetection
();
// Estimates the position of the source of the sound
Point3D
EstimateSoundSource
(
std
::
vector
<
std
::
vector
<
double
>>&&
channels_vec
,
const
std
::
string
&
respeaker_extrinsic_file
,
const
int
sample_rate
,
const
double
mic_distance
);
std
::
pair
<
Point3D
,
double
>
EstimateSoundSource
(
std
::
vector
<
std
::
vector
<
double
>>&&
channels_vec
,
const
std
::
string
&
respeaker_extrinsic_file
,
const
int
sample_rate
,
const
double
mic_distance
);
private:
const
double
kSoundSpeed
=
343.2
;
...
...
modules/audio/proto/audio.proto
浏览文件 @
126f06e9
...
...
@@ -27,4 +27,5 @@ message AudioDetection {
optional
bool
is_siren
=
2
;
optional
apollo.audio.MovingResult
moving_result
=
3
[
default
=
UNKNOWN
];
optional
apollo.common.Point3D
position
=
4
;
optional
double
source_degree
=
5
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录