- reenabled intersection test

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@469 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-25 14:20:21 +00:00
parent 93af373756
commit bedd7b0f00
2 changed files with 33 additions and 6 deletions
+31 -5
View File
@@ -341,10 +341,24 @@ namespace gr {
.half_width = (float)pbh, .half_width = (float)pbh,
.height_rel = m_pXd[pos], .height_rel = m_pXd[pos],
.height_abs = m_pX[pos], .height_abs = m_pX[pos],
.isConfirmed = true,
}; };
m_peakList.push_back(peak); // Intersection check
m_peak_id++; bool intersection = false;
for (int i = 0; i < m_peakList.size(); i++)
{
if (m_peakList[i].isInRange(peak))
{
intersection = true;
}
}
if (!intersection)
{
m_peakList.push_back(peak);
m_peak_id++;
}
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@@ -354,14 +368,13 @@ namespace gr {
for (int i = 0; i < m_peakList.size(); i++) for (int i = 0; i < m_peakList.size(); i++)
{ {
Peak &peak = m_peakList[i]; Peak &peak = m_peakList[i];
bool found = false; bool found = false;
for (int j=0; j < m_peakHistory.size(); j++) for (int j=0; j < m_peakHistory.size(); j++)
{ {
if (m_peakHistory[j].isInRange(peak)) if (m_peakHistory[j].isInRange(peak))
{ {
Peak p = m_peakHistory[j].update(peak); temp.push_back(m_peakHistory[j].update(peak));
temp.push_back(p);
found = true; found = true;
break; break;
} }
@@ -369,9 +382,21 @@ namespace gr {
if (!found) if (!found)
{ {
peak.isConfirmed = 1;
temp.push_back(peak); temp.push_back(peak);
fprintf(stderr, "New Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
} }
} }
for (int j=0; j < m_peakHistory.size(); j++)
{
Peak &peak = m_peakHistory[j];
if (!peak.isConfirmed)
{
fprintf(stderr, "Lost Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
}
}
m_peakHistory.clear();
m_peakHistory = temp; m_peakHistory = temp;
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@@ -412,6 +437,7 @@ namespace gr {
pmt::pmt_t tag_key = pmt::string_to_symbol(std::string("pos_id_") + std::to_string(peak.id)); 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); pmt::pmt_t tag_value = pmt::from_long(peak.pos);
add_item_tag(DATA, nitems_written(DATA) + k, tag_key, tag_value, m_tag_id); add_item_tag(DATA, nitems_written(DATA) + k, tag_key, tag_value, m_tag_id);
peak.isConfirmed = false;
} }
m_frameCount++; m_frameCount++;
+2 -1
View File
@@ -35,6 +35,7 @@ namespace jay {
float half_width; float half_width;
float height_rel; float height_rel;
float height_abs; float height_abs;
bool isConfirmed;
bool isInRange(const Peak &other) bool isInRange(const Peak &other)
{ {
@@ -49,7 +50,7 @@ namespace jay {
half_width = alpha*half_width + beta*other.half_width; half_width = alpha*half_width + beta*other.half_width;
height_rel = std::max(height_rel, other.height_rel); height_rel = std::max(height_rel, other.height_rel);
height_abs = std::max(height_abs, other.height_abs); height_abs = std::max(height_abs, other.height_abs);
isConfirmed = true;
return *this; return *this;
} }
}; };