Apollo 10.0
自动驾驶开放平台
moving_detection.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include <deque>
18#include <vector>
19#include <complex>
20
21#include "modules/common_msgs/audio_msgs/audio.pb.h"
22
23namespace apollo {
24namespace audio {
25
32 public:
33 MovingDetection() = default;
34
35 std::vector<std::complex<double>> fft1d(const std::vector<double>& signals);
36
37 MovingResult Detect(const std::vector<std::vector<double>>& signals);
38
40 const std::size_t channel_index, const std::vector<double>& signal);
41
42 private:
43 class SignalStat {
44 public:
45 SignalStat(double power, int top_frequency)
46 : power_(power), top_frequency_(top_frequency) {}
47 double power() const { return power_; }
48 int top_frequency() const { return top_frequency_; }
49 private:
50 double power_;
51 int top_frequency_;
52 };
53
54 SignalStat GetSignalStat(
55 const std::vector<std::complex<double>>& fft_results,
56 const int start_frequency);
57
58 MovingResult AnalyzePower(const std::deque<SignalStat>& signal_stats);
59
60 MovingResult AnalyzeTopFrequence(const std::deque<SignalStat>& signal_stats);
61
62 std::vector<std::deque<SignalStat>> signal_stats_;
63};
64
65} // namespace audio
66} // namespace apollo
std::vector< std::complex< double > > fft1d(const std::vector< double > &signals)
MovingResult DetectSingleChannel(const std::size_t channel_index, const std::vector< double > &signal)
MovingResult Detect(const std::vector< std::vector< double > > &signals)
class register implement
Definition arena_queue.h:37