- introduced peak history

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@463 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-25 09:35:42 +00:00
parent 1e0259a4f6
commit c67aae5e51
2 changed files with 108 additions and 35 deletions
+29 -2
View File
@@ -28,6 +28,30 @@ namespace jay {
class peak_detect_impl : public peak_detect
{
struct Peak
{
uint64_t id;
float pos;
float half_width;
float height_rel;
float height_abs;
bool isInRange(const Peak &other)
{
return (other.pos >= (pos - half_width)) and (other.pos <= (pos + half_width));
}
void update(const Peak &other)
{
float alpha = 0.5f;
float beta = 0.5f;
pos = alpha*pos + beta*other.pos;
half_width = alpha*half_width + beta*other.half_width;
height_rel = alpha*height_rel + beta*other.height_rel;
height_abs = alpha*height_abs + beta*other.height_abs;
}
};
private:
float m_framerate;
@@ -42,11 +66,13 @@ namespace jay {
float *m_pXm;
float *m_pXd;
int *m_pPeakPos;
int *m_pPeakPos_final;
float *m_pPeakBox_rel;
float *m_pPeakBox_abs;
uint64_t m_frameCount;
pmt::pmt_t m_tag_id;
std::vector<Peak> m_peakList;
std::vector<Peak> m_peakHistory;
uint64_t m_peak_id;
public:
peak_detect_impl(int vlen, float framerate, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m);
@@ -60,7 +86,8 @@ namespace jay {
int threshold(float *pDst, float *pSrc, int length, float thresh);
int findPeakPos(int *pDst, float *pSrc, int length);
inline void sort(float const * const pData, int *pPos, int numPos)
template <typename T>
inline void sort(T const * const pData, int *pPos, int numPos)
{
int n = numPos;
do