Apollo 10.0
自动驾驶开放平台
apollo::audio 命名空间参考

apollo::audio 更多...

class  AudioComponent
 
struct  AudioConf
 
struct  AudioDetection
 
struct  AudioEvent
 
class  AudioInfo
 
class  DirectionDetection
 
class  MessageProcess
 
class  MovingDetection
 
class  SirenDetection
 
struct  TopicConf
 

枚举

enum  MovingResult { UNKNOWN = 0 , APPROACHING = 1 , DEPARTING = 2 , STATIONARY = 3 }
 
enum  AudioType { UNKNOWN_TYPE = 0 , POLICE = 1 , AMBULANCE = 2 , FIRETRUCK = 3 }
 
enum  AudioDirection {
  UNKNOWN_DIRECTION = 0 , FRONT = 1 , LEFT = 2 , BACK = 3 ,
  RIGHT = 4
}
 

函数

void GetRecordFileNames (const boost::filesystem::path &p, std::vector< std::string > *record_files)
 
void ProcessSingleRecordFile (const AudioConf &audio_conf, const std::string &input_record_filepath, const std::string &output_record_filepath, AudioInfo *audio_info, DirectionDetection *direction_detection, MovingDetection *moving_detection, SirenDetection *siren_detection)
 
void ProcessFolder ()
 

详细描述

枚举类型说明

◆ AudioDirection

枚举值
UNKNOWN_DIRECTION 
FRONT 
LEFT 
BACK 
RIGHT 

在文件 audio_common.proto35 行定义.

◆ AudioType

枚举值
UNKNOWN_TYPE 
POLICE 
AMBULANCE 
FIRETRUCK 

在文件 audio_common.proto28 行定义.

◆ MovingResult

枚举值
UNKNOWN 
APPROACHING 
DEPARTING 
STATIONARY 

在文件 audio_common.proto21 行定义.

函数说明

◆ GetRecordFileNames()

void apollo::audio::GetRecordFileNames ( const boost::filesystem::path &  p,
std::vector< std::string > *  record_files 
)

在文件 audio_offline_processing.cc42 行定义.

43 {
44 if (!boost::filesystem::exists(p)) {
45 return;
46 }
47 if (boost::filesystem::is_regular_file(p)) {
48 AINFO << "Found record file: " << p.c_str();
49 record_files->push_back(p.c_str());
50 return;
51 }
52 if (boost::filesystem::is_directory(p)) {
53 for (auto& entry : boost::make_iterator_range(
54 boost::filesystem::directory_iterator(p), {})) {
55 GetRecordFileNames(entry.path(), record_files);
56 }
57 }
58}
#define AINFO
Definition log.h:42
void GetRecordFileNames(const boost::filesystem::path &p, std::vector< std::string > *record_files)

◆ ProcessFolder()

void apollo::audio::ProcessFolder ( )

在文件 audio_offline_processing.cc116 行定义.

116 {
117 if (FLAGS_audio_records_dir.empty()) {
118 AERROR << "The input folder is empty";
119 return;
120 }
121 AudioConf audio_conf;
122 if (!cyber::common::GetProtoFromFile(FLAGS_audio_conf_file,
123 &audio_conf)) {
124 return;
125 }
126 AudioInfo audio_info;
127 DirectionDetection direction_detection;
128 MovingDetection moving_detection;
129 SirenDetection siren_detection;
130 std::vector<std::string> offline_bags;
131 GetRecordFileNames(boost::filesystem::path(FLAGS_audio_records_dir),
132 &offline_bags);
133 std::sort(offline_bags.begin(), offline_bags.end());
134 for (std::size_t i = 0; i < offline_bags.size(); ++i) {
135 const std::string& input_record_filepath = offline_bags[i];
136 std::string output_record_filepath =
137 input_record_filepath + ".new_audio_detection";
138 ProcessSingleRecordFile(audio_conf, input_record_filepath,
139 output_record_filepath, &audio_info, &direction_detection,
140 &moving_detection, &siren_detection);
141 }
142}
#define AERROR
Definition log.h:44

◆ ProcessSingleRecordFile()

void apollo::audio::ProcessSingleRecordFile ( const AudioConf audio_conf,
const std::string &  input_record_filepath,
const std::string &  output_record_filepath,
AudioInfo audio_info,
DirectionDetection direction_detection,
MovingDetection moving_detection,
SirenDetection siren_detection 
)

在文件 audio_offline_processing.cc60 行定义.

66 {
67 RecordReader reader(input_record_filepath);
68 RecordMessage message;
69 RecordWriter writer;
70 writer.Open(output_record_filepath);
71 while (reader.ReadMessage(&message)) {
72 if (message.channel_name ==
73 audio_conf.topic_conf().audio_data_topic_name()) {
74 AudioData audio_data;
75 if (audio_data.ParseFromString(message.content)) {
76 AudioDetection audio_detection;
77 std::string respeaker_extrinsics_file =
78 audio_conf.respeaker_extrinsics_path();
79 MessageProcess::OnMicrophone(audio_data, respeaker_extrinsics_file,
80 audio_info, direction_detection, moving_detection, siren_detection,
81 &audio_detection);
84 audio_detection, message.time);
85 AINFO << "Generate a new audio detection message.";
86 }
87 } else if (message.channel_name ==
88 audio_conf.topic_conf().audio_event_topic_name()) {
89 AudioEvent audio_event;
90 if (audio_event.ParseFromString(message.content)) {
91 writer.WriteMessage<AudioEvent>(message.channel_name, audio_event,
92 message.time);
93 AINFO << "Save an audio even message.";
94 }
95 } else if (message.channel_name ==
96 audio_conf.topic_conf().localization_topic_name()) {
97 LocalizationEstimate localization;
98 if (localization.ParseFromString(message.content)) {
99 writer.WriteMessage<LocalizationEstimate>(
100 message.channel_name, localization, message.time);
101 AINFO << "Save a localization message.";
102 }
103 } else if (message.channel_name ==
104 audio_conf.topic_conf().perception_topic_name()) {
105 PerceptionObstacles perception_obstacles;
106 if (perception_obstacles.ParseFromString(message.content)) {
107 writer.WriteMessage<PerceptionObstacles>(
108 message.channel_name, perception_obstacles, message.time);
109 AINFO << "Save a perception message.";
110 }
111 }
112 }
113 writer.Close();
114}
bool Open(const std::string &file)
Open a record to write.
bool WriteMessage(const std::string &channel_name, const MessageT &message, const uint64_t time_nanosec, const std::string &proto_desc="")
Write a message to record.
optional TopicConf topic_conf
optional string respeaker_extrinsics_path
optional string audio_data_topic_name
optional string audio_event_topic_name
optional string localization_topic_name
optional string perception_topic_name
optional string audio_detection_topic_name
Basic data struct of record message.
std::string content
The content of the message.
uint64_t time
The time (nanosecond) of the message.
std::string channel_name
The channel name of the message.