feat: RQF: filter() style interface RunningQuality
This commit is contained in:
@@ -98,8 +98,23 @@ public:
|
||||
// note: arg should be an iterator really, but can do later
|
||||
/**
|
||||
* @param beat individual beat accelero signal
|
||||
* @return true if it is good beat
|
||||
*/
|
||||
void append(std::vector<double> &rawBeat, std::vector<double> &rawSsf);
|
||||
bool append(std::vector<double> &rawBeat, std::vector<double> &rawSsf);
|
||||
};
|
||||
|
||||
/**
|
||||
* Signal quality indicator.
|
||||
*/
|
||||
class RunningQualityFilter {
|
||||
protected:
|
||||
RunningQuality f_sqi;
|
||||
std::vector<double> beat_buf;
|
||||
std::vector<double> ssf_buf;
|
||||
double sqi;
|
||||
public:
|
||||
RunningQualityFilter(size_t upslope_width);
|
||||
double filter(double y, double ssf, double step);
|
||||
};
|
||||
|
||||
#endif //PASADASUPERPROJECT_SSF_FILTER_H
|
||||
@@ -124,7 +124,7 @@ RunningQuality::RunningQuality(bool disableSsf): beatCorrThr2(BEAT_CORR_THR_2),
|
||||
RunningQuality::~RunningQuality() {}
|
||||
|
||||
// note: arg should be an iterator really, but can do later
|
||||
void RunningQuality::append(std::vector<double> &rawBeat, std::vector<double> &rawSsf) {
|
||||
bool RunningQuality::append(std::vector<double> &rawBeat, std::vector<double> &rawSsf) {
|
||||
// TODO: should ignore crazy-long and very short beats here. (filter up on beat detector)
|
||||
|
||||
std::vector<double> beat;
|
||||
@@ -181,4 +181,20 @@ void RunningQuality::append(std::vector<double> &rawBeat, std::vector<double> &r
|
||||
dispatchBeat(idx, goodBeat, posCorr);
|
||||
}
|
||||
idx++;
|
||||
if (!goodBeat) return 0.0;
|
||||
return posCorr;
|
||||
}
|
||||
|
||||
|
||||
RunningQualityFilter::RunningQualityFilter(size_t upslope_width) : sqi(0.0) {}
|
||||
|
||||
double RunningQualityFilter::filter(double y, double ssf, double step) {
|
||||
if (step == 1.0) {
|
||||
sqi = f_sqi.append(beat_buf, ssf_buf);
|
||||
beat_buf.clear();
|
||||
ssf_buf.clear();
|
||||
}
|
||||
beat_buf.push_back(y);
|
||||
ssf_buf.push_back(ssf);
|
||||
return sqi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user