[Peak Detect]

- no intersection check during finding of peak boxes

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@464 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-25 10:22:03 +00:00
parent c67aae5e51
commit f7a4b9502b
2 changed files with 20 additions and 35 deletions
+12 -30
View File
@@ -74,9 +74,7 @@ namespace gr {
std::stringstream str;
str << name() << unique_id();
m_tag_id = pmt::string_to_symbol(str.str());
fprintf(stderr, "m_peakList.size = %u\n", m_peakHistory.size());
fprintf(stderr, "m_peakList.max_size = %u\n", m_peakHistory.max_size());
}
/*
@@ -331,7 +329,6 @@ namespace gr {
continue;
}
// Find intersection
Peak peak =
{
.id = m_peak_id,
@@ -340,29 +337,15 @@ namespace gr {
.height_rel = m_pXd[pos],
.height_abs = m_pX[pos],
};
int does_intersect = 0;
for (int j=0; j < m_peakList.size(); j++)
{
if (m_peakList[j].isInRange(peak))
{
if (m_peakList[j].height_rel > peak.height_rel)
{
does_intersect = 1;
break;
}
}
}
if (!does_intersect)
{
m_peakList.push_back(peak);
m_peak_id++;
}
m_peakList.push_back(peak);
m_peak_id++;
}
// -----------------------------------------------------------------
// Peak management
// -----------------------------------------------------------------
temp.clear();
for (int i = 0; i < m_peakList.size(); i++)
{
Peak &peak = m_peakList[i];
@@ -372,7 +355,8 @@ namespace gr {
{
if (m_peakHistory[j].isInRange(peak))
{
m_peakHistory[j].update(peak);
Peak p = m_peakHistory[j].update(peak);
temp.push_back(p);
found = true;
break;
}
@@ -380,10 +364,11 @@ namespace gr {
if (!found)
{
m_peakHistory.push_back(peak);
temp.push_back(peak);
}
}
m_peakHistory = temp;
// -----------------------------------------------------------------
// Create peak box data
// -----------------------------------------------------------------
@@ -419,11 +404,8 @@ namespace gr {
{
// Create peak tags
Peak &peak = m_peakHistory[i];
pmt::pmt_t tag_key = pmt::string_to_symbol("id");
pmt::pmt_t tag_value = pmt::from_long(peak.id);
add_item_tag(DATA, nitems_written(DATA) + peak.pos, tag_key, tag_value, m_tag_id);
tag_key = pmt::string_to_symbol("pos");
tag_value = pmt::from_long(peak.pos);
pmt::pmt_t tag_key = pmt::string_to_symbol(std::string("pos_id_") + std::to_string(peak.id));
pmt::pmt_t tag_value = pmt::from_long(peak.pos);
add_item_tag(DATA, nitems_written(DATA) + peak.pos, tag_key, tag_value, m_tag_id);
}
+8 -5
View File
@@ -41,14 +41,16 @@ namespace jay {
return (other.pos >= (pos - half_width)) and (other.pos <= (pos + half_width));
}
void update(const Peak &other)
const Peak& update(const Peak &other)
{
float alpha = 0.5f;
float beta = 0.5f;
float beta = 0.1f;
float alpha = (1.f-beta);
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;
height_rel = std::max(height_rel, other.height_rel);
height_abs = std::max(height_abs, other.height_abs);
return *this;
}
};
@@ -72,6 +74,7 @@ namespace jay {
pmt::pmt_t m_tag_id;
std::vector<Peak> m_peakList;
std::vector<Peak> m_peakHistory;
std::vector<Peak> temp;
uint64_t m_peak_id;
public: