[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:
@@ -74,9 +74,7 @@ namespace gr {
|
|||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str << name() << unique_id();
|
str << name() << unique_id();
|
||||||
m_tag_id = pmt::string_to_symbol(str.str());
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find intersection
|
|
||||||
Peak peak =
|
Peak peak =
|
||||||
{
|
{
|
||||||
.id = m_peak_id,
|
.id = m_peak_id,
|
||||||
@@ -340,29 +337,15 @@ namespace gr {
|
|||||||
.height_rel = m_pXd[pos],
|
.height_rel = m_pXd[pos],
|
||||||
.height_abs = m_pX[pos],
|
.height_abs = m_pX[pos],
|
||||||
};
|
};
|
||||||
int does_intersect = 0;
|
|
||||||
for (int j=0; j < m_peakList.size(); j++)
|
m_peakList.push_back(peak);
|
||||||
{
|
m_peak_id++;
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// Peak management
|
// Peak management
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
temp.clear();
|
||||||
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];
|
||||||
@@ -372,7 +355,8 @@ namespace gr {
|
|||||||
{
|
{
|
||||||
if (m_peakHistory[j].isInRange(peak))
|
if (m_peakHistory[j].isInRange(peak))
|
||||||
{
|
{
|
||||||
m_peakHistory[j].update(peak);
|
Peak p = m_peakHistory[j].update(peak);
|
||||||
|
temp.push_back(p);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -380,10 +364,11 @@ namespace gr {
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
m_peakHistory.push_back(peak);
|
temp.push_back(peak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_peakHistory = temp;
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// Create peak box data
|
// Create peak box data
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
@@ -419,11 +404,8 @@ namespace gr {
|
|||||||
{
|
{
|
||||||
// Create peak tags
|
// Create peak tags
|
||||||
Peak &peak = m_peakHistory[i];
|
Peak &peak = m_peakHistory[i];
|
||||||
pmt::pmt_t tag_key = pmt::string_to_symbol("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.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);
|
|
||||||
tag_key = pmt::string_to_symbol("pos");
|
|
||||||
tag_value = pmt::from_long(peak.pos);
|
|
||||||
add_item_tag(DATA, nitems_written(DATA) + peak.pos, tag_key, tag_value, m_tag_id);
|
add_item_tag(DATA, nitems_written(DATA) + peak.pos, tag_key, tag_value, m_tag_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,16 @@ namespace jay {
|
|||||||
return (other.pos >= (pos - half_width)) and (other.pos <= (pos + half_width));
|
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.1f;
|
||||||
float beta = 0.5f;
|
float alpha = (1.f-beta);
|
||||||
pos = alpha*pos + beta*other.pos;
|
pos = alpha*pos + beta*other.pos;
|
||||||
half_width = alpha*half_width + beta*other.half_width;
|
half_width = alpha*half_width + beta*other.half_width;
|
||||||
height_rel = alpha*height_rel + beta*other.height_rel;
|
height_rel = std::max(height_rel, other.height_rel);
|
||||||
height_abs = alpha*height_abs + beta*other.height_abs;
|
height_abs = std::max(height_abs, other.height_abs);
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ namespace jay {
|
|||||||
pmt::pmt_t m_tag_id;
|
pmt::pmt_t m_tag_id;
|
||||||
std::vector<Peak> m_peakList;
|
std::vector<Peak> m_peakList;
|
||||||
std::vector<Peak> m_peakHistory;
|
std::vector<Peak> m_peakHistory;
|
||||||
|
std::vector<Peak> temp;
|
||||||
uint64_t m_peak_id;
|
uint64_t m_peak_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user