- improved peak manager: less noisy peak new/lost
git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@475 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -202,7 +202,7 @@ namespace gr {
|
||||
// -----------------------------------------------------------------
|
||||
// Search true maximum peak using hill climbing
|
||||
// -----------------------------------------------------------------
|
||||
std::vector<Peak> newPeakPos;
|
||||
std::vector<Peak> peaks;
|
||||
int numPeaksLast = 0;
|
||||
while(1)
|
||||
{
|
||||
@@ -226,8 +226,8 @@ namespace gr {
|
||||
else
|
||||
{
|
||||
Peak peak(m_peak_id++, pos);
|
||||
peak.height_abs = m_pXds[pos];
|
||||
addToListByPos(newPeakPos, peak);
|
||||
peak.heightUpdate_rel(m_pXds, nitems_per_block);
|
||||
addToListByPos(peaks, peak);
|
||||
numPeaksClimbed++;
|
||||
break;
|
||||
}
|
||||
@@ -243,15 +243,15 @@ namespace gr {
|
||||
// -----------------------------------------------------------------
|
||||
// Sort peaks
|
||||
// -----------------------------------------------------------------
|
||||
sort(newPeakPos);
|
||||
sort(peaks);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Find peak boxes
|
||||
// -----------------------------------------------------------------
|
||||
m_peakList.clear();
|
||||
for (int i = 0; i < newPeakPos.size(); i++)
|
||||
for (int i = 0; i < peaks.size(); i++)
|
||||
{
|
||||
Peak &peak = newPeakPos[i];
|
||||
Peak &peak = peaks[i];
|
||||
bool success = peak.makeBox(m_peak_width_min, m_peak_width_max, m_pXds, nitems_per_block);
|
||||
if (success)
|
||||
{
|
||||
@@ -259,9 +259,10 @@ namespace gr {
|
||||
bool intersection = false;
|
||||
for (int i = 0; i < m_peakList.size(); i++)
|
||||
{
|
||||
if (m_peakList[i].isInRange(peak))
|
||||
if (m_peakList[i].isIntersect(peak))
|
||||
{
|
||||
intersection = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,16 +279,31 @@ namespace gr {
|
||||
// Peak management
|
||||
// -----------------------------------------------------------------
|
||||
temp.clear();
|
||||
for (int j=0; j < m_peakHistory.size(); j++)
|
||||
{
|
||||
Peak &peak = m_peakHistory[j];
|
||||
peak.heightUpdate_rel(m_pXds, nitems_per_block);
|
||||
|
||||
if (peak.height_rel >= (m_peak_height_min-6.f))
|
||||
{
|
||||
temp.push_back(peak);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Lost Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_peakList.size(); i++)
|
||||
{
|
||||
Peak &peak = m_peakList[i];
|
||||
|
||||
|
||||
bool found = false;
|
||||
for (int j=0; j < m_peakHistory.size(); j++)
|
||||
for (int j=0; j < temp.size(); j++)
|
||||
{
|
||||
if (m_peakHistory[j].isInRange(peak))
|
||||
if (temp[j].isInRange(peak))
|
||||
{
|
||||
temp.push_back(m_peakHistory[j].update(peak));
|
||||
temp[j].merge(peak);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -295,20 +311,11 @@ namespace gr {
|
||||
|
||||
if (!found)
|
||||
{
|
||||
peak.isValid = 1;
|
||||
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.isValid)
|
||||
{
|
||||
fprintf(stderr, "Lost Peak #%u at %d\n", (int)peak.id, (int)peak.pos);
|
||||
}
|
||||
}
|
||||
m_peakHistory.clear();
|
||||
m_peakHistory = temp;
|
||||
|
||||
@@ -350,7 +357,6 @@ namespace gr {
|
||||
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) + k, tag_key, tag_value, m_tag_id);
|
||||
peak.isValid = false;
|
||||
}
|
||||
|
||||
m_frameCount++;
|
||||
|
||||
Reference in New Issue
Block a user